#296 Let user know when the assets folder is missing

pull/309/head
meisnate12 4 years ago
parent f70d868261
commit 03ef602f58

@ -1685,8 +1685,7 @@ class CollectionBuilder:
if int(item.ratingKey) in rating_keys: if int(item.ratingKey) in rating_keys:
rating_keys.remove(int(item.ratingKey)) rating_keys.remove(int(item.ratingKey))
if self.details["item_assets"]: if self.details["item_assets"]:
poster, background = self.library.update_item_from_assets(item) self.library.update_item_from_assets(item, overlay=overlay)
self.library.upload_images(item, poster=poster, background=background, overlay=overlay)
self.library.edit_tags("label", item, add_tags=add_tags, remove_tags=remove_tags, sync_tags=sync_tags) self.library.edit_tags("label", item, add_tags=add_tags, remove_tags=remove_tags, sync_tags=sync_tags)
advance_edits = {} advance_edits = {}
for method_name, method_data in self.item_details.items(): for method_name, method_data in self.item_details.items():
@ -1818,48 +1817,50 @@ class CollectionBuilder:
if background_image: if background_image:
self.backgrounds["asset_directory"] = background_image self.backgrounds["asset_directory"] = background_image
poster = None
if len(self.posters) > 1: if len(self.posters) > 1:
logger.info(f"{len(self.posters)} posters found:") logger.info(f"{len(self.posters)} posters found:")
for p in self.posters: for p in self.posters:
logger.info(f"Method: {p} Poster: {self.posters[p]}") logger.info(f"Method: {p} Poster: {self.posters[p]}")
if "url_poster" in self.posters: poster = ImageData("url_poster", self.posters["url_poster"])
elif "file_poster" in self.posters: poster = ImageData("file_poster", self.posters["file_poster"], is_url=False)
elif "tmdb_poster" in self.posters: poster = ImageData("tmdb_poster", self.posters["tmdb_poster"])
elif "tmdb_profile" in self.posters: poster = ImageData("tmdb_poster", self.posters["tmdb_profile"])
elif "tvdb_poster" in self.posters: poster = ImageData("tvdb_poster", self.posters["tvdb_poster"])
elif "asset_directory" in self.posters: poster = self.posters["asset_directory"]
elif "tmdb_person" in self.posters: poster = ImageData("tmdb_person", self.posters["tmdb_person"])
elif "tmdb_collection_details" in self.posters: poster = ImageData("tmdb_collection_details", self.posters["tmdb_collection_details"])
elif "tmdb_actor_details" in self.posters: poster = ImageData("tmdb_actor_details", self.posters["tmdb_actor_details"])
elif "tmdb_crew_details" in self.posters: poster = ImageData("tmdb_crew_details", self.posters["tmdb_crew_details"])
elif "tmdb_director_details" in self.posters: poster = ImageData("tmdb_director_details", self.posters["tmdb_director_details"])
elif "tmdb_producer_details" in self.posters: poster = ImageData("tmdb_producer_details", self.posters["tmdb_producer_details"])
elif "tmdb_writer_details" in self.posters: poster = ImageData("tmdb_writer_details", self.posters["tmdb_writer_details"])
elif "tmdb_movie_details" in self.posters: poster = ImageData("tmdb_movie_details", self.posters["tmdb_movie_details"])
elif "tvdb_movie_details" in self.posters: poster = ImageData("tvdb_movie_details", self.posters["tvdb_movie_details"])
elif "tvdb_show_details" in self.posters: poster = ImageData("tvdb_show_details", self.posters["tvdb_show_details"])
elif "tmdb_show_details" in self.posters: poster = ImageData("tmdb_show_details", self.posters["tmdb_show_details"])
else:
logger.info("No poster collection detail or asset folder found")
background = None
if len(self.backgrounds) > 1: if len(self.backgrounds) > 1:
logger.info(f"{len(self.backgrounds)} backgrounds found:") logger.info(f"{len(self.backgrounds)} backgrounds found:")
for b in self.backgrounds: for b in self.backgrounds:
logger.info(f"Method: {b} Background: {self.backgrounds[b]}") logger.info(f"Method: {b} Background: {self.backgrounds[b]}")
poster = None if "url_background" in self.backgrounds: background = ImageData("url_background", self.backgrounds["url_background"], is_poster=False)
if "url_poster" in self.posters: poster = ImageData("url_poster", self.posters["url_poster"]) elif "file_background" in self.backgrounds: background = ImageData("file_background", self.backgrounds["file_background"], is_poster=False, is_url=False)
elif "file_poster" in self.posters: poster = ImageData("file_poster", self.posters["file_poster"], is_url=False) elif "tmdb_background" in self.backgrounds: background = ImageData("tmdb_background", self.backgrounds["tmdb_background"], is_poster=False)
elif "tmdb_poster" in self.posters: poster = ImageData("tmdb_poster", self.posters["tmdb_poster"]) elif "tvdb_background" in self.backgrounds: background = ImageData("tvdb_background", self.backgrounds["tvdb_background"], is_poster=False)
elif "tmdb_profile" in self.posters: poster = ImageData("tmdb_poster", self.posters["tmdb_profile"]) elif "asset_directory" in self.backgrounds: background = self.backgrounds["asset_directory"]
elif "tvdb_poster" in self.posters: poster = ImageData("tvdb_poster", self.posters["tvdb_poster"]) elif "tmdb_collection_details" in self.backgrounds: background = ImageData("tmdb_collection_details", self.backgrounds["tmdb_collection_details"], is_poster=False)
elif "asset_directory" in self.posters: poster = self.posters["asset_directory"] elif "tmdb_movie_details" in self.backgrounds: background = ImageData("tmdb_movie_details", self.backgrounds["tmdb_movie_details"], is_poster=False)
elif "tmdb_person" in self.posters: poster = ImageData("tmdb_person", self.posters["tmdb_person"]) elif "tvdb_movie_details" in self.backgrounds: background = ImageData("tvdb_movie_details", self.backgrounds["tvdb_movie_details"], is_poster=False)
elif "tmdb_collection_details" in self.posters: poster = ImageData("tmdb_collection_details", self.posters["tmdb_collection_details"]) elif "tvdb_show_details" in self.backgrounds: background = ImageData("tvdb_show_details", self.backgrounds["tvdb_show_details"], is_poster=False)
elif "tmdb_actor_details" in self.posters: poster = ImageData("tmdb_actor_details", self.posters["tmdb_actor_details"]) elif "tmdb_show_details" in self.backgrounds: background = ImageData("tmdb_show_details", self.backgrounds["tmdb_show_details"], is_poster=False)
elif "tmdb_crew_details" in self.posters: poster = ImageData("tmdb_crew_details", self.posters["tmdb_crew_details"]) else:
elif "tmdb_director_details" in self.posters: poster = ImageData("tmdb_director_details", self.posters["tmdb_director_details"]) logger.info("No background collection detail or asset folder found")
elif "tmdb_producer_details" in self.posters: poster = ImageData("tmdb_producer_details", self.posters["tmdb_producer_details"])
elif "tmdb_writer_details" in self.posters: poster = ImageData("tmdb_writer_details", self.posters["tmdb_writer_details"])
elif "tmdb_movie_details" in self.posters: poster = ImageData("tmdb_movie_details", self.posters["tmdb_movie_details"])
elif "tvdb_movie_details" in self.posters: poster = ImageData("tvdb_movie_details", self.posters["tvdb_movie_details"])
elif "tvdb_show_details" in self.posters: poster = ImageData("tvdb_show_details", self.posters["tvdb_show_details"])
elif "tmdb_show_details" in self.posters: poster = ImageData("tmdb_show_details", self.posters["tmdb_show_details"])
else: logger.info("No poster to update")
background = None
if "url_background" in self.backgrounds: background = ImageData("url_background", self.backgrounds["url_background"], is_poster=False)
elif "file_background" in self.backgrounds: background = ImageData("file_background", self.backgrounds["file_background"], is_poster=False, is_url=False)
elif "tmdb_background" in self.backgrounds: background = ImageData("tmdb_background", self.backgrounds["tmdb_background"], is_poster=False)
elif "tvdb_background" in self.backgrounds: background = ImageData("tvdb_background", self.backgrounds["tvdb_background"], is_poster=False)
elif "asset_directory" in self.backgrounds: background = self.backgrounds["asset_directory"]
elif "tmdb_collection_details" in self.backgrounds: background = ImageData("tmdb_collection_details", self.backgrounds["tmdb_collection_details"], is_poster=False)
elif "tmdb_movie_details" in self.backgrounds: background = ImageData("tmdb_movie_details", self.backgrounds["tmdb_movie_details"], is_poster=False)
elif "tvdb_movie_details" in self.backgrounds: background = ImageData("tvdb_movie_details", self.backgrounds["tvdb_movie_details"], is_poster=False)
elif "tvdb_show_details" in self.backgrounds: background = ImageData("tvdb_show_details", self.backgrounds["tvdb_show_details"], is_poster=False)
elif "tmdb_show_details" in self.backgrounds: background = ImageData("tmdb_show_details", self.backgrounds["tmdb_show_details"], is_poster=False)
else: logger.info("No background to update")
if poster or background: if poster or background:
self.library.upload_images(self.obj, poster=poster, background=background) self.library.upload_images(self.obj, poster=poster, background=background)

@ -17,7 +17,7 @@ class Metadata:
logger.info("") logger.info("")
logger.info(f"Loading Metadata {file_type}: {path}") logger.info(f"Loading Metadata {file_type}: {path}")
def get_dict(attribute, attr_data, check_list=None): def get_dict(attribute, attr_data, check_list=None):
if attribute in attr_data: if attr_data and attribute in attr_data:
if attr_data[attribute]: if attr_data[attribute]:
if isinstance(attr_data[attribute], dict): if isinstance(attr_data[attribute], dict):
if check_list: if check_list:

@ -764,8 +764,9 @@ class Plex:
logger.info(f"Detail: {attr.capitalize()} {remove} removed") logger.info(f"Detail: {attr.capitalize()} {remove} removed")
return updated return updated
def update_item_from_assets(self, item): def update_item_from_assets(self, item, overlay=None):
name = os.path.basename(os.path.dirname(item.locations[0]) if self.is_movie else item.locations[0]) name = os.path.basename(os.path.dirname(item.locations[0]) if self.is_movie else item.locations[0])
found_one = False
for ad in self.asset_directory: for ad in self.asset_directory:
poster = None poster = None
background = None background = None
@ -779,6 +780,7 @@ class Plex:
item_dir = os.path.abspath(matches[0]) item_dir = os.path.abspath(matches[0])
if item_dir is None: if item_dir is None:
continue continue
found_one = True
poster_filter = os.path.join(item_dir, "poster.*") poster_filter = os.path.join(item_dir, "poster.*")
background_filter = os.path.join(item_dir, "background.*") background_filter = os.path.join(item_dir, "background.*")
else: else:
@ -790,6 +792,8 @@ class Plex:
matches = glob.glob(background_filter) matches = glob.glob(background_filter)
if len(matches) > 0: if len(matches) > 0:
background = ImageData("asset_directory", os.path.abspath(matches[0]), prefix=f"{item.title}'s ", is_poster=False, is_url=False) background = ImageData("asset_directory", os.path.abspath(matches[0]), prefix=f"{item.title}'s ", is_poster=False, is_url=False)
if poster or background:
self.upload_images(item, poster=poster, background=background, overlay=overlay)
if self.is_show: if self.is_show:
for season in self.query(item.seasons): for season in self.query(item.seasons):
if item_dir: if item_dir:
@ -809,9 +813,8 @@ class Plex:
if len(matches) > 0: if len(matches) > 0:
episode_poster = ImageData("asset_directory", os.path.abspath(matches[0]), prefix=f"{item.title} {episode.seasonEpisode.upper()}'s ", is_url=False) episode_poster = ImageData("asset_directory", os.path.abspath(matches[0]), prefix=f"{item.title} {episode.seasonEpisode.upper()}'s ", is_url=False)
self.upload_images(episode, poster=episode_poster) self.upload_images(episode, poster=episode_poster)
if poster or background: if not found_one:
return poster, background logger.error(f"Asset Warning: No asset folder found called '{name}'")
return None, None
def find_collection_assets(self, item, name=None): def find_collection_assets(self, item, name=None):
if name is None: if name is None:

@ -192,8 +192,7 @@ def update_libraries(config):
poster, background = library.find_collection_assets(col) poster, background = library.find_collection_assets(col)
library.upload_images(col, poster=poster, background=background) library.upload_images(col, poster=poster, background=background)
for item in library.get_all(): for item in library.get_all():
poster, background = library.update_item_from_assets(item) library.update_item_from_assets(item)
library.upload_images(item, poster=poster, background=background)
logger.removeHandler(library_handler) logger.removeHandler(library_handler)

Loading…
Cancel
Save