From aa5fbf7fd13ac0f5fccf15d7dde655ad63bbcfc5 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Sun, 26 Dec 2021 22:49:48 -0500 Subject: [PATCH 1/9] fix for cached episode IDs --- modules/cache.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/cache.py b/modules/cache.py index 263b84ab..b5fd7067 100644 --- a/modules/cache.py +++ b/modules/cache.py @@ -202,10 +202,13 @@ class Cache: if row and row[to_id]: datetime_object = datetime.strptime(row["expiration_date"], "%Y-%m-%d") time_between_insertion = datetime.now() - datetime_object - try: - id_to_return = int(row[to_id]) - except ValueError: + if "_" in row[to_id]: id_to_return = row[to_id] + else: + try: + id_to_return = int(row[to_id]) + except ValueError: + id_to_return = row[to_id] expired = time_between_insertion.days > self.expiration out_type = row["media_type"] if return_type else None if return_type: From b903286b7aa703b11ab09cf3fa9129edb4ddc817 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Dec 2021 04:22:51 +0000 Subject: [PATCH 2/9] Bump ruamel-yaml from 0.17.17 to 0.17.19 Bumps [ruamel-yaml](https://sourceforge.net/p/ruamel-yaml/code/ci/default/tree) from 0.17.17 to 0.17.19. --- updated-dependencies: - dependency-name: ruamel-yaml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c29555c7..4e4e23b1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ tmdbv3api==1.7.6 arrapi==1.3.0 lxml==4.7.1 requests==2.26.0 -ruamel.yaml==0.17.17 +ruamel.yaml==0.17.19 schedule==1.1.0 retrying==1.3.3 pathvalidate==2.5.0 From b09f0dc366efccddab9f5d7c7f04b9e385c8721f Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Mon, 27 Dec 2021 19:01:43 -0500 Subject: [PATCH 3/9] fix trakt not saving authorization --- modules/config.py | 2 +- modules/mal.py | 2 +- modules/trakt.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/config.py b/modules/config.py index 5951b037..e6cf4cac 100644 --- a/modules/config.py +++ b/modules/config.py @@ -124,7 +124,7 @@ class ConfigFile: if "sonarr" in new_config: new_config["sonarr"] = new_config.pop("sonarr") if "trakt" in new_config: new_config["trakt"] = new_config.pop("trakt") if "mal" in new_config: new_config["mal"] = new_config.pop("mal") - if not read_only: + if not self.read_only: yaml.round_trip_dump(new_config, open(self.config_path, "w", encoding="utf-8"), indent=None, block_seq_indent=2) self.data = new_config except yaml.scanner.ScannerError as e: diff --git a/modules/mal.py b/modules/mal.py index a9c5f8fb..47b1cc30 100644 --- a/modules/mal.py +++ b/modules/mal.py @@ -108,7 +108,7 @@ class MyAnimeList: def _save(self, authorization): if authorization is not None and "access_token" in authorization and authorization["access_token"] and self._check(authorization): - if self.authorization != authorization and self.config.read_only: + if self.authorization != authorization and not self.config.read_only: yaml.YAML().allow_duplicate_keys = True config, ind, bsi = yaml.util.load_yaml_guess_indent(open(self.config_path)) config["mal"]["authorization"] = { diff --git a/modules/trakt.py b/modules/trakt.py index 344f52ce..c3e0cf0c 100644 --- a/modules/trakt.py +++ b/modules/trakt.py @@ -80,7 +80,7 @@ class Trakt: def _save(self, authorization): if authorization and self._check(authorization): - if self.authorization != authorization and self.config.read_only: + if self.authorization != authorization and not self.config.read_only: yaml.YAML().allow_duplicate_keys = True config, ind, bsi = yaml.util.load_yaml_guess_indent(open(self.config_path)) config["trakt"]["authorization"] = { From 2b4b557012e298dae7c643efe15fc2dd741445ad Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Tue, 28 Dec 2021 15:40:33 -0500 Subject: [PATCH 4/9] Allow Blank users --- config/config.yml.template | 1 + modules/config.py | 2 +- plex_meta_manager.py | 25 ++++++++++++------------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/config/config.yml.template b/config/config.yml.template index a770a3c2..b4d1b994 100644 --- a/config/config.yml.template +++ b/config/config.yml.template @@ -40,6 +40,7 @@ settings: # Can be individually specified tvdb_language: eng ignore_ids: ignore_imdb_ids: + playlist_sync_to_user: all webhooks: # Can be individually specified per library as well error: run_start: diff --git a/modules/config.py b/modules/config.py index e6cf4cac..8f0e3ca7 100644 --- a/modules/config.py +++ b/modules/config.py @@ -247,7 +247,7 @@ class ConfigFile: "tvdb_language": check_for_attribute(self.data, "tvdb_language", parent="settings", default="default"), "ignore_ids": check_for_attribute(self.data, "ignore_ids", parent="settings", var_type="int_list", default_is_none=True), "ignore_imdb_ids": check_for_attribute(self.data, "ignore_imdb_ids", parent="settings", var_type="list", default_is_none=True), - "playlist_sync_to_user": check_for_attribute(self.data, "playlist_sync_to_user", parent="settings", default="all"), + "playlist_sync_to_user": check_for_attribute(self.data, "playlist_sync_to_user", parent="settings", default="all", default_is_none=True), "assets_for_all": check_for_attribute(self.data, "assets_for_all", parent="settings", var_type="bool", default=False, save=False, do_print=False) } self.webhooks = { diff --git a/plex_meta_manager.py b/plex_meta_manager.py index 993c2ea8..6ada4fc8 100644 --- a/plex_meta_manager.py +++ b/plex_meta_manager.py @@ -853,23 +853,22 @@ def run_playlists(config): server_check = pl_library.PlexServer.machineIdentifier sync_to_users = config.general["playlist_sync_to_user"] - if "sync_to_users" not in playlist_attrs: - logger.warning(f"Playlist Error: sync_to_users attribute not found defaulting to playlist_sync_to_user: {sync_to_users}") - elif not playlist_attrs["sync_to_users"]: - logger.warning(f"Playlist Error: sync_to_users attribute is blank defaulting to playlist_sync_to_user: {sync_to_users}") - else: + if "sync_to_users" in playlist_attrs: sync_to_users = playlist_attrs["sync_to_users"] + else: + logger.warning(f"Playlist Error: sync_to_users attribute not found defaulting to playlist_sync_to_user: {sync_to_users}") valid_users = [] plex_users = pl_libraries[0].users - if str(sync_to_users) == "all": - valid_users = plex_users - else: - for user in util.get_list(sync_to_users): - if user in plex_users: - valid_users.append(user) - else: - raise Failed(f"Playlist Error: User: {user} not found in plex\nOptions: {plex_users}") + if sync_to_users: + if str(sync_to_users) == "all": + valid_users = plex_users + else: + for user in util.get_list(sync_to_users): + if user in plex_users: + valid_users.append(user) + else: + raise Failed(f"Playlist Error: User: {user} not found in plex\nOptions: {plex_users}") util.separator(f"Validating {mapping_name} Attributes", space=False, border=False) From 3bf3e8a918516576a685705bfaf86ae1aa3bf622 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Tue, 28 Dec 2021 16:23:26 -0500 Subject: [PATCH 5/9] fix tmdb_collections --- plex_meta_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plex_meta_manager.py b/plex_meta_manager.py index 6ada4fc8..7f8c0b4d 100644 --- a/plex_meta_manager.py +++ b/plex_meta_manager.py @@ -570,7 +570,7 @@ def library_operations(config, library): template[k] = v[int(_i)] for suffix in library.tmdb_collections["remove_suffix"]: if _n.endswith(suffix): - _n = _n[:-len(_n)] + _n = _n[:-len(suffix)] new_collections[_n.strip()] = {"template": template} metadata = MetadataFile(config, library, "Data", { "collections": new_collections, From 9214b3bd02fcc7978ce39b6c65608141fcf367ce Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Tue, 28 Dec 2021 17:41:04 -0500 Subject: [PATCH 6/9] better filepath check for radarr/sonarr --- modules/radarr.py | 10 +++++----- modules/sonarr.py | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/radarr.py b/modules/radarr.py index 481a908c..371d968b 100644 --- a/modules/radarr.py +++ b/modules/radarr.py @@ -58,7 +58,7 @@ class Radarr: arr_ids = {} for movie in self.api.all_movies(): if movie.path: - arr_paths[movie.path[:-1] if movie.path.endswith(("/", "\\")) else movie.path] = movie.tmdbId + arr_paths[movie.path[:-1].lower() if movie.path.endswith(("/", "\\")) else movie.path.lower()] = movie.tmdbId arr_ids[movie.tmdbId] = movie if self.config.trace_mode: logger.debug(arr_paths) @@ -85,11 +85,11 @@ class Radarr: if tmdb_id in arr_ids: exists.append(arr_ids[tmdb_id]) continue - if path in arr_paths: + if path.lower() in arr_paths: mismatched[path] = tmdb_id continue movie = self.api.get_movie(tmdb_id=tmdb_id) - if f"{folder}/{movie.folder}" in arr_paths: + if f"{folder}/{movie.folder}".lower() in arr_paths: path_in_use[f"{folder}/{movie.folder}"] = tmdb_id continue if path: @@ -134,14 +134,14 @@ class Radarr: logger.info("") logger.info("Items in Plex that have already been added to Radarr but under a different TMDb ID then in Plex") for path, tmdb_id in mismatched.items(): - logger.info(f"Plex TMDb ID: {tmdb_id:<7} | Radarr TMDb ID: {arr_paths[path]:<7} | Path: {path}") + logger.info(f"Plex TMDb ID: {tmdb_id:<7} | Radarr TMDb ID: {arr_paths[path.lower()]:<7} | Path: {path}") logger.info(f"{len(mismatched)} Movie{'s' if len(mismatched) > 1 else ''} with mismatched TMDb IDs") if len(path_in_use) > 0: logger.info("") logger.info("TMDb IDs that cannot be added to Radarr because the path they will use is already in use by a different TMDb ID") for path, tmdb_id in path_in_use.items(): - logger.info(f"TMDb ID: {tmdb_id:<7} | Radarr TMDb ID: {arr_paths[path]:<7} | Path: {path}") + logger.info(f"TMDb ID: {tmdb_id:<7} | Radarr TMDb ID: {arr_paths[path.lower()]:<7} | Path: {path}") logger.info(f"{len(path_in_use)} Movie{'s' if len(path_in_use) > 1 else ''} with paths already in use by other TMDb IDs") if len(invalid) > 0: diff --git a/modules/sonarr.py b/modules/sonarr.py index 259f4501..489f892a 100644 --- a/modules/sonarr.py +++ b/modules/sonarr.py @@ -84,8 +84,8 @@ class Sonarr: arr_ids = {} for series in self.api.all_series(): if series.path: - arr_paths[series.path[:-1] if series.path.endswith(("/", "\\")) else series.path] = series.tvdbId - arr_paths[series.tvdbId] = series + arr_paths[series.path[:-1].lower() if series.path.endswith(("/", "\\")) else series.path.lower()] = series.tvdbId + arr_ids[series.tvdbId] = series if self.config.trace_mode: logger.debug(arr_paths) logger.debug(arr_ids) @@ -111,11 +111,11 @@ class Sonarr: if tvdb_id in arr_ids: exists.append(arr_ids[tvdb_id]) continue - if path in arr_paths: + if path.lower() in arr_paths: mismatched[path] = tvdb_id continue show = self.api.get_series(tvdb_id=tvdb_id) - if f"{folder}/{show.folder}" in arr_paths: + if f"{folder}/{show.folder}".lower() in arr_paths: path_in_use[f"{folder}/{show.folder}"] = tvdb_id continue if path: @@ -160,14 +160,14 @@ class Sonarr: logger.info("") logger.info("Items in Plex that have already been added to Sonarr but under a different TVDb ID then in Plex") for path, tmdb_id in mismatched.items(): - logger.info(f"Plex TVDb ID: {tmdb_id:<7} | Sonarr TVDb ID: {arr_paths[path]:<7} | Path: {path}") + logger.info(f"Plex TVDb ID: {tmdb_id:<7} | Sonarr TVDb ID: {arr_paths[path.lower()]:<7} | Path: {path}") logger.info(f"{len(mismatched)} Series with mismatched TVDb IDs") if len(path_in_use) > 0: logger.info("") logger.info("TVDb IDs that cannot be added to Sonarr because the path they will use is already in use by a different TVDb ID") for path, tvdb_id in path_in_use.items(): - logger.info(f"TVDb ID: {tvdb_id:<7} | Sonarr TVDb ID: {arr_paths[path]:<7} | Path: {path}") + logger.info(f"TVDb ID: {tvdb_id:<7} | Sonarr TVDb ID: {arr_paths[path.lower()]:<7} | Path: {path}") logger.info(f"{len(path_in_use)} Series with paths already in use by other TVDb IDs") if len(invalid) > 0: From 672cdbd2cefaa12e45b8db30de5a2fc096835e62 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Tue, 28 Dec 2021 22:44:55 -0500 Subject: [PATCH 7/9] fix NoneError --- modules/radarr.py | 2 +- modules/sonarr.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/radarr.py b/modules/radarr.py index 371d968b..652653f1 100644 --- a/modules/radarr.py +++ b/modules/radarr.py @@ -85,7 +85,7 @@ class Radarr: if tmdb_id in arr_ids: exists.append(arr_ids[tmdb_id]) continue - if path.lower() in arr_paths: + if path and path.lower() in arr_paths: mismatched[path] = tmdb_id continue movie = self.api.get_movie(tmdb_id=tmdb_id) diff --git a/modules/sonarr.py b/modules/sonarr.py index 489f892a..f9f143d5 100644 --- a/modules/sonarr.py +++ b/modules/sonarr.py @@ -111,7 +111,7 @@ class Sonarr: if tvdb_id in arr_ids: exists.append(arr_ids[tvdb_id]) continue - if path.lower() in arr_paths: + if path and path.lower() in arr_paths: mismatched[path] = tvdb_id continue show = self.api.get_series(tvdb_id=tvdb_id) From a6ae03db311f560c92b8f82d817fda7fbcfa0769 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Tue, 28 Dec 2021 23:12:40 -0500 Subject: [PATCH 8/9] allow original_language filter for shows --- modules/builder.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/builder.py b/modules/builder.py index 86b48e3d..4972404e 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -147,7 +147,6 @@ movie_only_filters = [ "country", "country.not", "director", "director.not", "duration.gt", "duration.gte", "duration.lt", "duration.lte", - "original_language", "original_language.not", "subtitle_language", "subtitle_language.not", "resolution", "resolution.not", "writer", "writer.not" @@ -738,8 +737,7 @@ class CollectionBuilder: elif method_name in plex.item_advance_keys: key, options = plex.item_advance_keys[method_name] if method_name in advance_new_agent and self.library.agent not in plex.new_plex_agents: - logger.error( - f"Metadata Error: {method_name} attribute only works for with the New Plex Movie Agent and New Plex TV Agent") + logger.error(f"Metadata Error: {method_name} attribute only works for with the New Plex Movie Agent and New Plex TV Agent") elif method_name in advance_show and not self.library.is_show: logger.error(f"Metadata Error: {method_name} attribute only works for show libraries") elif str(method_data).lower() not in options: From 2b9405afa61001287d4e35c9b66c6ba2d392a98b Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Wed, 29 Dec 2021 10:45:30 -0500 Subject: [PATCH 9/9] version --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index cd99d386..30f101cb 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.14.0 \ No newline at end of file +1.14.1 \ No newline at end of file