Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error catching of NotFound plex items #223

Merged
merged 3 commits into from
Apr 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions plex_trakt_sync/commands/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 20 additions & 1 deletion plex_trakt_sync/plex_api.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -19,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):
Expand Down Expand Up @@ -108,8 +116,19 @@ 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

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
Expand Down