[48] fix mass_* operations

pull/1052/head
meisnate12 2 years ago
parent 649fe4bbb5
commit 9130682cdb

@ -1 +1 @@
1.17.3-develop47 1.17.3-develop48

@ -812,12 +812,14 @@ class ConfigFile:
params["metadata_path"] = [("File", os.path.join(default_dir, f"{library_name}.yml"), lib_vars, None)] params["metadata_path"] = [("File", os.path.join(default_dir, f"{library_name}.yml"), lib_vars, None)]
else: else:
params["metadata_path"] = [] params["metadata_path"] = []
except Failed as e:
logger.error(e)
params["default_dir"] = default_dir params["default_dir"] = default_dir
params["skip_library"] = False params["skip_library"] = False
if lib and "schedule" in lib and not self.requested_libraries and not self.ignore_schedules: if lib and "schedule" in lib and not self.requested_libraries and not self.ignore_schedules:
if not lib["schedule"]: if not lib["schedule"]:
raise Failed(f"Config Error: schedule attribute is blank") logger.error(f"Config Error: schedule attribute is blank")
else: else:
logger.debug(f"Value: {lib['schedule']}") logger.debug(f"Value: {lib['schedule']}")
try: try:
@ -835,7 +837,7 @@ class ConfigFile:
raise Failed("Config Error: overlay_path attribute is blank") raise Failed("Config Error: overlay_path attribute is blank")
files = util.load_files(lib["overlay_path"], "overlay_path", lib_vars=lib_vars) files = util.load_files(lib["overlay_path"], "overlay_path", lib_vars=lib_vars)
if not files: if not files:
logger.error("Config Error: No Paths Found for overlay_path") raise Failed("Config Error: No Paths Found for overlay_path")
for file in util.get_list(lib["overlay_path"], split=False): for file in util.get_list(lib["overlay_path"], split=False):
if isinstance(file, dict): if isinstance(file, dict):
if ("remove_overlays" in file and file["remove_overlays"] is True) \ if ("remove_overlays" in file and file["remove_overlays"] is True) \
@ -871,7 +873,10 @@ class ConfigFile:
logger.info(e) logger.info(e)
params["overlay_path"] = [] params["overlay_path"] = []
params["remove_overlays"] = False params["remove_overlays"] = False
except Failed as e:
logger.error(e)
try:
logger.info("") logger.info("")
logger.separator("Plex Configuration", space=False, border=False) logger.separator("Plex Configuration", space=False, border=False)
params["plex"] = { params["plex"] = {

@ -111,8 +111,8 @@ class Library(ABC):
self.items_library_operation = True if self.assets_for_all or self.mass_genre_update or self.remove_title_parentheses \ self.items_library_operation = True if self.assets_for_all or self.mass_genre_update or self.remove_title_parentheses \
or self.mass_audience_rating_update or self.mass_critic_rating_update or self.mass_user_rating_update \ or self.mass_audience_rating_update or self.mass_critic_rating_update or self.mass_user_rating_update \
or self.mass_episode_audience_rating_update or self.mass_episode_critic_rating_update or self.mass_episode_user_rating_update \ or self.mass_episode_audience_rating_update or self.mass_episode_critic_rating_update or self.mass_episode_user_rating_update \
or self.mass_content_rating_update or self.mass_originally_available_update or self.mass_imdb_parental_labels \ or self.mass_content_rating_update or self.mass_originally_available_update or self.mass_original_title_update\
or self.genre_mapper or self.content_rating_mapper \ or self.mass_imdb_parental_labels or self.genre_mapper or self.content_rating_mapper \
or self.radarr_add_all_existing or self.sonarr_add_all_existing else False or self.radarr_add_all_existing or self.sonarr_add_all_existing else False
self.library_operation = True if self.items_library_operation or self.delete_unmanaged_collections or self.delete_collections_with_less \ self.library_operation = True if self.items_library_operation or self.delete_unmanaged_collections or self.delete_collections_with_less \
or self.radarr_remove_by_tag or self.sonarr_remove_by_tag or self.mass_collection_mode \ or self.radarr_remove_by_tag or self.sonarr_remove_by_tag or self.mass_collection_mode \

@ -8,7 +8,7 @@ logger = util.logger
meta_operations = [ meta_operations = [
"mass_audience_rating_update", "mass_user_rating_update", "mass_critic_rating_update", "mass_audience_rating_update", "mass_user_rating_update", "mass_critic_rating_update",
"mass_episode_audience_rating_update", "mass_episode_user_rating_update", "mass_episode_critic_rating_update", "mass_episode_audience_rating_update", "mass_episode_user_rating_update", "mass_episode_critic_rating_update",
"mass_genre_update", "mass_content_rating_update", "mass_originally_available_update" "mass_genre_update", "mass_content_rating_update", "mass_originally_available_update", "mass_original_title_update"
] ]
class Operations: class Operations:
@ -33,6 +33,7 @@ class Operations:
logger.debug(f"Mass Episode Critic Rating Update: {self.library.mass_episode_critic_rating_update}") logger.debug(f"Mass Episode Critic Rating Update: {self.library.mass_episode_critic_rating_update}")
logger.debug(f"Mass Episode User Rating Update: {self.library.mass_episode_user_rating_update}") logger.debug(f"Mass Episode User Rating Update: {self.library.mass_episode_user_rating_update}")
logger.debug(f"Mass Content Rating Update: {self.library.mass_content_rating_update}") logger.debug(f"Mass Content Rating Update: {self.library.mass_content_rating_update}")
logger.debug(f"Mass Original Title Update: {self.library.mass_original_title_update}")
logger.debug(f"Mass Originally Available Update: {self.library.mass_originally_available_update}") logger.debug(f"Mass Originally Available Update: {self.library.mass_originally_available_update}")
logger.debug(f"Mass IMDb Parental Labels: {self.library.mass_imdb_parental_labels}") logger.debug(f"Mass IMDb Parental Labels: {self.library.mass_imdb_parental_labels}")
logger.debug(f"Mass Collection Mode Update: {self.library.mass_collection_mode}") logger.debug(f"Mass Collection Mode Update: {self.library.mass_collection_mode}")
@ -226,8 +227,10 @@ class Operations:
return f"\n{display} | None" return f"\n{display} | None"
elif attribute in ["unlock", "reset"] and item_attr in locked_fields: elif attribute in ["unlock", "reset"] and item_attr in locked_fields:
self.library.edit_query(item, {f"{item_attr}.locked": 0}) self.library.edit_query(item, {f"{item_attr}.locked": 0})
return f"\n{display} | Unlocked"
elif attribute in ["lock", "remove"] and item_attr not in locked_fields: elif attribute in ["lock", "remove"] and item_attr not in locked_fields:
self.library.edit_query(item, {f"{item_attr}.locked": 1}) self.library.edit_query(item, {f"{item_attr}.locked": 1})
return f"\n{display} | Locked"
elif attribute not in ["lock", "unlock", "remove", "reset"]: elif attribute not in ["lock", "unlock", "remove", "reset"]:
if tmdb_item and attribute == "tmdb": if tmdb_item and attribute == "tmdb":
found_rating = tmdb_item.vote_average found_rating = tmdb_item.vote_average
@ -306,9 +309,10 @@ class Operations:
raise Failed raise Failed
if not new_genres: if not new_genres:
logger.info(f"No Genres Found") logger.info(f"No Genres Found")
if self.library.genre_mapper: if self.library.genre_mapper or self.library.mass_genre_update in ["lock", "unlock"]:
if not new_genres and self.library.mass_genre_update not in ["remove", "reset"]: if not new_genres and self.library.mass_genre_update not in ["remove", "reset"]:
new_genres = [g.tag for g in item.genres] new_genres = [g.tag for g in item.genres]
if self.library.genre_mapper:
mapped_genres = [] mapped_genres = []
for genre in new_genres: for genre in new_genres:
if genre in self.library.genre_mapper: if genre in self.library.genre_mapper:
@ -328,7 +332,7 @@ class Operations:
if self.library.mass_content_rating_update or self.library.content_rating_mapper: if self.library.mass_content_rating_update or self.library.content_rating_mapper:
try: try:
new_rating = None new_rating = None
if self.library.mass_content_rating_update and self.library.mass_genre_update not in ["lock", "unlock", "remove", "reset"]: if self.library.mass_content_rating_update and self.library.mass_content_rating_update not in ["lock", "unlock", "remove", "reset"]:
if omdb_item and self.library.mass_content_rating_update == "omdb": if omdb_item and self.library.mass_content_rating_update == "omdb":
new_rating = omdb_item.content_rating new_rating = omdb_item.content_rating
elif mdb_item and self.library.mass_content_rating_update == "mdb": elif mdb_item and self.library.mass_content_rating_update == "mdb":
@ -340,23 +344,24 @@ class Operations:
else: else:
raise Failed raise Failed
if self.library.content_rating_mapper: if self.library.content_rating_mapper:
if new_rating is None and self.library.mass_genre_update not in ["remove", "reset"]: if new_rating is None and self.library.mass_content_rating_update not in ["remove", "reset"]:
new_rating = item.contentRating new_rating = item.contentRating
if new_rating in self.library.content_rating_mapper: if new_rating in self.library.content_rating_mapper:
new_rating = self.library.content_rating_mapper[new_rating] new_rating = self.library.content_rating_mapper[new_rating]
if self.library.mass_content_rating_update in ["remove", "reset"] and item.contentRating: if self.library.mass_content_rating_update in ["remove", "reset"] and item.contentRating:
item.editField("contentRating", None, locked=self.library.mass_content_rating_update == "remove") item.editField("contentRating", None, locked=self.library.mass_content_rating_update == "remove")
batch_display += f"\nContent Rating | None" batch_display += f"\nContent Rating | None"
elif not new_rating and self.library.mass_genre_update not in ["lock", "unlock", "remove", "reset"]: elif not new_rating and self.library.mass_content_rating_update not in ["lock", "unlock", "remove", "reset"]:
logger.info(f"No Content Rating Found") logger.info(f"No Content Rating Found")
elif str(item.contentRating) != str(new_rating): elif str(item.contentRating) != str(new_rating):
item.editContentRating(new_rating) item.editContentRating(new_rating)
batch_display += f"\nContent Rating | {new_rating}" batch_display += f"\nContent Rating | {new_rating}"
elif self.library.mass_content_rating_update in ["unlock", "reset"] and "contentRating" in locked_fields: elif self.library.mass_content_rating_update in ["unlock", "reset"] and "contentRating" in locked_fields:
self.library.edit_query(item, {"contentRating.locked": 0}) self.library.edit_query(item, {"contentRating.locked": 0})
batch_display += f"\nContent Rating | Unlocked"
elif self.library.mass_content_rating_update in ["lock", "remove"] and "contentRating" not in locked_fields: elif self.library.mass_content_rating_update in ["lock", "remove"] and "contentRating" not in locked_fields:
self.library.edit_query(item, {"contentRating.locked": 1}) self.library.edit_query(item, {"contentRating.locked": 1})
batch_display += f"\nContent Rating | Locked"
except Failed: except Failed:
pass pass
@ -366,8 +371,10 @@ class Operations:
batch_display += f"\nOriginal Title | None" batch_display += f"\nOriginal Title | None"
elif self.library.mass_original_title_update in ["unlock", "reset"] and "originalTitle" in locked_fields: elif self.library.mass_original_title_update in ["unlock", "reset"] and "originalTitle" in locked_fields:
self.library.edit_query(item, {"originalTitle.locked": 0}) self.library.edit_query(item, {"originalTitle.locked": 0})
batch_display += f"\nOriginal Title | Unlocked"
elif self.library.mass_original_title_update in ["lock", "remove"] and "originalTitle" not in locked_fields: elif self.library.mass_original_title_update in ["lock", "remove"] and "originalTitle" not in locked_fields:
self.library.edit_query(item, {"originalTitle.locked": 1}) self.library.edit_query(item, {"originalTitle.locked": 1})
batch_display += f"\nOriginal Title | Locked"
elif self.library.mass_original_title_update not in ["lock", "unlock", "remove", "reset"]: elif self.library.mass_original_title_update not in ["lock", "unlock", "remove", "reset"]:
try: try:
if anidb_item and self.library.mass_original_title_update == "anidb": if anidb_item and self.library.mass_original_title_update == "anidb":
@ -396,8 +403,10 @@ class Operations:
batch_display += f"\nOriginally Available Date | None" batch_display += f"\nOriginally Available Date | None"
elif self.library.mass_originally_available_update in ["unlock", "reset"] and "originallyAvailableAt" in locked_fields: elif self.library.mass_originally_available_update in ["unlock", "reset"] and "originallyAvailableAt" in locked_fields:
self.library.edit_query(item, {"originallyAvailableAt.locked": 0}) self.library.edit_query(item, {"originallyAvailableAt.locked": 0})
batch_display += f"\nOriginally Available Date | Unlocked"
elif self.library.mass_originally_available_update in ["lock", "remove"] and "originallyAvailableAt" not in locked_fields: elif self.library.mass_originally_available_update in ["lock", "remove"] and "originallyAvailableAt" not in locked_fields:
self.library.edit_query(item, {"originallyAvailableAt.locked": 1}) self.library.edit_query(item, {"originallyAvailableAt.locked": 1})
batch_display += f"\nOriginally Available Date | Locked"
elif self.library.mass_originally_available_update not in ["lock", "unlock", "remove", "reset"]: elif self.library.mass_originally_available_update not in ["lock", "unlock", "remove", "reset"]:
try: try:
if omdb_item and self.library.mass_originally_available_update == "omdb": if omdb_item and self.library.mass_originally_available_update == "omdb":
@ -448,8 +457,10 @@ class Operations:
return f"\n{display} | None" return f"\n{display} | None"
elif attribute in ["unlock", "reset"] and item_attr in episode_locked_fields: elif attribute in ["unlock", "reset"] and item_attr in episode_locked_fields:
self.library.edit_query(ep, {f"{item_attr}.locked": 0}) self.library.edit_query(ep, {f"{item_attr}.locked": 0})
return f"\n{display} | Unlocked"
elif attribute in ["lock", "remove"] and item_attr not in episode_locked_fields: elif attribute in ["lock", "remove"] and item_attr not in episode_locked_fields:
self.library.edit_query(ep, {f"{item_attr}.locked": 1}) self.library.edit_query(ep, {f"{item_attr}.locked": 1})
return f"\n{display} | Locked"
elif attribute not in ["lock", "unlock", "remove", "reset"]: elif attribute not in ["lock", "unlock", "remove", "reset"]:
found_rating = None found_rating = None
if tmdb_item and attribute == "tmdb": if tmdb_item and attribute == "tmdb":

@ -1006,6 +1006,7 @@ class Plex(Library):
display += f"-{', -'.join(_remove)}" display += f"-{', -'.join(_remove)}"
if is_locked is not None and not display and is_locked != locked: if is_locked is not None and not display and is_locked != locked:
self.edit_query(obj, {f"{actual}.locked": 1 if locked else 0}) self.edit_query(obj, {f"{actual}.locked": 1 if locked else 0})
display = "Locked" if locked else "Unlocked"
final = f"{obj.title[:25]:<25} | {attr_display} | {display}" if display else display final = f"{obj.title[:25]:<25} | {attr_display} | {display}" if display else display
if do_print and final: if do_print and final:
logger.info(final) logger.info(final)

Loading…
Cancel
Save