JSON errors and image not loading
This commit is contained in:
1 parent
0fe18b0109
commit
af92355e2f
7 files changed
+24
-20
No files matched your search
+1
-1
@@ -33,7 +33,7 @@ class Loader(object):
|
|||||||
self.log = CPLog(__name__)
|
self.log = CPLog(__name__)
|
||||||
|
|
||||||
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s', '%H:%M:%S')
|
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s', '%H:%M:%S')
|
||||||
hdlr = handlers.RotatingFileHandler(os.path.join(self.data_dir, 'logs', 'error.log'), 'a', 500000, 10)
|
hdlr = handlers.RotatingFileHandler(os.path.join(self.data_dir, 'error.log'), 'a', 500000, 10)
|
||||||
hdlr.setLevel(logging.CRITICAL)
|
hdlr.setLevel(logging.CRITICAL)
|
||||||
hdlr.setFormatter(formatter)
|
hdlr.setFormatter(formatter)
|
||||||
self.log.logger.addHandler(hdlr)
|
self.log.logger.addHandler(hdlr)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ var NotificationBase = new Class({
|
|||||||
self.request = Api.request('core_notifier.listener', {
|
self.request = Api.request('core_notifier.listener', {
|
||||||
'initialDelay': 100,
|
'initialDelay': 100,
|
||||||
'delay': 3000,
|
'delay': 3000,
|
||||||
'onComplete': self.processData.bind(self)
|
'onSuccess': self.processData.bind(self)
|
||||||
})
|
})
|
||||||
|
|
||||||
self.request.startTimer()
|
self.request.startTimer()
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ class FileManager(Plugin):
|
|||||||
self.createFile(dest, filedata, binary = True)
|
self.createFile(dest, filedata, binary = True)
|
||||||
return dest
|
return dest
|
||||||
|
|
||||||
def add(self, path = '', part = 1, type = (), available = 1, properties = {}):
|
def add(self, path = '', part = 1, type_tuple = (), available = 1, properties = {}):
|
||||||
|
type_id = self.getType(type_tuple).get('id')
|
||||||
db = get_session()
|
db = get_session()
|
||||||
|
|
||||||
f = db.query(File).filter(File.path == toUnicode(path)).first()
|
f = db.query(File).filter(File.path == toUnicode(path)).first()
|
||||||
@@ -56,7 +57,7 @@ class FileManager(Plugin):
|
|||||||
f.path = toUnicode(path)
|
f.path = toUnicode(path)
|
||||||
f.part = part
|
f.part = part
|
||||||
f.available = available
|
f.available = available
|
||||||
f.type_id = self.getType(type).id
|
f.type_id = type_id
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
@@ -64,23 +65,24 @@ class FileManager(Plugin):
|
|||||||
|
|
||||||
return file_dict
|
return file_dict
|
||||||
|
|
||||||
def getType(self, type):
|
def getType(self, type_tuple):
|
||||||
|
|
||||||
db = get_session()
|
db = get_session()
|
||||||
type, identifier = type
|
type_type, type_identifier = type_tuple
|
||||||
|
|
||||||
ft = db.query(FileType).filter_by(identifier = identifier).first()
|
ft = db.query(FileType).filter_by(identifier = type_identifier).first()
|
||||||
if not ft:
|
if not ft:
|
||||||
ft = FileType(
|
ft = FileType(
|
||||||
type = toUnicode(type),
|
type = toUnicode(type_type),
|
||||||
identifier = identifier,
|
identifier = type_identifier,
|
||||||
name = toUnicode(identifier[0].capitalize() + identifier[1:])
|
name = toUnicode(type_identifier[0].capitalize() + type_identifier[1:])
|
||||||
)
|
)
|
||||||
|
|
||||||
db.add(ft)
|
db.add(ft)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
return ft
|
type_dict = ft.to_dict()
|
||||||
|
db.remove()
|
||||||
|
return type_dict
|
||||||
|
|
||||||
def getTypes(self):
|
def getTypes(self):
|
||||||
|
|
||||||
@@ -89,7 +91,7 @@ class FileManager(Plugin):
|
|||||||
results = db.query(FileType).all()
|
results = db.query(FileType).all()
|
||||||
|
|
||||||
types = []
|
types = []
|
||||||
for type in results:
|
for type_object in results:
|
||||||
types.append(type.to_dict())
|
types.append(type_object.to_dict())
|
||||||
|
|
||||||
return types
|
return types
|
||||||
@@ -102,7 +102,7 @@ class LibraryPlugin(Plugin):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
file_path = fireEvent('file.download', url = image, single = True)
|
file_path = fireEvent('file.download', url = image, single = True)
|
||||||
file_obj = fireEvent('file.add', path = file_path, type = ('image', type), single = True)
|
file_obj = fireEvent('file.add', path = file_path, type_tuple = ('image', type), single = True)
|
||||||
try:
|
try:
|
||||||
file_obj = db.query(File).filter_by(id = file_obj.get('id')).one()
|
file_obj = db.query(File).filter_by(id = file_obj.get('id')).one()
|
||||||
library.files.append(file_obj)
|
library.files.append(file_obj)
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ Block.Search.Item = new Class({
|
|||||||
'click': self.showOptions.bind(self)
|
'click': self.showOptions.bind(self)
|
||||||
}
|
}
|
||||||
}).adopt(
|
}).adopt(
|
||||||
self.thumbnail = info.images.poster.length > 0 ? new Element('img.thumbnail', {
|
self.thumbnail = info.images && info.images.poster.length > 0 ? new Element('img.thumbnail', {
|
||||||
'src': info.images.poster[0]
|
'src': info.images.poster[0]
|
||||||
}) : null,
|
}) : null,
|
||||||
new Element('div.info').adopt(
|
new Element('div.info').adopt(
|
||||||
@@ -288,7 +288,7 @@ Block.Search.Item = new Class({
|
|||||||
|
|
||||||
self.options.adopt(
|
self.options.adopt(
|
||||||
new Element('div').adopt(
|
new Element('div').adopt(
|
||||||
self.info.images.poster.length > 0 ? new Element('img.thumbnail', {
|
self.info.images && self.info.images.poster.length > 0 ? new Element('img.thumbnail', {
|
||||||
'src': self.info.images.poster[0]
|
'src': self.info.images.poster[0]
|
||||||
}) : null,
|
}) : null,
|
||||||
self.info.in_wanted ? new Element('span.in_wanted', {
|
self.info.in_wanted ? new Element('span.in_wanted', {
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class Release(Plugin):
|
|||||||
properties = {}
|
properties = {}
|
||||||
|
|
||||||
# Check database and update/insert if necessary
|
# Check database and update/insert if necessary
|
||||||
return fireEvent('file.add', path = filepath, part = fireEvent('scanner.partnumber', file, single = True), type = Scanner.file_types.get(type), properties = properties, single = True)
|
return fireEvent('file.add', path = filepath, part = fireEvent('scanner.partnumber', file, single = True), type_tuple = Scanner.file_types.get(type), properties = properties, single = True)
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,9 @@ class IMDBAPI(MovieProvider):
|
|||||||
if cached:
|
if cached:
|
||||||
result = self.parseMovie(cached)
|
result = self.parseMovie(cached)
|
||||||
log.info('Found: %s' % result['titles'][0] + ' (' + str(result['year']) + ')')
|
log.info('Found: %s' % result['titles'][0] + ' (' + str(result['year']) + ')')
|
||||||
|
return [result]
|
||||||
|
|
||||||
return [result]
|
return []
|
||||||
|
|
||||||
def getInfo(self, identifier = None):
|
def getInfo(self, identifier = None):
|
||||||
|
|
||||||
@@ -44,8 +45,9 @@ class IMDBAPI(MovieProvider):
|
|||||||
if cached:
|
if cached:
|
||||||
result = self.parseMovie(cached)
|
result = self.parseMovie(cached)
|
||||||
log.info('Found: %s' % result['titles'][0] + ' (' + str(result['year']) + ')')
|
log.info('Found: %s' % result['titles'][0] + ' (' + str(result['year']) + ')')
|
||||||
|
return result
|
||||||
|
|
||||||
return result
|
return {}
|
||||||
|
|
||||||
def parseMovie(self, movie):
|
def parseMovie(self, movie):
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user