Settings
Movie List Directory selection
This commit is contained in:
1 parent
272e0b8527
commit
8682be33fb
27 files changed
+1770
-233
No files matched your search
@@ -1,8 +1,66 @@
|
||||
from couchpotato.api.file_browser import FileBrowser
|
||||
from couchpotato.core.settings import settings
|
||||
from couchpotato.core.settings.loader import settings_loader
|
||||
from flask import Module
|
||||
from flask.helpers import jsonify
|
||||
import flask
|
||||
|
||||
api = Module(__name__)
|
||||
|
||||
@api.route('/')
|
||||
@api.route('')
|
||||
def index():
|
||||
return jsonify({'test': 'bla'})
|
||||
|
||||
|
||||
@api.route('settings/')
|
||||
def settings_view():
|
||||
return jsonify({
|
||||
'sections': settings_loader.sections,
|
||||
'values': settings.getValues()
|
||||
})
|
||||
|
||||
@api.route('setting.save/')
|
||||
def setting_save_view():
|
||||
a = flask.request.args
|
||||
|
||||
section = a.get('section')
|
||||
option = a.get('name')
|
||||
value = a.get('value')
|
||||
|
||||
settings.set(section, option, value)
|
||||
settings.save()
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
});
|
||||
|
||||
@api.route('movie/')
|
||||
def movie():
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'movies': [
|
||||
{
|
||||
'name': 'Movie 1',
|
||||
'description': 'Description 1',
|
||||
},
|
||||
{
|
||||
'name': 'Movie 2',
|
||||
'description': 'Description 2',
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
@api.route('directory.list/')
|
||||
def director_list():
|
||||
a = flask.request.args
|
||||
|
||||
try:
|
||||
fb = FileBrowser(a.get('path', '/'))
|
||||
dirs = fb.getDirectories()
|
||||
except:
|
||||
dirs = []
|
||||
|
||||
return jsonify({
|
||||
'empty': len(dirs) == 0,
|
||||
'dirs': dirs,
|
||||
})
|
||||
@@ -0,0 +1,38 @@
|
||||
import os
|
||||
import string
|
||||
|
||||
if os.name == 'nt':
|
||||
import win32file
|
||||
|
||||
class FileBrowser():
|
||||
|
||||
def __init__(self, path = '/'):
|
||||
self.path = path
|
||||
|
||||
def getDirectories(self):
|
||||
|
||||
# Return driveletters or root if path is empty
|
||||
if self.path == '/' or not self.path:
|
||||
if os.name == 'nt':
|
||||
return self.getDriveLetters()
|
||||
self.path = '/'
|
||||
|
||||
dirs = []
|
||||
for f in os.listdir(self.path):
|
||||
path = os.path.join(self.path, f)
|
||||
if(os.path.isdir(path)):
|
||||
dirs.append(path)
|
||||
|
||||
return dirs
|
||||
|
||||
def getFiles(self):
|
||||
pass
|
||||
|
||||
def getDriveLetters(self):
|
||||
|
||||
driveletters = []
|
||||
for drive in string.ascii_uppercase:
|
||||
if win32file.GetDriveType(drive + ":") == win32file.DRIVE_FIXED:
|
||||
driveletters.append(drive + ":")
|
||||
|
||||
return driveletters
|
||||
Reference in new issue
Block a user