JSON errors and image not loading
This commit is contained in:
+1
-1
@@ -33,7 +33,7 @@ class Loader(object):
|
||||
self.log = CPLog(__name__)
|
||||
|
||||
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.setFormatter(formatter)
|
||||
self.log.logger.addHandler(hdlr)
|
||||
|
||||
@@ -23,7 +23,7 @@ var NotificationBase = new Class({
|
||||
self.request = Api.request('core_notifier.listener', {
|
||||
'initialDelay': 100,
|
||||
'delay': 3000,
|
||||
'onComplete': self.processData.bind(self)
|
||||
'onSuccess': self.processData.bind(self)
|
||||
})
|
||||
|
||||
self.request.startTimer()
|
||||
|
||||
@@ -45,7 +45,8 @@ class FileManager(Plugin):
|
||||
self.createFile(dest, filedata, binary = True)
|
||||
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()
|
||||
|
||||
f = db.query(File).filter(File.path == toUnicode(path)).first()
|
||||
@@ -56,7 +57,7 @@ class FileManager(Plugin):
|
||||
f.path = toUnicode(path)
|
||||
f.part = part
|
||||
f.available = available
|
||||
f.type_id = self.getType(type).id
|
||||
f.type_id = type_id
|
||||
|
||||
db.commit()
|
||||
|
||||
@@ -64,23 +65,24 @@ class FileManager(Plugin):
|
||||
|
||||
return file_dict
|
||||
|
||||
def getType(self, type):
|
||||
def getType(self, type_tuple):
|
||||
|
||||
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:
|
||||
ft = FileType(
|
||||
type = toUnicode(type),
|
||||
identifier = identifier,
|
||||
name = toUnicode(identifier[0].capitalize() + identifier[1:])
|
||||
type = toUnicode(type_type),
|
||||
identifier = type_identifier,
|
||||
name = toUnicode(type_identifier[0].capitalize() + type_identifier[1:])
|
||||
)
|
||||
|
||||
db.add(ft)
|
||||
db.commit()
|
||||
|
||||
return ft
|
||||
type_dict = ft.to_dict()
|
||||
db.remove()
|
||||
return type_dict
|
||||
|
||||
def getTypes(self):
|
||||
|
||||
@@ -89,7 +91,7 @@ class FileManager(Plugin):
|
||||
results = db.query(FileType).all()
|
||||
|
||||
types = []
|
||||
for type in results:
|
||||
types.append(type.to_dict())
|
||||
for type_object in results:
|
||||
types.append(type_object.to_dict())
|
||||
|
||||
return types
|
||||
|
||||
@@ -102,7 +102,7 @@ class LibraryPlugin(Plugin):
|
||||
continue
|
||||
|
||||
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:
|
||||
file_obj = db.query(File).filter_by(id = file_obj.get('id')).one()
|
||||
library.files.append(file_obj)
|
||||
|
||||
@@ -183,7 +183,7 @@ Block.Search.Item = new Class({
|
||||
'click': self.showOptions.bind(self)
|
||||
}
|
||||
}).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]
|
||||
}) : null,
|
||||
new Element('div.info').adopt(
|
||||
@@ -288,7 +288,7 @@ Block.Search.Item = new Class({
|
||||
|
||||
self.options.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]
|
||||
}) : null,
|
||||
self.info.in_wanted ? new Element('span.in_wanted', {
|
||||
|
||||
@@ -79,7 +79,7 @@ class Release(Plugin):
|
||||
properties = {}
|
||||
|
||||
# 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):
|
||||
|
||||
|
||||
@@ -33,8 +33,9 @@ class IMDBAPI(MovieProvider):
|
||||
if cached:
|
||||
result = self.parseMovie(cached)
|
||||
log.info('Found: %s' % result['titles'][0] + ' (' + str(result['year']) + ')')
|
||||
return [result]
|
||||
|
||||
return [result]
|
||||
return []
|
||||
|
||||
def getInfo(self, identifier = None):
|
||||
|
||||
@@ -44,8 +45,9 @@ class IMDBAPI(MovieProvider):
|
||||
if cached:
|
||||
result = self.parseMovie(cached)
|
||||
log.info('Found: %s' % result['titles'][0] + ' (' + str(result['year']) + ')')
|
||||
return result
|
||||
|
||||
return result
|
||||
return {}
|
||||
|
||||
def parseMovie(self, movie):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user