[94] #701 add url_theme and file_theme

pull/752/head
meisnate12 3 years ago
parent b4ba3dd06c
commit 457c52af2e

@ -1 +1 @@
1.15.1-develop93 1.15.1-develop94

@ -97,7 +97,7 @@ ignored_details = [
"delete_not_scheduled", "tmdb_person", "build_collection", "collection_order", "collection_level", "delete_not_scheduled", "tmdb_person", "build_collection", "collection_order", "collection_level",
"validate_builders", "libraries", "sync_to_users", "collection_name", "playlist_name", "name", "blank_collection" "validate_builders", "libraries", "sync_to_users", "collection_name", "playlist_name", "name", "blank_collection"
] ]
details = ["ignore_ids", "ignore_imdb_ids", "server_preroll", "changes_webhooks", "collection_mode", "limit", details = ["ignore_ids", "ignore_imdb_ids", "server_preroll", "changes_webhooks", "collection_mode", "limit", "url_theme", "file_theme"
"minimum_items", "label", "album_sorting", "cache_builders"] + boolean_details + scheduled_boolean + string_details "minimum_items", "label", "album_sorting", "cache_builders"] + boolean_details + scheduled_boolean + string_details
collectionless_details = ["collection_order", "plex_collectionless", "label", "label_sync_mode", "test"] + \ collectionless_details = ["collection_order", "plex_collectionless", "label", "label_sync_mode", "test"] + \
poster_details + background_details + summary_details + string_details poster_details + background_details + summary_details + string_details
@ -183,7 +183,8 @@ episode_parts_only = ["plex_pilots"]
parts_collection_valid = [ parts_collection_valid = [
"filters", "plex_all", "plex_search", "trakt_list", "trakt_list_details", "collection_mode", "label", "visible_library", "limit", "filters", "plex_all", "plex_search", "trakt_list", "trakt_list_details", "collection_mode", "label", "visible_library", "limit",
"visible_home", "visible_shared", "show_missing", "save_missing", "missing_only_released", "server_preroll", "changes_webhooks", "visible_home", "visible_shared", "show_missing", "save_missing", "missing_only_released", "server_preroll", "changes_webhooks",
"item_lock_background", "item_lock_poster", "item_lock_title", "item_refresh", "item_refresh_delay", "imdb_list", "cache_builders" "item_lock_background", "item_lock_poster", "item_lock_title", "item_refresh", "item_refresh_delay", "imdb_list", "cache_builders",
"url_theme", "file_theme"
] + episode_parts_only + summary_details + poster_details + background_details + string_details ] + episode_parts_only + summary_details + poster_details + background_details + string_details
playlist_attributes = [ playlist_attributes = [
"filters", "name_mapping", "show_filtered", "show_missing", "save_missing", "filters", "name_mapping", "show_filtered", "show_missing", "save_missing",
@ -766,6 +767,13 @@ class CollectionBuilder:
logger.error(f"{self.Type} Error: Background Path Does Not Exist: {os.path.abspath(method_data)}") logger.error(f"{self.Type} Error: Background Path Does Not Exist: {os.path.abspath(method_data)}")
def _details(self, method_name, method_data, method_final, methods): def _details(self, method_name, method_data, method_final, methods):
if method_name == "url_theme":
self.url_theme = method_data
elif method_name == "file_theme":
if os.path.exists(os.path.abspath(method_data)):
self.file_theme = os.path.abspath(method_data)
else:
logger.error(f"{self.Type} Error: Theme Path Does Not Exist: {os.path.abspath(method_data)}")
if method_name == "collection_mode": if method_name == "collection_mode":
self.details[method_name] = util.check_collection_mode(method_data) self.details[method_name] = util.check_collection_mode(method_data)
elif method_name == "minimum_items": elif method_name == "minimum_items":
@ -2393,7 +2401,6 @@ class CollectionBuilder:
sync_tags = self.details["label.sync"] if "label.sync" in self.details else None sync_tags = self.details["label.sync"] if "label.sync" in self.details else None
self.library.edit_tags("label", self.obj, add_tags=add_tags, remove_tags=remove_tags, sync_tags=sync_tags) self.library.edit_tags("label", self.obj, add_tags=add_tags, remove_tags=remove_tags, sync_tags=sync_tags)
poster_image = None poster_image = None
background_image = None background_image = None
asset_location = None asset_location = None
@ -2487,6 +2494,11 @@ class CollectionBuilder:
if self.collection_poster or self.collection_background: if self.collection_poster or self.collection_background:
self.library.upload_images(self.obj, poster=self.collection_poster, background=self.collection_background) self.library.upload_images(self.obj, poster=self.collection_poster, background=self.collection_background)
if self.url_theme:
self.library.upload_theme(url=self.url_theme)
elif self.file_theme:
self.library.upload_theme(filepath=self.file_theme)
def sort_collection(self): def sort_collection(self):
logger.info("") logger.info("")
logger.separator(f"Sorting {self.name} {self.Type}", space=False, border=False) logger.separator(f"Sorting {self.name} {self.Type}", space=False, border=False)

@ -476,6 +476,13 @@ class Plex(Library):
self._all_items = results self._all_items = results
return results return results
def upload_theme(self, collection, url=None, filepath=None):
key = f"/library/metadata/{collection.ratingKey}/themes"
if url:
self.PlexServer.query(f"{key}?url={parse.quote_plus(url)}", method=self.PlexServer._session.post)
elif filepath:
self.PlexServer.query(key, method=self.PlexServer._session.post, data=open(filepath, 'rb').read())
@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex) @retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex)
def create_playlist(self, name, items): def create_playlist(self, name, items):
return self.PlexServer.createPlaylist(name, items=items) return self.PlexServer.createPlaylist(name, items=items)

Loading…
Cancel
Save