Skip to content

Commit 13a8295

Browse files
Merge branch 'dev' of github.com:TimilsinaBimal/Watchly into feat/rename-catalog
2 parents 4c8c0c1 + 77c4fa2 commit 13a8295

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

app/api/endpoints/catalogs.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import re
2+
13
from fastapi import APIRouter, HTTPException, Response
24
from loguru import logger
35

@@ -38,13 +40,8 @@ async def get_catalog(
3840
raise HTTPException(status_code=400, detail="Invalid type. Use 'movie' or 'series'")
3941

4042
# Supported IDs now include dynamic themes and item-based rows
41-
if (
42-
id != "watchly.rec"
43-
and not id.startswith("tt")
44-
and not id.startswith("watchly.theme.")
45-
and not id.startswith("watchly.item.")
46-
and not id.startswith("watchly.loved.")
47-
and not id.startswith("watchly.watched.")
43+
if id != "watchly.rec" and not any(
44+
id.startswith(p) for p in ("tt", "watchly.theme.", "watchly.item.", "watchly.loved.", "watchly.watched.")
4845
):
4946
logger.warning(f"Invalid id: {id}")
5047
raise HTTPException(
@@ -76,7 +73,7 @@ async def get_catalog(
7673

7774
elif id.startswith("watchly.item.") or id.startswith("watchly.loved.") or id.startswith("watchly.watched."):
7875
# Extract actual item ID (tt... or tmdb:...)
79-
item_id = id.replace("watchly.item.", "").replace("watchly.loved.", "").replace("watchly.watched.", "")
76+
item_id = re.sub(r"^watchly\.(item|loved|watched)\.", "", id)
8077
recommendations = await recommendation_service.get_recommendations_for_item(item_id=item_id)
8178
logger.info(f"Found {len(recommendations)} recommendations for item {item_id}")
8279

0 commit comments

Comments
 (0)