From 7882a7eac27fc0fc190a0077a6de2bf41d096322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 11 Apr 2021 10:06:55 +0300 Subject: [PATCH 1/3] Add error catching of NotFound plex items --- plex_trakt_sync/plex_api.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plex_trakt_sync/plex_api.py b/plex_trakt_sync/plex_api.py index e239725e91b..35ae3db53f1 100644 --- a/plex_trakt_sync/plex_api.py +++ b/plex_trakt_sync/plex_api.py @@ -1,8 +1,11 @@ import datetime from typing import Union +from plexapi.exceptions import NotFound from plexapi.library import MovieSection, ShowSection, LibrarySection from plexapi.video import Movie, Show + +from plex_trakt_sync.logging import logger from plex_trakt_sync.decorators import memoize, nocache from plex_trakt_sync.config import CONFIG @@ -108,7 +111,13 @@ def all(self): def items(self): result = [] for item in (PlexLibraryItem(x) for x in self.all()): - if item.provider in ["local", "none", "agents.none"]: + try: + provider = item.provider + except NotFound as e: + logger.error(f"{e}, skipping {item}") + continue + + if provider in ["local", "none", "agents.none"]: continue result.append(item) From 16b9719f5074764f894435ab0059ba0820d4bd34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 11 Apr 2021 10:17:01 +0300 Subject: [PATCH 2/3] Add guids property --- plex_trakt_sync/plex_api.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plex_trakt_sync/plex_api.py b/plex_trakt_sync/plex_api.py index 35ae3db53f1..c16e6fc9d6f 100644 --- a/plex_trakt_sync/plex_api.py +++ b/plex_trakt_sync/plex_api.py @@ -22,6 +22,11 @@ def guid(self): return self.item.guids[0].id return self.item.guid + @property + @memoize + def guids(self): + return self.item.guids + @property @memoize def type(self): From cbb3629e4ebf12ca6a8dc82ece28c2ec8386595f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 11 Apr 2021 10:19:02 +0300 Subject: [PATCH 3/3] Catch early on a valid provider --- plex_trakt_sync/commands/sync.py | 6 +----- plex_trakt_sync/plex_api.py | 5 +++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/plex_trakt_sync/commands/sync.py b/plex_trakt_sync/commands/sync.py index 5288083201b..399813d2a36 100644 --- a/plex_trakt_sync/commands/sync.py +++ b/plex_trakt_sync/commands/sync.py @@ -95,13 +95,9 @@ def for_each_pair(sections, trakt: TraktApi): for section in sections: with measure_time(f"Processing section {section.title}"): for pm in section.items(): - if not pm.provider: - logger.error(f'[{pm}]: Unrecognized GUID {pm.guid}') - continue - tm = trakt.find_movie(pm) if tm is None: - logger.warning(f"[{pm})]: Not found from Trakt. Skipping") + logger.warning(f"[{pm})]: Not found on Trakt. Skipping") continue yield pm, tm diff --git a/plex_trakt_sync/plex_api.py b/plex_trakt_sync/plex_api.py index c16e6fc9d6f..96e6b30d945 100644 --- a/plex_trakt_sync/plex_api.py +++ b/plex_trakt_sync/plex_api.py @@ -124,6 +124,11 @@ def items(self): if provider in ["local", "none", "agents.none"]: continue + + if provider not in ["imdb", "tmdb", "tvdb"]: + logger.error(f"{item}: Unable to parse a valid provider from guid:'{item.guid}', guids:{item.guids}") + continue + result.append(item) return result