Download fanart en bigger poster when needed

This commit is contained in:
Ruud
2012-09-16 19:25:53 +02:00
parent 4be8d02cbb
commit ef7fc62c66
2 changed files with 15 additions and 4 deletions

View File

@@ -111,18 +111,20 @@ class LibraryPlugin(Plugin):
# Files
images = info.get('images', [])
for type in images:
for image in images[type]:
if not isinstance(image, str):
for image_type in ['poster']:
for image in images.get(image_type, []):
if not isinstance(image, (str, unicode)):
continue
file_path = fireEvent('file.download', url = image, single = True)
if file_path:
file_obj = fireEvent('file.add', path = file_path, type_tuple = ('image', type), single = True)
file_obj = fireEvent('file.add', path = file_path, type_tuple = ('image', image_type), single = True)
try:
file_obj = db.query(File).filter_by(id = file_obj.get('id')).one()
library.files.append(file_obj)
db.commit()
break
except:
log.debug('Failed to attach to library: %s', traceback.format_exc())

View File

@@ -74,9 +74,18 @@ class MetaDataBase(Plugin):
if file_type.get('identifier') == wanted_file_type:
break
# See if it is in current files
for cur_file in data['library'].get('files', []):
if cur_file.get('type_id') is file_type.get('id') and os.path.isfile(cur_file.get('path')):
return cur_file.get('path')
# Download using existing info
try:
images = data['library']['info']['images'][wanted_file_type]
file_path = fireEvent('file.download', url = images[0], single = True)
return file_path
except:
pass
def getFanart(self, movie_info = {}, data = {}):
return self.getThumbnail(movie_info = movie_info, data = data, wanted_file_type = 'backdrop_original')