Fixed MediaBase.getPoster(), switched MovieBase to use this generic method
This commit is contained in:
Regular → Executable
+6
-3
@@ -65,10 +65,13 @@ class MediaBase(Plugin):
|
|||||||
|
|
||||||
return def_title or 'UNKNOWN'
|
return def_title or 'UNKNOWN'
|
||||||
|
|
||||||
def getPoster(self, image_urls, existing_files):
|
def getPoster(self, media, image_urls):
|
||||||
image_type = 'poster'
|
if 'files' not in media:
|
||||||
|
media['files'] = {}
|
||||||
|
|
||||||
# Remove non-existing files
|
existing_files = media['files']
|
||||||
|
|
||||||
|
image_type = 'poster'
|
||||||
file_type = 'image_%s' % image_type
|
file_type = 'image_%s' % image_type
|
||||||
|
|
||||||
# Make existing unique
|
# Make existing unique
|
||||||
|
|||||||
Regular → Executable
+2
-28
@@ -312,37 +312,11 @@ class MovieBase(MovieTypeBase):
|
|||||||
media['title'] = def_title
|
media['title'] = def_title
|
||||||
|
|
||||||
# Files
|
# Files
|
||||||
images = info.get('images', [])
|
image_urls = info.get('images', [])
|
||||||
media['files'] = media.get('files', {})
|
|
||||||
for image_type in ['poster']:
|
|
||||||
|
|
||||||
# Remove non-existing files
|
self.getPoster(media, image_urls)
|
||||||
file_type = 'image_%s' % image_type
|
|
||||||
existing_files = list(set(media['files'].get(file_type, [])))
|
|
||||||
for ef in media['files'].get(file_type, []):
|
|
||||||
if not os.path.isfile(ef):
|
|
||||||
existing_files.remove(ef)
|
|
||||||
|
|
||||||
# Replace new files list
|
|
||||||
media['files'][file_type] = existing_files
|
|
||||||
if len(existing_files) == 0:
|
|
||||||
del media['files'][file_type]
|
|
||||||
|
|
||||||
# Loop over type
|
|
||||||
for image in images.get(image_type, []):
|
|
||||||
if not isinstance(image, (str, unicode)):
|
|
||||||
continue
|
|
||||||
|
|
||||||
if file_type not in media['files'] or len(media['files'].get(file_type, [])) == 0:
|
|
||||||
file_path = fireEvent('file.download', url = image, single = True)
|
|
||||||
if file_path:
|
|
||||||
media['files'][file_type] = [file_path]
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
|
|
||||||
db.update(media)
|
db.update(media)
|
||||||
|
|
||||||
return media
|
return media
|
||||||
except:
|
except:
|
||||||
log.error('Failed update media: %s', traceback.format_exc())
|
log.error('Failed update media: %s', traceback.format_exc())
|
||||||
|
|||||||
Reference in New Issue
Block a user