From 7eb8bc4e6b445aac259f9df9d01b98399ccd04eb Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Fri, 10 Jun 2022 09:53:16 -0400 Subject: [PATCH] [34] fix plex_collectionless --- VERSION | 2 +- modules/config.py | 3 +++ modules/imdb.py | 13 ++++++++++--- modules/library.py | 1 + modules/operations.py | 5 +++-- modules/overlays.py | 4 +++- modules/plex.py | 6 +++--- 7 files changed, 24 insertions(+), 10 deletions(-) diff --git a/VERSION b/VERSION index 390539e8..a1f713ff 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.17.0-develop33 +1.17.0-develop34 diff --git a/modules/config.py b/modules/config.py index b2597e87..1d7109e2 100644 --- a/modules/config.py +++ b/modules/config.py @@ -775,6 +775,7 @@ class ConfigFile: params["overlay_path"] = [] params["remove_overlays"] = False + params["reapply_overlay"] = False if lib and "overlay_path" in lib: try: if not lib["overlay_path"]: @@ -787,6 +788,8 @@ class ConfigFile: if ("remove_overlays" in file and file["remove_overlays"] is True) \ or ("revert_overlays" in file and file["revert_overlays"] is True): params["remove_overlays"] = True + if "reapply_overlay" in file and file["reapply_overlay"] is True: + params["reapply_overlay"] = True if "schedule" in file and file["schedule"]: logger.debug(f"Value: {file['schedule']}") err = None diff --git a/modules/imdb.py b/modules/imdb.py index 445302bc..6e6597b3 100644 --- a/modules/imdb.py +++ b/modules/imdb.py @@ -217,11 +217,18 @@ class IMDb: with open(tsv, "r") as t: if interface == "ratings": - return {line[0]: line[1] for line in csv.reader(t, delimiter="\t")} + data = {line[0]: line[1] for line in csv.reader(t, delimiter="\t")} elif interface == "basics": - return {line[0]: str(line[-1]).split(",") for line in csv.reader(tsv, delimiter="\t")} + data = {line[0]: str(line[-1]).split(",") for line in csv.reader(tsv, delimiter="\t")} else: - return [line for line in csv.reader(t, delimiter="\t")] + data = [line for line in csv.reader(t, delimiter="\t")] + + if os.path.exists(gz): + os.remove(gz) + if os.path.exists(tsv): + os.remove(tsv) + + return data @property def ratings(self): diff --git a/modules/library.py b/modules/library.py index 3f7ca4d4..7ae5e244 100644 --- a/modules/library.py +++ b/modules/library.py @@ -92,6 +92,7 @@ class Library(ABC): self.update_blank_track_titles = params["update_blank_track_titles"] self.remove_title_parentheses = params["remove_title_parentheses"] self.remove_overlays = params["remove_overlays"] + self.reapply_overlay = params["reapply_overlay"] self.mass_collection_mode = params["mass_collection_mode"] self.metadata_backup = params["metadata_backup"] self.genre_mapper = params["genre_mapper"] diff --git a/modules/operations.py b/modules/operations.py index 6d8d265f..6a7ed08c 100644 --- a/modules/operations.py +++ b/modules/operations.py @@ -89,7 +89,7 @@ class Operations: tmdb_id, tvdb_id, imdb_id = self.library.get_ids(item) item.batchEdits() - batch_display = "Batch Edits" + batch_display = "" if self.library.remove_title_parentheses: if not any([f.name == "title" and f.locked for f in item.fields]) and item.title.endswith(")"): @@ -341,7 +341,8 @@ class Operations: pass item.saveEdits() - logger.info(batch_display) + if batch_display: + logger.info(f"Batch Edits{batch_display}") episode_ops = [self.library.mass_episode_audience_rating_update, self.library.mass_episode_critic_rating_update, self.library.mass_episode_user_rating_update] diff --git a/modules/overlays.py b/modules/overlays.py index a44e8f47..2b3cab2b 100644 --- a/modules/overlays.py +++ b/modules/overlays.py @@ -101,6 +101,8 @@ class Overlays: if overlay.queue: if overlay.queue not in queue_overlays: queue_overlays[overlay.queue] = {} + if overlay.weight in queue_overlays[overlay.queue]: + raise Failed("Overlay Error: Overlays in a queue cannot have the same weight") queue_overlays[overlay.queue][overlay.weight] = over_name else: applied_names.append(over_name) @@ -170,7 +172,7 @@ class Overlays: poster_compare = None if poster is None and has_original is None: logger.error(f"{item_title[:60]:<60} | Overlay Error: No poster found") - elif changed_image or overlay_change: + elif self.library.reapply_overlay or changed_image or overlay_change: try: canvas_width = 1920 if isinstance(item, Episode) else 1000 canvas_height = 1080 if isinstance(item, Episode) else 1500 diff --git a/modules/plex.py b/modules/plex.py index 2d416205..8c18f2e0 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -815,14 +815,14 @@ class Plex(Library): logger.info("Collections Not Excluded (Items in these collections are not added to Collectionless)") for col in good_collections: logger.info(col.title) - collection_indexes = [c.index for c in good_collections] + logger.info("") + collection_indexes = [c.title for c in good_collections] all_items = self.get_all() for i, item in enumerate(all_items, 1): logger.ghost(f"Processing: {i}/{len(all_items)} {item.title}") - self.reload(item) add_item = True for collection in item.collections: - if collection.id in collection_indexes: + if collection.tag in collection_indexes: add_item = False break if add_item: