Skip to content

Commit

Permalink
Merge pull request #203 from glensc/errors
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc authored Apr 7, 2021
2 parents ed90c4b + 9fc9cb7 commit 586dbce
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plex_trakt_sync/trakt_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from json import JSONDecodeError
from typing import Union
import trakt

Expand Down Expand Up @@ -171,9 +172,11 @@ def add_to_collection(self, m):
def find_movie(self, movie):
try:
search = trakt.sync.search_by_id(movie.id, id_type=movie.provider)
except JSONDecodeError as e:
raise ValueError(f"Unable to search result for {movie.provider}: {movie.id}: {e.doc!r}") from e
except ValueError as e:
# ValueError: search_type must be one of ('trakt', 'trakt-movie', 'trakt-show', 'trakt-episode', 'trakt-person', 'imdb', 'tmdb', 'tvdb')
raise e
# Search_type must be one of ('trakt', ..., 'imdb', 'tmdb', 'tvdb')
raise ValueError(f"Invalid id_type: {movie.provider}") from e
# look for the first movie in the results
for m in search:
if type(m) is trakt.movies.Movie:
Expand Down

0 comments on commit 586dbce

Please sign in to comment.