Skip to content

Commit

Permalink
fix: correct parsing of external id's (#163)
Browse files Browse the repository at this point in the history
Co-authored-by: Dreu LaVelle <[email protected]>
  • Loading branch information
dreulavelle and Dreu LaVelle authored Jan 24, 2024
1 parent bac8284 commit b155e60
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions backend/program/content/overseerr.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from utils.logger import logger
from utils.request import get, ping
from program.media.container import MediaItemContainer
from program.updaters.trakt import Updater as Trakt, get_imdbid_from_tvdb
from program.updaters.trakt import Updater as Trakt, get_imdbid_from_tmdb, get_imdbid_from_tvdb


class OverseerrConfig(BaseModel):
Expand Down Expand Up @@ -65,7 +65,6 @@ def run(self):

def _get_items_from_overseerr(self, amount: int):
"""Fetch media from overseerr"""

response = get(
self.settings.url + f"/api/v1/request?take={amount}",
additional_headers=self.headers,
Expand Down Expand Up @@ -98,18 +97,31 @@ def get_imdb_id(self, overseerr_item):
self.settings.url + f"/api/v1/{overseerr_item.mediaType}/{external_id}?language=en",
additional_headers=self.headers,
)
if response.is_ok:
if response.is_ok and response.data.externalIds:
imdb_id = response.data.externalIds.imdbId
if imdb_id:
return imdb_id
if not imdb_id:
# I've seen a case where no imdbId was returned but a tvdbId was
elif not imdb_id and response.data.externalIds.tvdbId:
imdb_id = get_imdbid_from_tvdb(response.data.externalIds.tvdbId)
if imdb_id:
logger.debug(
"Could not find imdbId for %s but found it from tvdbId %s",
overseerr_item.title,
response.data.externalIds.tvdbId
)
return imdb_id
elif not imdb_id and response.data.externalIds.tmdbId:
imdb_id = get_imdbid_from_tmdb(response.data.externalIds.tmdbId)
if imdb_id:
logger.debug(
"Could not find imdbId for %s but found it from tmdbId %s",
overseerr_item.title,
response.data.externalIds.tmdbId
)
return imdb_id
self.not_found_ids.append(f"{id_extension}{external_id}")
title = getattr(response.data, "title", None) or getattr(
response.data, "originalName", None
)
logger.debug("Could not get imdbId for %s", title)
logger.debug("Could not get imdbId for %s, or match with external id", title)
return None

0 comments on commit b155e60

Please sign in to comment.