[35] catch asset errors

pull/858/head
meisnate12 3 years ago
parent 8e802cdeb7
commit e5a6ac99ba

@ -1 +1 @@
1.16.5-develop34
1.16.5-develop35

@ -2605,12 +2605,15 @@ class CollectionBuilder:
if "name_mapping" in self.details:
if self.details["name_mapping"]: name_mapping = self.details["name_mapping"]
else: logger.error(f"{self.Type} Error: name_mapping attribute is blank")
final_name, _ = util.validate_filename(name_mapping)
try:
poster_image, background_image, asset_location, _ = self.library.find_item_assets(name_mapping, asset_directory=self.asset_directory)
if poster_image:
self.posters["asset_directory"] = poster_image
if background_image:
self.backgrounds["asset_directory"] = background_image
except Failed as e:
if self.library.asset_folders and (self.library.show_missing_assets or self.library.create_asset_folders):
logger.error(e)
self.collection_poster = None
if len(self.posters) > 0:

@ -78,11 +78,12 @@ class Operations:
current_labels = [la.tag for la in item.labels] if self.library.assets_for_all or self.library.mass_imdb_parental_labels else []
if self.library.assets_for_all and "Overlay" not in current_labels:
try:
poster, background, item_dir, name = self.library.find_item_assets(item)
if item_dir:
if poster or background:
self.library.upload_images(item, poster=poster, background=background)
elif self.library.show_missing_assets:
logger.warning(f"Asset Warning: No poster or background found in the assets folder '{item_dir}'")
if isinstance(item, Show):
missing_seasons = ""
@ -120,11 +121,9 @@ class Operations:
self.library.upload_images(album, poster=album_poster, background=album_background)
if self.library.show_missing_season_assets and found_album and missing_assets:
logger.info(f"Missing Album Posters for {item.title}{missing_assets}")
elif self.library.asset_folders:
logger.warning(f"Asset Warning: No asset folder found called '{name}'")
elif not poster and not background and self.library.show_missing_assets:
logger.warning(f"Asset Warning: No poster or background found in the assets folder '{item_dir}'")
except Failed as e:
if self.library.show_missing_assets:
logger.warning(e)
tmdb_id, tvdb_id, imdb_id = self.library.get_ids(item)
@ -429,14 +428,14 @@ class Operations:
logger.separator(f"Unmanaged Collection Assets Check for {self.library.name} Library", space=False, border=False)
logger.info("")
for col in unmanaged_collections:
try:
poster, background, item_dir, name = self.library.find_item_assets(col)
if item_dir:
if poster or background:
self.library.upload_images(col, poster=poster, background=background)
if self.library.asset_folders and item_dir is None:
logger.warning(f"Asset Warning: No asset folder found called '{name}'")
elif not poster and not background and self.library.show_missing_assets:
elif self.library.show_missing_assets:
logger.warning(f"Asset Warning: No poster or background found in an assets folder for '{name}'")
except Failed as e:
logger.warning(e)
if self.library.mass_collection_mode:
logger.info("")

@ -78,6 +78,7 @@ class Overlays:
logger.ghost(f"Overlaying: {i}/{len(key_to_overlays)} {item.title}")
image_compare = None
overlay_compare = None
poster = None
if self.config.Cache:
image, image_compare, overlay_compare = self.config.Cache.query_image_map(item.ratingKey, f"{self.library.image_table_name}_overlays")
@ -93,7 +94,13 @@ class Overlays:
for over_name in over_names:
if over_name not in overlay_compare or properties[over_name]["updated"]:
overlay_change = True
poster, _, _, _ = self.library.find_item_assets(item)
try:
poster, _, item_dir, _ = self.library.find_item_assets(item)
if not poster and self.library.assets_for_all and self.library.show_missing_assets:
logger.warning(f"Asset Warning: No poster found in the assets folder '{item_dir}'")
except Failed as e:
if self.library.assets_for_all and self.library.show_missing_assets:
logger.warning(e)
has_original = None
changed_image = False
@ -277,7 +284,10 @@ class Overlays:
return items if not ignore else [o for o in items if o.ratingKey not in ignore]
def remove_overlay(self, item, label, locations):
try:
poster, _, _, _ = self.library.find_item_assets(item)
except Failed:
poster = None
is_url = False
original = None
if poster:

@ -815,7 +815,6 @@ class Plex(Library):
def find_item_assets(self, item, item_asset_directory=None, asset_directory=None):
poster = None
background = None
item_dir = None
folder_name = None
if asset_directory is None:
@ -869,11 +868,12 @@ class Plex(Library):
if item_asset_directory:
break
if not item_asset_directory:
extra = ""
if self.create_asset_folders and self.asset_folders:
item_asset_directory = os.path.join(asset_directory[0], folder_name)
os.makedirs(item_asset_directory, exist_ok=True)
logger.info(f"Asset Directory Created: {item_asset_directory}")
raise Failed(f"Asset Error: Unable to find asset {'folder' if self.asset_folders else 'file'}: {folder_name if self.asset_folders else file_name}")
extra = f"\nAsset Directory Created: {item_asset_directory}"
raise Failed(f"Asset Warning: Unable to find asset {'folder' if self.asset_folders else 'file'}: {folder_name if self.asset_folders else file_name}{extra}")
poster_filter = os.path.join(item_asset_directory, f"{file_name}.*")
background_filter = os.path.join(item_asset_directory, "background.*" if file_name == "poster" else f"{file_name}_background.*")
@ -906,7 +906,7 @@ class Plex(Library):
except OSError:
logger.error(f"Asset Error: Failed to open image: {file}")
return poster, background, item_dir, folder_name
return poster, background, item_asset_directory, folder_name
def get_ids(self, item):
tmdb_id = None

Loading…
Cancel
Save