From 3e8cb33a8324df913c998e8549c703432742f7e8 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Sat, 28 May 2022 01:32:02 -0400 Subject: [PATCH] [2] small fixes --- VERSION | 2 +- modules/logs.py | 2 ++ modules/meta.py | 2 +- modules/plex.py | 17 +++++++++++------ modules/tmdb.py | 8 ++++---- modules/trakt.py | 9 ++++++--- plex_meta_manager.py | 7 +++---- 7 files changed, 28 insertions(+), 19 deletions(-) diff --git a/VERSION b/VERSION index 17d0441a..24b1d315 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.17.0-develop1 +1.17.0-develop2 diff --git a/modules/logs.py b/modules/logs.py index 58bbf462..44623faa 100644 --- a/modules/logs.py +++ b/modules/logs.py @@ -234,6 +234,8 @@ class MyLogger: msg = msg.replace(secret, "(redacted)") if "HTTPConnectionPool" in msg: msg = re.sub("HTTPConnectionPool\\((.*?)\\)", "HTTPConnectionPool(redacted)", msg) + if "HTTPSConnectionPool" in msg: + msg = re.sub("HTTPSConnectionPool\\((.*?)\\)", "HTTPSConnectionPool(redacted)", msg) try: if not _srcfile: raise ValueError diff --git a/modules/meta.py b/modules/meta.py index dabc0af8..fe6c2f1c 100644 --- a/modules/meta.py +++ b/modules/meta.py @@ -44,7 +44,7 @@ def get_dict(attribute, attr_data, check_list=None, make_str=False): new_name = f'"{str(_name)}"' if make_str or not isinstance(_name, int) else _name logger.warning(f"Config Warning: Skipping duplicate {attribute[:-1] if attribute[-1] == 's' else attribute}: {new_name}") elif _data is None: - logger.warning(f"Config Warning: {attribute[:-1] if attribute[-1] == 's' else attribute}: {_name} has no data") + continue elif not isinstance(_data, dict): logger.warning(f"Config Warning: {attribute[:-1] if attribute[-1] == 's' else attribute}: {_name} must be a dictionary") elif attribute == "templates": diff --git a/modules/plex.py b/modules/plex.py index 12d17593..eab02353 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -627,10 +627,13 @@ class Plex(Library): def playlist_report(self): playlists = {} def scan_user(server, username): - for playlist in server.playlists(): - if playlist.title not in playlists: - playlists[playlist.title] = [] - playlists[playlist.title].append(username) + try: + for playlist in server.playlists(): + if playlist.title not in playlists: + playlists[playlist.title] = [] + playlists[playlist.title].append(username) + except requests.exceptions.ConnectionError: + pass scan_user(self.PlexServer, self.PlexServer.myPlexAccount().title) for user in self.users: scan_user(self.PlexServer.switchUser(user), user) @@ -1313,9 +1316,11 @@ class Plex(Library): attrs.append(media.videoResolution) for part in media.parts: if filter_attr == "audio_language": - attrs.extend([a.language for a in part.audioStreams()]) + for a in part.audioStreams(): + attrs.extend([a.language, a.tag, a.languageCode]) if filter_attr == "subtitle_language": - attrs.extend([s.language for s in part.subtitleStreams()]) + for s in part.subtitleStreams(): + attrs.extend([s.language, s.tag, s.languageCode]) elif filter_attr in ["content_rating", "year", "rating"]: attrs = [getattr(item, filter_actual)] elif filter_attr in ["actor", "country", "director", "genre", "label", "producer", "writer", diff --git a/modules/tmdb.py b/modules/tmdb.py index 75e5b6d6..cded87d5 100644 --- a/modules/tmdb.py +++ b/modules/tmdb.py @@ -214,11 +214,11 @@ class TMDb: except Failed: raise Failed(f"TMDb Error: No Movie or Collection found for TMDb ID {tmdb_id}") else: return self.get_show(tmdb_id) - def get_movie(self, tmdb_id): - return TMDbMovie(self, tmdb_id) + def get_movie(self, tmdb_id, ignore_cache=False): + return TMDbMovie(self, tmdb_id, ignore_cache=ignore_cache) - def get_show(self, tmdb_id): - return TMDbShow(self, tmdb_id) + def get_show(self, tmdb_id, ignore_cache=False): + return TMDbShow(self, tmdb_id, ignore_cache=ignore_cache) @retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_failed) def get_season(self, tmdb_id, season_number, partial=None): diff --git a/modules/trakt.py b/modules/trakt.py index bb871155..4b271525 100644 --- a/modules/trakt.py +++ b/modules/trakt.py @@ -302,7 +302,7 @@ class Trakt: return data def sync_list(self, slug, ids): - current_ids = self._list(slug, urlparse=False) + current_ids = self._list(slug, urlparse=False, fail=False) def read_result(data, obj_type, result_type, result_str=None): result_str = result_str if result_str else result_type.capitalize() @@ -365,14 +365,17 @@ class Trakt: def build_user_url(self, user, name): return f"{base_url.replace('api.', '')}/users/{user}/lists/{name}" - def _list(self, data, urlparse=True, trakt_ids=False): + def _list(self, data, urlparse=True, trakt_ids=False, fail=True): try: url = requests.utils.urlparse(data).path if urlparse else f"/users/me/lists/{data}" items = self._request(f"{url}/items") except Failed: raise Failed(f"Trakt Error: List {data} not found") if len(items) == 0: - raise Failed(f"Trakt Error: List {data} is empty") + if fail: + raise Failed(f"Trakt Error: List {data} is empty") + else: + return [] return self._parse(items, trakt_ids=trakt_ids) def _userlist(self, list_type, user, is_movie, sort_by=None): diff --git a/plex_meta_manager.py b/plex_meta_manager.py index af60942e..829ca5ac 100644 --- a/plex_meta_manager.py +++ b/plex_meta_manager.py @@ -203,7 +203,7 @@ def start(attrs): logger.debug("") logger.separator(f"Starting {start_type}Run") config = None - stats = {"created": 0, "modified": 0, "deleted": 0, "added": 0, "unchanged": 0, "removed": 0, "radarr": 0, "sonarr": 0} + stats = {"created": 0, "modified": 0, "deleted": 0, "added": 0, "unchanged": 0, "removed": 0, "radarr": 0, "sonarr": 0, "names": []} try: config = ConfigFile(default_dir, attrs) except Exception as e: @@ -211,7 +211,7 @@ def start(attrs): logger.critical(e) else: try: - stats = run_config(config) + stats = run_config(config, stats) except Exception as e: config.notify(e) logger.stacktrace() @@ -231,7 +231,7 @@ def start(attrs): logger.separator(f"Finished {start_type}Run\n{version_line}\nFinished: {end_time.strftime('%H:%M:%S %Y-%m-%d')} Run Time: {run_time}") logger.remove_main_handler() -def run_config(config): +def run_config(config, stats): library_status = run_libraries(config) playlist_status = {} @@ -354,7 +354,6 @@ def run_config(config): logger.info("") print_status(playlist_status) - stats = {"created": 0, "modified": 0, "deleted": 0, "added": 0, "unchanged": 0, "removed": 0, "radarr": 0, "sonarr": 0, "names": []} stats["added"] += amount_added for library in config.libraries: stats["created"] += library.stats["created"]