diff --git a/VERSION b/VERSION index 0b59df08..8ca9b157 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.17.3-develop47 +1.17.3-develop48 diff --git a/modules/config.py b/modules/config.py index 989a4074..0ebb07ac 100644 --- a/modules/config.py +++ b/modules/config.py @@ -812,66 +812,71 @@ class ConfigFile: params["metadata_path"] = [("File", os.path.join(default_dir, f"{library_name}.yml"), lib_vars, None)] else: params["metadata_path"] = [] - params["default_dir"] = default_dir - - params["skip_library"] = False - if lib and "schedule" in lib and not self.requested_libraries and not self.ignore_schedules: - if not lib["schedule"]: - raise Failed(f"Config Error: schedule attribute is blank") - else: - logger.debug(f"Value: {lib['schedule']}") - try: - util.schedule_check("schedule", lib["schedule"], current_time, self.run_hour) - except NotScheduled: - params["skip_library"] = True + except Failed as e: + logger.error(e) + params["default_dir"] = default_dir - params["overlay_path"] = [] - params["remove_overlays"] = False - params["reapply_overlays"] = False - params["reset_overlays"] = None - if lib and "overlay_path" in lib: + params["skip_library"] = False + if lib and "schedule" in lib and not self.requested_libraries and not self.ignore_schedules: + if not lib["schedule"]: + logger.error(f"Config Error: schedule attribute is blank") + else: + logger.debug(f"Value: {lib['schedule']}") try: - if not lib["overlay_path"]: - raise Failed("Config Error: overlay_path attribute is blank") - files = util.load_files(lib["overlay_path"], "overlay_path", lib_vars=lib_vars) - if not files: - logger.error("Config Error: No Paths Found for overlay_path") - for file in util.get_list(lib["overlay_path"], split=False): - if isinstance(file, dict): - if ("remove_overlays" in file and file["remove_overlays"] is True) \ - or ("remove_overlay" in file and file["remove_overlay"] is True) \ - or ("revert_overlays" in file and file["revert_overlays"] is True): - params["remove_overlays"] = True - if ("reapply_overlays" in file and file["reapply_overlays"] is True) \ - or ("reapply_overlay" in file and file["reapply_overlay"] is True): - params["reapply_overlays"] = True - if "reset_overlays" in file or "reset_overlay" in file: - attr = f"reset_overlay{'s' if 'reset_overlays' in file else ''}" - if file[attr] and file[attr] in reset_overlay_options: - params["reset_overlays"] = file[attr] - else: - final_text = f"Config Error: reset_overlays attribute {file[attr]} invalid. Options: " - for option, description in reset_overlay_options.items(): - final_text = f"{final_text}\n {option} ({description})" - logger.error(final_text) - if "schedule" in file and file["schedule"]: - logger.debug(f"Value: {file['schedule']}") - err = None - try: - util.schedule_check("schedule", file["schedule"], current_time, self.run_hour) - except NotScheduledRange as e: + util.schedule_check("schedule", lib["schedule"], current_time, self.run_hour) + except NotScheduled: + params["skip_library"] = True + + params["overlay_path"] = [] + params["remove_overlays"] = False + params["reapply_overlays"] = False + params["reset_overlays"] = None + if lib and "overlay_path" in lib: + try: + if not lib["overlay_path"]: + raise Failed("Config Error: overlay_path attribute is blank") + files = util.load_files(lib["overlay_path"], "overlay_path", lib_vars=lib_vars) + if not files: + raise Failed("Config Error: No Paths Found for overlay_path") + for file in util.get_list(lib["overlay_path"], split=False): + if isinstance(file, dict): + if ("remove_overlays" in file and file["remove_overlays"] is True) \ + or ("remove_overlay" in file and file["remove_overlay"] is True) \ + or ("revert_overlays" in file and file["revert_overlays"] is True): + params["remove_overlays"] = True + if ("reapply_overlays" in file and file["reapply_overlays"] is True) \ + or ("reapply_overlay" in file and file["reapply_overlay"] is True): + params["reapply_overlays"] = True + if "reset_overlays" in file or "reset_overlay" in file: + attr = f"reset_overlay{'s' if 'reset_overlays' in file else ''}" + if file[attr] and file[attr] in reset_overlay_options: + params["reset_overlays"] = file[attr] + else: + final_text = f"Config Error: reset_overlays attribute {file[attr]} invalid. Options: " + for option, description in reset_overlay_options.items(): + final_text = f"{final_text}\n {option} ({description})" + logger.error(final_text) + if "schedule" in file and file["schedule"]: + logger.debug(f"Value: {file['schedule']}") + err = None + try: + util.schedule_check("schedule", file["schedule"], current_time, self.run_hour) + except NotScheduledRange as e: + err = e + except NotScheduled as e: + if not self.ignore_schedules: err = e - except NotScheduled as e: - if not self.ignore_schedules: - err = e - if err: - raise NotScheduled(f"{err}\n\nOverlays not scheduled to run") - params["overlay_path"] = files - except NotScheduled as e: - logger.info(e) - params["overlay_path"] = [] - params["remove_overlays"] = False + if err: + raise NotScheduled(f"{err}\n\nOverlays not scheduled to run") + params["overlay_path"] = files + except NotScheduled as e: + logger.info(e) + params["overlay_path"] = [] + params["remove_overlays"] = False + except Failed as e: + logger.error(e) + try: logger.info("") logger.separator("Plex Configuration", space=False, border=False) params["plex"] = { diff --git a/modules/library.py b/modules/library.py index 62512d89..987684d1 100644 --- a/modules/library.py +++ b/modules/library.py @@ -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 \ 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_content_rating_update or self.mass_originally_available_update or self.mass_imdb_parental_labels \ - or self.genre_mapper or self.content_rating_mapper \ + or self.mass_content_rating_update or self.mass_originally_available_update or self.mass_original_title_update\ + 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 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 \ diff --git a/modules/operations.py b/modules/operations.py index b915f059..43801b2a 100644 --- a/modules/operations.py +++ b/modules/operations.py @@ -8,7 +8,7 @@ logger = util.logger meta_operations = [ "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_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: @@ -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 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 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 IMDb Parental Labels: {self.library.mass_imdb_parental_labels}") logger.debug(f"Mass Collection Mode Update: {self.library.mass_collection_mode}") @@ -226,8 +227,10 @@ class Operations: return f"\n{display} | None" elif attribute in ["unlock", "reset"] and item_attr in locked_fields: 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: self.library.edit_query(item, {f"{item_attr}.locked": 1}) + return f"\n{display} | Locked" elif attribute not in ["lock", "unlock", "remove", "reset"]: if tmdb_item and attribute == "tmdb": found_rating = tmdb_item.vote_average @@ -306,17 +309,18 @@ class Operations: raise Failed if not new_genres: 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"]: new_genres = [g.tag for g in item.genres] - mapped_genres = [] - for genre in new_genres: - if genre in self.library.genre_mapper: - if self.library.genre_mapper[genre]: - mapped_genres.append(self.library.genre_mapper[genre]) - else: - mapped_genres.append(genre) - new_genres = mapped_genres + if self.library.genre_mapper: + mapped_genres = [] + for genre in new_genres: + if genre in self.library.genre_mapper: + if self.library.genre_mapper[genre]: + mapped_genres.append(self.library.genre_mapper[genre]) + else: + mapped_genres.append(genre) + new_genres = mapped_genres temp_display = self.library.edit_tags("genre", item, sync_tags=new_genres, do_print=False, locked=False if self.library.mass_genre_update in ["unlock", "reset"] else True, is_locked="genre" in locked_fields) @@ -328,7 +332,7 @@ class Operations: if self.library.mass_content_rating_update or self.library.content_rating_mapper: try: 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": new_rating = omdb_item.content_rating elif mdb_item and self.library.mass_content_rating_update == "mdb": @@ -340,23 +344,24 @@ class Operations: else: raise Failed 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 if new_rating in self.library.content_rating_mapper: new_rating = self.library.content_rating_mapper[new_rating] - 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") 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") elif str(item.contentRating) != str(new_rating): item.editContentRating(new_rating) batch_display += f"\nContent Rating | {new_rating}" elif self.library.mass_content_rating_update in ["unlock", "reset"] and "contentRating" in locked_fields: 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: self.library.edit_query(item, {"contentRating.locked": 1}) + batch_display += f"\nContent Rating | Locked" except Failed: pass @@ -366,8 +371,10 @@ class Operations: batch_display += f"\nOriginal Title | None" elif self.library.mass_original_title_update in ["unlock", "reset"] and "originalTitle" in locked_fields: 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: 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"]: try: if anidb_item and self.library.mass_original_title_update == "anidb": @@ -396,8 +403,10 @@ class Operations: batch_display += f"\nOriginally Available Date | None" elif self.library.mass_originally_available_update in ["unlock", "reset"] and "originallyAvailableAt" in locked_fields: 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: 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"]: try: if omdb_item and self.library.mass_originally_available_update == "omdb": @@ -448,8 +457,10 @@ class Operations: return f"\n{display} | None" elif attribute in ["unlock", "reset"] and item_attr in episode_locked_fields: 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: self.library.edit_query(ep, {f"{item_attr}.locked": 1}) + return f"\n{display} | Locked" elif attribute not in ["lock", "unlock", "remove", "reset"]: found_rating = None if tmdb_item and attribute == "tmdb": diff --git a/modules/plex.py b/modules/plex.py index 8539a939..f191617f 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -1006,6 +1006,7 @@ class Plex(Library): display += f"-{', -'.join(_remove)}" 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}) + display = "Locked" if locked else "Unlocked" final = f"{obj.title[:25]:<25} | {attr_display} | {display}" if display else display if do_print and final: logger.info(final)