From aa96b06508e0b67c9a996e505395985b0f04780b Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Wed, 10 Feb 2021 14:10:53 -0500 Subject: [PATCH 1/9] more debugging outputs --- modules/config.py | 7 ++++++- modules/radarr.py | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/config.py b/modules/config.py index a9ebe94c..eb46bfd3 100644 --- a/modules/config.py +++ b/modules/config.py @@ -533,6 +533,8 @@ class Config: logger.info("Collection Error: {} skipped. MyAnimeList must be configured".format(m)) map = {} elif collections[c][m] is not None: + logger.debug("Method: {}".format(m)) + logger.debug("Value: {}".format(collections[c][m])) if m in util.method_alias: method_name = util.method_alias[m] logger.warning("Collection Warning: {} attribute will run as {}".format(m, method_name)) @@ -843,8 +845,11 @@ class Config: library.clear_collection_missing(collection_name) for method, values in methods: + logger.debug("Method: {}".format(method)) + logger.debug("Values: {}".format(values)) pretty = util.pretty_names[method] if method in util.pretty_names else method for value in values: + logger.debug("Value: {}".format(value)) items = [] missing_movies = [] missing_shows = [] @@ -986,10 +991,10 @@ class Config: edits["summary.value"] = details["summary"] edits["summary.locked"] = 1 if len(edits) > 0: + logger.debug(edits) plex_collection.edit(**edits) plex_collection.reload() logger.info("Details: have been updated") - logger.debug(edits) if "collection_mode" in details: plex_collection.modeUpdate(mode=details["collection_mode"]) if "collection_order" in details: diff --git a/modules/radarr.py b/modules/radarr.py index 2434a9d8..c6cb4433 100644 --- a/modules/radarr.py +++ b/modules/radarr.py @@ -79,7 +79,13 @@ class RadarrAPI: logger.info("Added to Radarr | {:<6} | {}".format(tmdb_id, movie.title)) add_count += 1 else: - logger.error("Radarr Error: ({}) {}: ({}) {}".format(tmdb_id, movie.title, response.status_code, response.json()[0]["errorMessage"])) + try: + logger.error("Radarr Error: ({}) {}: ({}) {}".format(tmdb_id, movie.title, response.status_code, response.json()[0]["errorMessage"])) + except KeyError as e: + logger.debug(url_json) + logger.debug(response) + logger.debug(response.status_code) + logger.debug(response.json()) logger.info("{} Movie{} added to Radarr".format(add_count, "s" if add_count > 1 else "")) @retry(stop_max_attempt_number=6, wait_fixed=10000) From d4c1c9157eac0940a246a1030bdb979cc4a083d9 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Wed, 10 Feb 2021 22:03:43 -0500 Subject: [PATCH 2/9] fix for #10 --- modules/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/util.py b/modules/util.py index d0525641..03e81cff 100644 --- a/modules/util.py +++ b/modules/util.py @@ -1,4 +1,4 @@ -import logging, re, signal, sys, time, traceback +import datetime logging, re, signal, sys, time, traceback try: import msvcrt From af00fee17281a1f5f7d5ba3d599413e4214c795d Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Wed, 10 Feb 2021 22:35:51 -0500 Subject: [PATCH 3/9] fixed comma --- modules/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/util.py b/modules/util.py index 03e81cff..91104620 100644 --- a/modules/util.py +++ b/modules/util.py @@ -1,4 +1,4 @@ -import datetime logging, re, signal, sys, time, traceback +import datetime, logging, re, signal, sys, time, traceback try: import msvcrt From 100c9de2e2e74f144d085516a7b492fe50237d4c Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Wed, 10 Feb 2021 22:50:01 -0500 Subject: [PATCH 4/9] fix for #7 --- modules/radarr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/radarr.py b/modules/radarr.py index c6cb4433..83e91286 100644 --- a/modules/radarr.py +++ b/modules/radarr.py @@ -67,7 +67,7 @@ class RadarrAPI: "title": movie.title, "{}".format("qualityProfileId" if self.version == "v3" else "profileId"): self.quality_profile_id, "year": int(year), - "tmdbid": str(tmdb_id), + "tmdbid": int(tmdb_id), "titleslug": titleslug, "monitored": True, "rootFolderPath": self.root_folder_path, From 8050783e52e8d4f2aa5432f86da9c872fd90232d Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Wed, 10 Feb 2021 23:25:13 -0500 Subject: [PATCH 5/9] Add option to turn off unmanaged collections --- modules/config.py | 33 ++++++++++++++++++++++----------- modules/plex.py | 1 + 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/modules/config.py b/modules/config.py index eb46bfd3..3cbcce8f 100644 --- a/modules/config.py +++ b/modules/config.py @@ -142,6 +142,7 @@ class Config: self.general["plex"]["token"] = check_for_attribute(self.data, "token", parent="plex", default_is_none=True) if "plex" in self.data else None self.general["plex"]["asset_directory"] = check_for_attribute(self.data, "asset_directory", parent="plex", var_type="path", default=os.path.join(default_dir, "assets")) if "plex" in self.data else os.path.join(default_dir, "assets") self.general["plex"]["sync_mode"] = check_for_attribute(self.data, "sync_mode", parent="plex", default="append", test_list=["append", "sync"], options="| \tappend (Only Add Items to the Collection)\n| \tsync (Add & Remove Items from the Collection)") if "plex" in self.data else "append" + self.general["plex"]["show_unmanaged_collections"] = check_for_attribute(self.data, "show_unmanaged_collections", parent="plex", var_type="bool", default=True) if "plex" in self.data else True self.general["radarr"] = {} self.general["radarr"]["url"] = check_for_attribute(self.data, "url", parent="radarr", default_is_none=True) if "radarr" in self.data else None @@ -239,6 +240,16 @@ class Config: else: logger.warning("Config Warning: sync_mode attribute is blank using general value: {}".format(self.general["plex"]["sync_mode"])) + params["show_unmanaged_collections"] = self.general["plex"]["show_unmanaged_collections"] + if "plex" in libs[lib] and "show_unmanaged_collections" in libs[lib]["plex"]: + if libs[lib]["plex"]["show_unmanaged_collections"]: + if isinstance(libs[lib]["plex"]["show_unmanaged_collections"], bool): + params["plex"]["show_unmanaged_collections"] = libs[lib]["plex"]["show_unmanaged_collections"] + else: + logger.warning("Config Warning: plex sub-attribute show_unmanaged_collections must be either true or false using general value: {}".format(self.general["plex"]["show_unmanaged_collections"])) + else: + logger.warning("Config Warning: radarr sub-attribute add is blank using general value: {}".format(self.general["radarr"]["add"])) + params["tmdb"] = self.TMDb params["tvdb"] = self.TVDb @@ -1032,17 +1043,17 @@ class Config: except Exception as e: util.print_stacktrace() logger.error("Unknown Error: {}".format(e)) - - logger.info("") - util.seperator("Unmanaged Collections in {} Library".format(library.name)) - logger.info("") - unmanaged_count = 0 - collections_in_plex = [str(pcol) for pcol in collections] - for col in library.get_all_collections(): - if col.title not in collections_in_plex: - logger.info(col.title) - unmanaged_count += 1 - logger.info("{} Unmanaged Collections".format(unmanaged_count)) + if library.show_unmanaged_collections is True: + logger.info("") + util.seperator("Unmanaged Collections in {} Library".format(library.name)) + logger.info("") + unmanaged_count = 0 + collections_in_plex = [str(pcol) for pcol in collections] + for col in library.get_all_collections(): + if col.title not in collections_in_plex: + logger.info(col.title) + unmanaged_count += 1 + logger.info("{} Unmanaged Collections".format(unmanaged_count)) else: logger.error("No collection to update") diff --git a/modules/plex.py b/modules/plex.py index d4c0c827..8c73e7ce 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -74,6 +74,7 @@ class PlexAPI: self.metadata_path = params["metadata_path"] self.asset_directory = params["asset_directory"] self.sync_mode = params["sync_mode"] + self.show_unmanaged_collections = params["show_unmanaged_collections"] self.plex = params["plex"] self.radarr = params["radarr"] self.sonarr = params["sonarr"] From 486006e5045318286adeb6a63d0c98a922405497 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Thu, 11 Feb 2021 00:35:47 -0500 Subject: [PATCH 6/9] remove original_title use for shows --- modules/plex.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/plex.py b/modules/plex.py index 8c73e7ce..d366bc8e 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -294,7 +294,10 @@ class PlexAPI: add_edit("originally_available", str(item.originallyAvailableAt)[:-9], self.metadata[m], key="originallyAvailableAt", value=originally_available) add_edit("rating", item.rating, self.metadata[m], value=rating) add_edit("content_rating", item.contentRating, self.metadata[m], key="contentRating") - add_edit("original_title", item.originalTitle, self.metadata[m], key="originalTitle", value=original_title) + if self.is_movie: + add_edit("original_title", item.originalTitle, self.metadata[m], key="originalTitle", value=original_title) + elif "original_title" in self.metadata[m]: + logger.error("Metadata Error: original_title does not work with shows") add_edit("studio", item.studio, self.metadata[m], value=studio) add_edit("tagline", item.tagline, self.metadata[m], value=tagline) add_edit("summary", item.summary, self.metadata[m], value=summary) From 64f854fc5134452a559e835669f1f0c868a468fb Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Thu, 11 Feb 2021 01:11:48 -0500 Subject: [PATCH 7/9] more logging changes --- modules/radarr.py | 4 +--- modules/sonarr.py | 6 +++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/radarr.py b/modules/radarr.py index 83e91286..a0257edf 100644 --- a/modules/radarr.py +++ b/modules/radarr.py @@ -83,9 +83,7 @@ class RadarrAPI: logger.error("Radarr Error: ({}) {}: ({}) {}".format(tmdb_id, movie.title, response.status_code, response.json()[0]["errorMessage"])) except KeyError as e: logger.debug(url_json) - logger.debug(response) - logger.debug(response.status_code) - logger.debug(response.json()) + logger.error("Radarr Error: {}".format(response.json())) logger.info("{} Movie{} added to Radarr".format(add_count, "s" if add_count > 1 else "")) @retry(stop_max_attempt_number=6, wait_fixed=10000) diff --git a/modules/sonarr.py b/modules/sonarr.py index 5a959288..1351ebcb 100644 --- a/modules/sonarr.py +++ b/modules/sonarr.py @@ -70,7 +70,11 @@ class SonarrAPI: logger.info("Added to Sonarr | {:<6} | {}".format(tvdb_id, show.title)) add_count += 1 else: - logger.error("Sonarr Error: ({}) {}: ({}) {}".format(tvdb_id, show.title, response.status_code, response.json()[0]["errorMessage"])) + try: + logger.error("Sonarr Error: ({}) {}: ({}) {}".format(tvdb_id, show.title, response.status_code, response.json()[0]["errorMessage"])) + except KeyError as e: + logger.debug(url_json) + logger.error("Sonarr Error: {}".format(response.json())) logger.info("{} Show{} added to Sonarr".format(add_count, "s" if add_count > 1 else "")) @retry(stop_max_attempt_number=6, wait_fixed=10000) From dd2c23b4efa3c3064b3e1296e625a9562e2ddd41 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Thu, 11 Feb 2021 01:15:37 -0500 Subject: [PATCH 8/9] update template --- config/config.yml.template | 1 + 1 file changed, 1 insertion(+) diff --git a/config/config.yml.template b/config/config.yml.template index 021603ac..1e90c918 100644 --- a/config/config.yml.template +++ b/config/config.yml.template @@ -13,6 +13,7 @@ plex: # Can be individually specified pe token: #################### sync_mode: append asset_directory: config/assets + show_unmanaged_collections: true radarr: # Can be individually specified per library as well url: http://192.168.1.12:7878 token: ################################ From 015495d03cf7c17446c8066ea5320cdd22c7f430 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Thu, 11 Feb 2021 01:18:49 -0500 Subject: [PATCH 9/9] v1.0.1 --- README.md | 1 + plex_meta_manager.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f8df5672..ff559bb3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Plex Meta Manager +#### Version 1.0.1 The original concept for Plex Meta Manager is [Plex Auto Collections](https://github.com/mza921/Plex-Auto-Collections), but this is rewritten from the ground up to be able to include a scheduler, metadata edits, multiple libraries, and logging. Plex Meta Manager is a Python 3 script that can be continuously run using YAML configuration files to update on a schedule the metadata of the movies, shows, and collections in your libraries as well as automatically build collections based on various methods all detailed in the wiki. Some collection examples that the script can automatically build and update daily include Plex Based Searches like actor, genre, or studio collections or Collections based on TMDb, IMDb, Trakt, TVDb, AniDB, or MyAnimeList lists and various other services. diff --git a/plex_meta_manager.py b/plex_meta_manager.py index 807e18ab..370fdbb7 100644 --- a/plex_meta_manager.py +++ b/plex_meta_manager.py @@ -56,7 +56,7 @@ logger.info(util.get_centered_text("| |_) | |/ _ \ \/ / | |\/| |/ _ \ __/ _` | | logger.info(util.get_centered_text("| __/| | __/> < | | | | __/ || (_| | | | | | (_| | | | | (_| | (_| | __/ | ")) logger.info(util.get_centered_text("|_| |_|\___/_/\_\ |_| |_|\___|\__\__,_| |_| |_|\__,_|_| |_|\__,_|\__, |\___|_| ")) logger.info(util.get_centered_text(" |___/ ")) -logger.info(util.get_centered_text(" Version: 1.0.0 ")) +logger.info(util.get_centered_text(" Version: 1.0.1 ")) util.seperator() if args.test: