Skip to content

Commit

Permalink
Fix movie lookup by title and year
Browse files Browse the repository at this point in the history
Jellyfin json response defines ProductionYear as number so we need to cast it as string to compare with item release_year
  • Loading branch information
fl0v authored Dec 1, 2024
1 parent 0733b0a commit 0816e3b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions utils/jellyfin.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def add_item_to_collection(self, collection_id: str, item, year_filter: bool = T
# Check if there's a year match
if match is None and year_filter:
for result in res.json()["Items"]:
if result.get("ProductionYear", None) == item["release_year"]:
if str(result.get("ProductionYear", None)) == str(item["release_year"]):
match = result
break

Expand All @@ -126,7 +126,7 @@ def add_item_to_collection(self, collection_id: str, item, year_filter: bool = T
match = res.json()["Items"][0]

if match is None:
logger.warning(f"Item {item['title']} not found in jellyfin")
logger.warning(f"Item {item['title']} ({item.get('release_year','N/A')}) {item.get('imdb_id','N/A')} not found in jellyfin")
else:
try:
item_id = res.json()["Items"][0]["Id"]
Expand Down

0 comments on commit 0816e3b

Please sign in to comment.