mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-22 20:43:07 +00:00
#232 genre_mapper library operation
This commit is contained in:
parent
f8e51c361c
commit
d38f9df168
3 changed files with 24 additions and 4 deletions
|
@ -456,6 +456,7 @@ class Config:
|
|||
params["radarr_add_all"] = check_for_attribute(lib, "radarr_add_all", var_type="bool", default=False, save=False, do_print=False)
|
||||
params["sonarr_add_all"] = check_for_attribute(lib, "sonarr_add_all", var_type="bool", default=False, save=False, do_print=False)
|
||||
params["tmdb_collections"] = None
|
||||
params["genre_mapper"] = None
|
||||
|
||||
if lib and "operations" in lib and lib["operations"]:
|
||||
if isinstance(lib["operations"], dict):
|
||||
|
@ -490,6 +491,14 @@ class Config:
|
|||
logger.warning("Config Warning: Using default template for tmdb_collections")
|
||||
else:
|
||||
logger.error("Config Error: tmdb_collections blank using default settings")
|
||||
if "genre_mapper" in lib["operations"]:
|
||||
if lib["operations"]["genre_mapper"] and isinstance(lib["operations"]["genre_mapper"], dict):
|
||||
params["genre_mapper"] = {}
|
||||
for new_genre, old_genres in lib["operations"]["genre_mapper"].items():
|
||||
for old_genre in util.get_list(old_genres, split=False):
|
||||
params["genre_mapper"][old_genre] = new_genre
|
||||
else:
|
||||
logger.error("Config Error: genre_mapper is blank")
|
||||
else:
|
||||
logger.error("Config Error: operations must be a dictionary")
|
||||
|
||||
|
|
|
@ -59,9 +59,10 @@ class Library(ABC):
|
|||
self.mass_audience_rating_update = params["mass_audience_rating_update"]
|
||||
self.mass_critic_rating_update = params["mass_critic_rating_update"]
|
||||
self.mass_trakt_rating_update = params["mass_trakt_rating_update"]
|
||||
self.tmdb_collections = params["tmdb_collections"]
|
||||
self.radarr_add_all = params["radarr_add_all"]
|
||||
self.sonarr_add_all = params["sonarr_add_all"]
|
||||
self.tmdb_collections = params["tmdb_collections"]
|
||||
self.genre_mapper = params["genre_mapper"]
|
||||
self.error_webhooks = params["error_webhooks"]
|
||||
self.collection_changes_webhooks = params["collection_changes_webhooks"]
|
||||
self.split_duplicates = params["split_duplicates"] # TODO: Here or just in Plex?
|
||||
|
|
|
@ -230,6 +230,7 @@ def update_libraries(config):
|
|||
logger.debug(f"Radarr Add All: {library.radarr_add_all}")
|
||||
logger.debug(f"Sonarr Add All: {library.sonarr_add_all}")
|
||||
logger.debug(f"TMDb Collections: {library.tmdb_collections}")
|
||||
logger.debug(f"Genre Mapper: {library.genre_mapper}")
|
||||
logger.debug(f"Clean Bundles: {library.clean_bundles}")
|
||||
logger.debug(f"Empty Trash: {library.empty_trash}")
|
||||
logger.debug(f"Optimize: {library.optimize}")
|
||||
|
@ -442,9 +443,6 @@ def library_operations(config, library, items=None):
|
|||
else:
|
||||
logger.info(util.adjust_space(f"{item.title[:25]:<25} | No TVDb ID for Guid: {item.guid}"))
|
||||
|
||||
if not tmdb_item and not omdb_item and not tvdb_item:
|
||||
continue
|
||||
|
||||
if library.tmdb_collections and tmdb_item and tmdb_item.belongs_to_collection:
|
||||
tmdb_collections[tmdb_item.belongs_to_collection.id] = tmdb_item.belongs_to_collection.name
|
||||
|
||||
|
@ -493,6 +491,18 @@ def library_operations(config, library, items=None):
|
|||
logger.info(util.adjust_space(f"{item.title[:25]:<25} | Critic Rating | {new_rating}"))
|
||||
except Failed:
|
||||
pass
|
||||
if library.genre_mapper:
|
||||
try:
|
||||
adds = []
|
||||
deletes = []
|
||||
library.reload(item)
|
||||
for genre in item.genres:
|
||||
if genre.tag in library.genre_mapper:
|
||||
deletes.append(genre.tag)
|
||||
adds.append(library.genre_mapper[genre.tag])
|
||||
library.edit_tags("genre", item, add_tags=adds, remove_tags=deletes)
|
||||
except Failed:
|
||||
pass
|
||||
|
||||
if library.Radarr and library.radarr_add_all:
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue