asset_folders and create_asset_folders can be set at the collection level

pull/528/head
meisnate12 3 years ago
parent f3357aadba
commit df24853936

@ -78,7 +78,10 @@ summary_details = [
]
poster_details = ["url_poster", "tmdb_poster", "tmdb_profile", "tvdb_poster", "file_poster"]
background_details = ["url_background", "tmdb_background", "tvdb_background", "file_background"]
boolean_details = ["show_filtered", "show_missing", "save_missing", "missing_only_released", "only_filter_missing", "delete_below_minimum"]
boolean_details = [
"show_filtered", "show_missing", "save_missing", "missing_only_released", "only_filter_missing",
"delete_below_minimum", "asset_folders", "create_asset_folders"
]
scheduled_boolean = ["visible_library", "visible_home", "visible_shared"]
string_details = ["sort_title", "content_rating", "name_mapping"]
ignored_details = [
@ -187,6 +190,7 @@ class CollectionBuilder:
"save_missing": self.library.save_missing,
"missing_only_released": self.library.missing_only_released,
"only_filter_missing": self.library.only_filter_missing,
"asset_folders": self.library.asset_folders,
"create_asset_folders": self.library.create_asset_folders,
"delete_below_minimum": self.library.delete_below_minimum,
"delete_not_scheduled": self.library.delete_not_scheduled,
@ -2003,7 +2007,7 @@ class CollectionBuilder:
rating_keys.remove(int(item.ratingKey))
if "item_assets" in self.item_details or overlay is not None:
try:
self.library.find_assets(item, overlay=overlay)
self.library.find_assets(item, overlay=overlay, folders=self.details["asset_folders"], create=self.details["create_asset_folders"])
except Failed as e:
logger.error(e)
self.library.edit_tags("label", item, add_tags=add_tags, remove_tags=remove_tags, sync_tags=sync_tags)
@ -2189,7 +2193,7 @@ 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")
poster_image, background_image = self.library.find_assets(self.obj, name=name_mapping, upload=False)
poster_image, background_image = self.library.find_assets(self.obj, name=name_mapping, upload=False, folders=self.details["asset_folders"], create=self.details["create_asset_folders"])
if poster_image:
self.posters["asset_directory"] = poster_image
if background_image:

@ -645,7 +645,7 @@ class Plex(Library):
logger.info(f"{obj.title[:25]:<25} | {attr.capitalize()} | {display}")
return len(display) > 0
def find_assets(self, item, name=None, upload=True, overlay=None):
def find_assets(self, item, name=None, upload=True, overlay=None, folders=None, create=None):
if isinstance(item, Movie):
name = os.path.basename(os.path.dirname(str(item.locations[0])))
elif isinstance(item, Show):
@ -654,12 +654,16 @@ class Plex(Library):
name = name if name else item.title
else:
return None, None
if not folders:
folders = self.asset_folders
if not create:
create = self.create_asset_folders
found_folder = False
poster = None
background = None
for ad in self.asset_directory:
item_dir = None
if self.asset_folders:
if folders:
if os.path.isdir(os.path.join(ad, name)):
item_dir = os.path.join(ad, name)
else:
@ -746,11 +750,11 @@ class Plex(Library):
if self.show_missing_season_assets and found_season and missing_assets:
util.print_multiline(f"Missing Season Posters for {item.title}{missing_assets}", info=True)
if isinstance(item, (Movie, Show)) and not poster and overlay:
self.upload_images(item, overlay=name)
if self.create_asset_folders and self.asset_folders and not found_folder:
self.upload_images(item, overlay=overlay)
if create and folders and not found_folder:
os.makedirs(os.path.join(self.asset_directory[0], name), exist_ok=True)
logger.info(f"Asset Directory Created: {os.path.join(self.asset_directory[0], name)}")
elif isinstance(item, (Movie, Show)) and not overlay and self.asset_folders and not found_folder:
elif isinstance(item, (Movie, Show)) and not overlay and folders and not found_folder:
logger.error(f"Asset Warning: No asset folder found called '{name}'")
elif isinstance(item, (Movie, Show)) and not poster and not background and self.show_missing_assets:
logger.error(f"Asset Warning: No poster or background found in an assets folder for '{name}'")

Loading…
Cancel
Save