Skip to content

Commit d91dd25

Browse files
committed
fix: handle create_item_from_imdb_id response exception
1 parent 7fd087f commit d91dd25

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/program/apis/trakt_api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,11 @@ def get_show_aliases(self, imdb_id: str, item_type: str) -> List[dict]:
197197
def create_item_from_imdb_id(self, imdb_id: str, type: str = None) -> Optional[MediaItem]:
198198
"""Wrapper for trakt.tv API search method."""
199199
url = f"{self.BASE_URL}/search/imdb/{imdb_id}?extended=full"
200-
response = self.request_handler.execute(HttpMethod.GET, url, timeout=30)
200+
try:
201+
response = self.request_handler.execute(HttpMethod.GET, url, timeout=30)
202+
except TraktAPIError as e:
203+
logger.error(f"Failed to create item using imdb id: {imdb_id} - {str(e)}")
204+
return None
201205
if not response.is_ok or not response.data:
202206
logger.error(
203207
f"Failed to create item using imdb id: {imdb_id}") # This returns an empty list for response.data

0 commit comments

Comments
 (0)