diff options
| author | Tyler Hoang <tyler@tylerhoang.xyz> | 2026-05-06 17:20:35 -0700 |
|---|---|---|
| committer | Tyler Hoang <tyler@tylerhoang.xyz> | 2026-05-06 17:20:35 -0700 |
| commit | 2d298f982408f222ad344b2aa9c18bbe7dc70f12 (patch) | |
| tree | 7347dff5f45789189032bee2821c3cd314b69625 /routers/tmdb.py | |
| parent | 4bbafdd460945eb506ddb07b9068731245708812 (diff) | |
Add TMDB poster picker to film detail page
- New movie_images() async function in services/tmdb.py fetches poster
URLs from TMDB /movie/{id}/images endpoint, filtering for English
and no-text posters only
- New GET /tmdb/posters endpoint returns list of available posters for
a TMDB ID
- New POST /films/{film_id}/poster endpoint to save selected poster
(mirrors the stars endpoint pattern)
- Add "Change Poster" button on detail page (only shown if film has a
TMDB ID) that opens a 3-column grid of posters
- Selected poster gets accent border, main image updates instantly, no
page reload needed
- Posters are cached per load to avoid refetching on re-open
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Diffstat (limited to 'routers/tmdb.py')
| -rw-r--r-- | routers/tmdb.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/routers/tmdb.py b/routers/tmdb.py index 522c1d0..5f7943f 100644 --- a/routers/tmdb.py +++ b/routers/tmdb.py @@ -3,7 +3,7 @@ from dotenv import load_dotenv from fastapi import APIRouter, Query from fastapi.responses import JSONResponse -from services.tmdb import TMDBNotConfiguredError, search_movies +from services.tmdb import TMDBNotConfiguredError, search_movies, movie_images load_dotenv() @@ -30,3 +30,16 @@ async def search_tmdb(q: str = Query(..., min_length=2)): "results": [], }, ) + + +@router.get("/posters") +async def tmdb_posters(tmdb_id: int = Query(...)): + try: + async with httpx.AsyncClient(timeout=10.0) as client: + urls = await movie_images(client, tmdb_id) + return {"posters": urls} + except TMDBNotConfiguredError: + return JSONResponse( + status_code=503, + content={"error": "TMDB_API_KEY is not configured.", "posters": []}, + ) |
