JSON errors and image not loading

This commit is contained in:
Ruud
2012-02-16 00:01:43 +01:00
parent 0fe18b0109
commit af92355e2f
7 changed files with 24 additions and 20 deletions
+14 -12
View File
@@ -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
+1 -1
View File
@@ -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', {
+1 -1
View File
@@ -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):