[111] update mass_imdb_parental_labels

pull/1330/head
meisnate12 2 years ago
parent 41dc1ae651
commit 4b154645a7

@ -1 +1 @@
1.18.3-develop110 1.18.3-develop111

@ -266,16 +266,18 @@ Updates every item's background to the chosen sites background. Will fallback to
## Mass IMDb Parental Labels ## Mass IMDb Parental Labels
Updates every item's labels in the library to match the IMDb Parental Guide Updates every item's labels in the library to match the IMDb Parental Guide.
**Attribute:** `mass_imdb_parental_labels` **Attribute:** `mass_imdb_parental_labels`
**Values:** **Values:**
| Value | Description | | Value | Description |
|:---------------|:--------------------------------------------------------------------------------------------------------------------| |:-----------|:----------------------------------------------------------------------------------|
| `with_none` | Apply all Parental Labels regardless of value | | `none` | Apply all Parental Labels with a value of `None`, `Mild`, `Moderate`, or `Severe` |
| `without_none` | Only apply Parental Labels if the value is not none (i.e. do not apply "Sex & Nudity" label if the value is "None") | | `mild` | Apply all Parental Labels with a value of `Mild`, `Moderate`, or `Severe` |
| `moderate` | Apply all Parental Labels with a value of `Moderate` or `Severe` |
| `severe` | Apply all Parental Labels with a value of `Severe` |
## Mass Collection Mode ## Mass Collection Mode

@ -33,7 +33,12 @@ from retrying import retry
logger = util.logger logger = util.logger
sync_modes = {"append": "Only Add Items to the Collection or Playlist", "sync": "Add & Remove Items from the Collection or Playlist"} sync_modes = {"append": "Only Add Items to the Collection or Playlist", "sync": "Add & Remove Items from the Collection or Playlist"}
imdb_label_options = {"with_none": "Add IMDb Parental Labels including None", "without_none": "Add IMDb Parental Labels including None"} imdb_label_options = {
"none": "Add IMDb Parental Labels for None, Mild, Moderate, or Severe",
"mild": "Add IMDb Parental Labels for Mild, Moderate, or Severe",
"moderate": "Add IMDb Parental Labels for Moderate or Severe",
"severe": "Add IMDb Parental Labels for Severe"
}
mass_genre_options = { mass_genre_options = {
"lock": "Unlock Genre", "unlock": "Unlock Genre", "remove": "Remove and Lock Genre", "reset": "Remove and Unlock Genre", "lock": "Unlock Genre", "unlock": "Unlock Genre", "remove": "Remove and Lock Genre", "reset": "Remove and Unlock Genre",
"tmdb": "Use TMDb Genres", "imdb": "Use IMDb Genres", "omdb": "Use IMDb Genres through OMDb", "tvdb": "Use TVDb Genres", "tmdb": "Use TMDb Genres", "imdb": "Use IMDb Genres", "omdb": "Use IMDb Genres through OMDb", "tvdb": "Use TVDb Genres",
@ -99,7 +104,8 @@ library_operations = {
"mass_critic_rating_update": mass_rating_options, "mass_episode_critic_rating_update": mass_episode_rating_options, "mass_critic_rating_update": mass_rating_options, "mass_episode_critic_rating_update": mass_episode_rating_options,
"mass_user_rating_update": mass_rating_options, "mass_episode_user_rating_update": mass_episode_rating_options, "mass_user_rating_update": mass_rating_options, "mass_episode_user_rating_update": mass_episode_rating_options,
"mass_original_title_update": mass_original_title_options, "mass_originally_available_update": mass_available_options, "mass_original_title_update": mass_original_title_options, "mass_originally_available_update": mass_available_options,
"mass_imdb_parental_labels": imdb_label_options, "mass_poster_update": mass_image_options, "mass_background_update": mass_image_options, "mass_imdb_parental_labels": imdb_label_options, "mass_episode_imdb_parental_labels": imdb_label_options,
"mass_poster_update": mass_image_options, "mass_background_update": mass_image_options,
"mass_collection_mode": "mass_collection_mode", "metadata_backup": "metadata_backup", "delete_collections": "delete_collections", "mass_collection_mode": "mass_collection_mode", "metadata_backup": "metadata_backup", "delete_collections": "delete_collections",
"genre_mapper": "mapper", "content_rating_mapper": "mapper", "genre_mapper": "mapper", "content_rating_mapper": "mapper",
} }
@ -212,6 +218,11 @@ class ConfigFile:
self.data["libraries"][library]["operations"]["radarr_add_all_existing"] = self.data["libraries"][library]["operations"].pop("radarr_add_all") self.data["libraries"][library]["operations"]["radarr_add_all_existing"] = self.data["libraries"][library]["operations"].pop("radarr_add_all")
if "sonarr_add_all" in self.data["libraries"][library]["operations"]: if "sonarr_add_all" in self.data["libraries"][library]["operations"]:
self.data["libraries"][library]["operations"]["sonarr_add_all_existing"] = self.data["libraries"][library]["operations"].pop("sonarr_add_all") self.data["libraries"][library]["operations"]["sonarr_add_all_existing"] = self.data["libraries"][library]["operations"].pop("sonarr_add_all")
if "mass_imdb_parental_labels" in self.data["libraries"][library]["operations"] and self.data["libraries"][library]["operations"]["mass_imdb_parental_labels"]:
if self.data["libraries"][library]["operations"]["mass_imdb_parental_labels"] == "with_none":
self.data["libraries"][library]["operations"]["mass_imdb_parental_labels"] = "none"
elif self.data["libraries"][library]["operations"]["mass_imdb_parental_labels"] == "without_none":
self.data["libraries"][library]["operations"]["mass_imdb_parental_labels"] = "mild"
if "webhooks" in self.data["libraries"][library] and self.data["libraries"][library]["webhooks"] and "collection_changes" not in self.data["libraries"][library]["webhooks"]: if "webhooks" in self.data["libraries"][library] and self.data["libraries"][library]["webhooks"] and "collection_changes" not in self.data["libraries"][library]["webhooks"]:
changes = [] changes = []
def hooks(attr): def hooks(attr):

@ -88,6 +88,7 @@ class Library(ABC):
self.mass_original_title_update = params["mass_original_title_update"] self.mass_original_title_update = params["mass_original_title_update"]
self.mass_originally_available_update = params["mass_originally_available_update"] self.mass_originally_available_update = params["mass_originally_available_update"]
self.mass_imdb_parental_labels = params["mass_imdb_parental_labels"] self.mass_imdb_parental_labels = params["mass_imdb_parental_labels"]
self.mass_episode_imdb_parental_labels = params["mass_episode_imdb_parental_labels"]
self.mass_poster_update = params["mass_poster_update"] self.mass_poster_update = params["mass_poster_update"]
self.mass_background_update = params["mass_background_update"] self.mass_background_update = params["mass_background_update"]
self.radarr_add_all_existing = params["radarr_add_all_existing"] self.radarr_add_all_existing = params["radarr_add_all_existing"]
@ -115,12 +116,13 @@ class Library(ABC):
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_original_title_update\ 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.mass_studio_update\ or self.mass_imdb_parental_labels or self.mass_episode_imdb_parental_labels or self.genre_mapper or self.content_rating_mapper or self.mass_studio_update\
or self.radarr_add_all_existing or self.sonarr_add_all_existing or self.mass_poster_update or self.mass_background_update else False or self.radarr_add_all_existing or self.sonarr_add_all_existing or self.mass_poster_update or self.mass_background_update else False
self.library_operation = True if self.items_library_operation or self.delete_collections or self.mass_collection_mode \ self.library_operation = True if self.items_library_operation or self.delete_collections or self.mass_collection_mode \
or self.radarr_remove_by_tag or self.sonarr_remove_by_tag or self.show_unmanaged or self.show_unconfigured \ or self.radarr_remove_by_tag or self.sonarr_remove_by_tag or self.show_unmanaged or self.show_unconfigured \
or self.metadata_backup or self.update_blank_track_titles else False or self.metadata_backup or self.update_blank_track_titles else False
self.meta_operations = [i for i in [getattr(self, o) for o in operations.meta_operations] if i] self.meta_operations = [i for i in [getattr(self, o) for o in operations.meta_operations] if i]
self.label_operations = True if self.library.assets_for_all or self.library.mass_imdb_parental_labels or self.mass_episode_imdb_parental_labels else False
if self.asset_directory: if self.asset_directory:
logger.info("") logger.info("")

@ -38,6 +38,7 @@ class Operations:
logger.debug(f"Mass Original Title Update: {self.library.mass_original_title_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 Episode IMDb Parental Labels: {self.library.mass_episode_imdb_parental_labels}")
logger.debug(f"Mass Poster Update: {self.library.mass_poster_update}") logger.debug(f"Mass Poster Update: {self.library.mass_poster_update}")
logger.debug(f"Mass Background Update: {self.library.mass_background_update}") logger.debug(f"Mass Background Update: {self.library.mass_background_update}")
logger.debug(f"Mass Collection Mode Update: {self.library.mass_collection_mode}") logger.debug(f"Mass Collection Mode Update: {self.library.mass_collection_mode}")
@ -95,7 +96,7 @@ class Operations:
continue continue
logger.info("") logger.info("")
logger.info(f"Processing: {i}/{len(items)} {item.title}") logger.info(f"Processing: {i}/{len(items)} {item.title}")
current_labels = [la.tag for la in self.library.item_labels(item)] if self.library.assets_for_all or self.library.mass_imdb_parental_labels else [] current_labels = [la.tag for la in self.library.item_labels(item)] if self.library.label_operations else []
if self.library.assets_for_all and self.library.asset_directory: if self.library.assets_for_all and self.library.asset_directory:
self.library.find_and_upload_assets(item, current_labels) self.library.find_and_upload_assets(item, current_labels)
@ -116,7 +117,7 @@ class Operations:
if self.library.mass_imdb_parental_labels: if self.library.mass_imdb_parental_labels:
try: try:
parental_guide = self.config.IMDb.parental_guide(imdb_id) parental_guide = self.config.IMDb.parental_guide(imdb_id)
parental_labels = [f"{k.capitalize()}:{v}" for k, v in parental_guide.items() if self.library.mass_imdb_parental_labels == "with_none" or v != "None"] parental_labels = [f"{k.capitalize()}:{v}" for k, v in parental_guide.items() if v not in util.parental_levels[self.library.mass_imdb_parental_labels]]
add_labels = [la for la in parental_labels if la not in current_labels] add_labels = [la for la in parental_labels if la not in current_labels]
remove_labels = [la for la in current_labels if la in util.parental_labels and la not in parental_labels] remove_labels = [la for la in current_labels if la in util.parental_labels and la not in parental_labels]
if add_labels or remove_labels: if add_labels or remove_labels:
@ -555,7 +556,10 @@ class Operations:
if self.library.mass_background_update: if self.library.mass_background_update:
self.library.background_update(episode, episode_background, title=episode.title if episode else None) self.library.background_update(episode, episode_background, title=episode.title if episode else None)
episode_ops = [self.library.mass_episode_audience_rating_update, self.library.mass_episode_critic_rating_update, self.library.mass_episode_user_rating_update] episode_ops = [
self.library.mass_episode_audience_rating_update, self.library.mass_episode_critic_rating_update,
self.library.mass_episode_user_rating_update, self.library.mass_episode_imdb_parental_labels
]
if any([x is not None for x in episode_ops]): if any([x is not None for x in episode_ops]):
@ -564,6 +568,7 @@ class Operations:
for ep in item.episodes(): for ep in item.episodes():
#ep.batchEdits() #ep.batchEdits()
ep = self.library.reload(ep)
batch_display = "" batch_display = ""
item_title = self.library.get_item_sort_title(ep, atr="title") item_title = self.library.get_item_sort_title(ep, atr="title")
logger.info("") logger.info("")

@ -186,16 +186,16 @@ class Overlays:
try: try:
has_original = self.library.check_image_for_overlay(new_backup, os.path.join(self.library.overlay_backup, f"{item.ratingKey}")) has_original = self.library.check_image_for_overlay(new_backup, os.path.join(self.library.overlay_backup, f"{item.ratingKey}"))
except Failed as e: except Failed as e:
raise Failed(f"Overlay Error: {e}") raise Failed(f" Overlay Error: {e}")
poster_compare = None poster_compare = None
if poster is None and has_original is None: if poster is None and has_original is None:
logger.error(f"Overlay Error: No poster found") logger.error(f" Overlay Error: No poster found")
elif self.library.reapply_overlays or changed_image or overlay_change: elif self.library.reapply_overlays or changed_image or overlay_change:
try: try:
if not self.library.reapply_overlays and changed_image: if not self.library.reapply_overlays and changed_image:
logger.trace("Overlay applied because new image was detected") logger.trace(" Overlay applied because new image was detected")
elif not self.library.reapply_overlays and overlay_change: elif not self.library.reapply_overlays and overlay_change:
logger.trace(f"Overlay applied because overlay changed {change_reason}") logger.trace(f" Overlay applied because overlay changed {change_reason}")
canvas_width, canvas_height = overlay.get_canvas_size(item) canvas_width, canvas_height = overlay.get_canvas_size(item)
with Image.open(poster.location if poster else has_original) as new_poster: with Image.open(poster.location if poster else has_original) as new_poster:
exif_tags = new_poster.getexif() exif_tags = new_poster.getexif()
@ -296,7 +296,7 @@ class Overlays:
try: try:
overlay_image, addon_box = current_overlay.get_backdrop((canvas_width, canvas_height), box=image_box, text=get_text(current_overlay)) overlay_image, addon_box = current_overlay.get_backdrop((canvas_width, canvas_height), box=image_box, text=get_text(current_overlay))
except Failed as e: except Failed as e:
logger.warning(e) logger.warning(f" {e}")
continue continue
new_poster.paste(overlay_image, (0, 0), overlay_image) new_poster.paste(overlay_image, (0, 0), overlay_image)
else: else:
@ -331,7 +331,7 @@ class Overlays:
try: try:
overlay_image, addon_box = current_overlay.get_backdrop((canvas_width, canvas_height), box=image_box, text=get_text(current_overlay), new_cords=cord) overlay_image, addon_box = current_overlay.get_backdrop((canvas_width, canvas_height), box=image_box, text=get_text(current_overlay), new_cords=cord)
except Failed as e: except Failed as e:
logger.warning(e) logger.warning(f" {e}")
continue continue
new_poster.paste(overlay_image, (0, 0), overlay_image) new_poster.paste(overlay_image, (0, 0), overlay_image)
if current_overlay.image: if current_overlay.image:
@ -348,17 +348,17 @@ class Overlays:
self.library.upload_poster(item, temp) self.library.upload_poster(item, temp)
self.library.edit_tags("label", item, add_tags=["Overlay"], do_print=False) self.library.edit_tags("label", item, add_tags=["Overlay"], do_print=False)
poster_compare = poster.compare if poster else item.thumb poster_compare = poster.compare if poster else item.thumb
logger.info(f"Overlays Applied: {', '.join(over_names)}") logger.info(f" Overlays Applied: {', '.join(over_names)}")
except (OSError, BadRequest, SyntaxError) as e: except (OSError, BadRequest, SyntaxError) as e:
logger.stacktrace() logger.stacktrace()
raise Failed(f"Overlay Error: {e}") raise Failed(f" Overlay Error: {e}")
else: else:
logger.info("Overlay Update Not Needed") logger.info(" Overlay Update Not Needed")
if self.config.Cache and poster_compare: if self.config.Cache and poster_compare:
self.config.Cache.update_image_map(item.ratingKey, f"{self.library.image_table_name}_overlays", item.thumb, poster_compare, overlay='|'.join(compare_names)) self.config.Cache.update_image_map(item.ratingKey, f"{self.library.image_table_name}_overlays", item.thumb, poster_compare, overlay='|'.join(compare_names))
except Failed as e: except Failed as e:
logger.error(f"{e}\nOverlays Attempted on {item_title}: {', '.join(over_names)}") logger.error(f" {e}\n Overlays Attempted on {item_title}: {', '.join(over_names)}")
except Exception as e: except Exception as e:
logger.info(e) logger.info(e)
logger.info(type(e)) logger.info(type(e))

@ -99,6 +99,7 @@ collection_mode_options = {
} }
parental_types = ["nudity", "violence", "profanity", "alcohol", "frightening"] parental_types = ["nudity", "violence", "profanity", "alcohol", "frightening"]
parental_values = ["None", "Mild", "Moderate", "Severe"] parental_values = ["None", "Mild", "Moderate", "Severe"]
parental_levels = {"none": [], "mild": ["None"], "moderate": ["None", "Mild"], "severe": ["None", "Mild", "Moderate"]}
parental_labels = [f"{t.capitalize()}:{v}" for t in parental_types for v in parental_values] parental_labels = [f"{t.capitalize()}:{v}" for t in parental_types for v in parental_values]
previous_time = None previous_time = None
start_time = None start_time = None

Loading…
Cancel
Save