Settings, directory browser

This commit is contained in:
Ruud
2011-09-05 22:09:54 +02:00
parent 6430014c56
commit 1e36aeced3
13 changed files with 208 additions and 180 deletions
-74
View File
@@ -1,75 +1 @@
from uuid import uuid4
def start():
pass
config = [{
'name': 'core',
'groups': [
{
'tab': 'general',
'name': 'basics',
'description': 'Needs restart before changes take effect.',
'options': [
{
'name': 'username',
'default': '',
},
{
'name': 'password',
'default': '',
'type': 'password',
},
{
'name': 'host',
'advanced': True,
'default': '0.0.0.0',
'label': 'IP',
'description': 'Host that I should listen to. "0.0.0.0" listens to all ips.',
},
{
'name': 'port',
'default': 5000,
'type': 'int',
'description': 'The port I should listen to.',
},
{
'name': 'launch_browser',
'default': 1,
'type': 'bool',
'label': 'Launch Browser',
'description': 'Launch the browser when I start.',
},
],
},
{
'tab': 'general',
'name': 'advanced',
'description': "For those who know what the're doing",
'advanced': True,
'options': [
{
'name': 'api_key',
'default': uuid4().hex,
'readonly': 1,
'label': 'Api Key',
'description': "This is top-secret! Don't share this!",
},
{
'name': 'debug',
'default': 0,
'type': 'bool',
'label': 'Debug',
'description': 'Enable debugging.',
},
{
'name': 'url_base',
'default': '',
'label': 'Url Base',
'description': 'When using mod_proxy use this to append the url with this.',
},
],
},
],
}]
+17 -1
View File
@@ -1,6 +1,7 @@
from couchpotato.api import addApiView
from couchpotato.core.helpers.request import getParam, jsonified
from couchpotato.core.plugins.base import Plugin
import ctypes
import os
import string
@@ -23,7 +24,7 @@ class FileBrowser(Plugin):
dirs = []
for f in os.listdir(path):
p = os.path.join(path, f)
if(os.path.isdir(p)):
if os.path.isdir(p) and ((self.is_hidden(p) and bool(int(show_hidden))) or not self.is_hidden(p)):
dirs.append(p + '/')
return dirs
@@ -48,6 +49,21 @@ class FileBrowser(Plugin):
dirs = []
return jsonified({
'is_root': getParam('path', '/') == '/',
'empty': len(dirs) == 0,
'dirs': dirs,
})
def is_hidden(self, filepath):
name = os.path.basename(os.path.abspath(filepath))
return name.startswith('.') or self.has_hidden_attribute(filepath)
def has_hidden_attribute(self, filepath):
try:
attrs = ctypes.windll.kernel32.GetFileAttributesW(unicode(filepath))
assert attrs != -1
result = bool(attrs & 2)
except (AttributeError, AssertionError):
result = False
return result
+3 -1
View File
@@ -51,7 +51,9 @@ class LibraryPlugin(Plugin):
library = db.query(Library).filter_by(identifier = identifier).first()
done_status = fireEvent('status.get', 'done', single = True)
library_dict = library.to_dict(self.default_dict)
if library:
library_dict = library.to_dict(self.default_dict)
do_update = True
if library.status_id == done_status.get('id') and not force:
+11 -16
View File
@@ -10,6 +10,14 @@ from urllib import urlencode
class MoviePlugin(Plugin):
default_dict = {
'profile': {'types': {'quality': {}}},
'releases': {'status': {}, 'quality': {}, 'files':{}, 'info': {}},
'library': {'titles': {}, 'files':{}},
'files': {},
'status': {}
}
def __init__(self):
addApiView('movie.search', self.search)
addApiView('movie.list', self.list)
@@ -30,12 +38,7 @@ class MoviePlugin(Plugin):
movies = []
for movie in results:
temp = movie.to_dict(deep = {
'releases': {'status': {}, 'quality': {}, 'files':{}, 'info': {}},
'library': {'titles': {}, 'files':{}},
'files': {}
})
temp = movie.to_dict(self.default_dict)
movies.append(temp)
return jsonified({
@@ -59,12 +62,7 @@ class MoviePlugin(Plugin):
if movie:
#addEvent('library.update.after', )
fireEventAsync('library.update', identifier = movie.library.identifier, default_title = default_title, force = True)
fireEventAsync('searcher.single', movie.to_dict(deep = {
'profile': {'types': {'quality': {}}},
'releases': {'status': {}, 'quality': {}, 'files': {}, 'info': {}},
'library': {'titles': {}, 'files':{}},
'files': {}
}))
fireEventAsync('searcher.single', movie.to_dict(self.default_dict))
return jsonified({
'success': True,
@@ -119,10 +117,7 @@ class MoviePlugin(Plugin):
m.status_id = status_active.get('id')
db.commit()
movie_dict = m.to_dict(deep = {
'releases': {'status': {}, 'quality': {}, 'files': {}, 'info': {}},
'library': {'titles': {}}
})
movie_dict = m.to_dict(self.default_dict)
return jsonified({
'success': True,
+1 -1
View File
@@ -4,7 +4,7 @@ def start():
return Wizard()
config = [{
'name': 'global',
'name': 'core',
'groups': [
{
'tab': 'general',