|
| 1 | +import re |
| 2 | + |
1 | 3 | from fastapi import APIRouter, HTTPException, Response |
2 | 4 | from loguru import logger |
3 | 5 |
|
@@ -38,13 +40,8 @@ async def get_catalog( |
38 | 40 | raise HTTPException(status_code=400, detail="Invalid type. Use 'movie' or 'series'") |
39 | 41 |
|
40 | 42 | # 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.") |
48 | 45 | ): |
49 | 46 | logger.warning(f"Invalid id: {id}") |
50 | 47 | raise HTTPException( |
@@ -76,7 +73,7 @@ async def get_catalog( |
76 | 73 |
|
77 | 74 | elif id.startswith("watchly.item.") or id.startswith("watchly.loved.") or id.startswith("watchly.watched."): |
78 | 75 | # 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) |
80 | 77 | recommendations = await recommendation_service.get_recommendations_for_item(item_id=item_id) |
81 | 78 | logger.info(f"Found {len(recommendations)} recommendations for item {item_id}") |
82 | 79 |
|
|
0 commit comments