update
This commit is contained in:
@@ -107,8 +107,10 @@ async def startup():
|
||||
log.info("Leere Datenbank, starte ersten Sync im Hintergrund")
|
||||
asyncio.create_task(guarded_sync())
|
||||
else:
|
||||
# Altbestand: gemerkte Filme, die noch keine Katalogdaten haben
|
||||
# Altbestand: gemerkte Filme, die noch keine Katalogdaten haben,
|
||||
# und Filme, bei denen noch nicht steht, ob man sie leihen kann
|
||||
asyncio.create_task(sync.katalog_nachtragen())
|
||||
asyncio.create_task(sync.leihbarkeit_nachtragen())
|
||||
|
||||
|
||||
@app.on_event("shutdown")
|
||||
@@ -157,15 +159,16 @@ def movie(movie_id: int):
|
||||
|
||||
|
||||
@app.get("/api/search")
|
||||
async def search_movies(q: str):
|
||||
async def search_movies(q: str, limit: int = 24):
|
||||
"""Freie TMDB-Suche für Filme außerhalb des Katalogs."""
|
||||
if len(q.strip()) < 2:
|
||||
return []
|
||||
return await search.search(q.strip())
|
||||
return await search.search(q.strip(), limit=max(1, min(search.MAX_TREFFER, limit)))
|
||||
|
||||
|
||||
@app.get("/api/discover")
|
||||
async def stoebern(
|
||||
limit: int = 40,
|
||||
sort: str = "rating",
|
||||
include: str = "",
|
||||
exclude: str = "",
|
||||
@@ -192,7 +195,8 @@ async def stoebern(
|
||||
"jahr_max": jahr_max,
|
||||
"note_min": note_min,
|
||||
"note_max": note_max,
|
||||
}
|
||||
},
|
||||
limit=max(1, min(search.MAX_TREFFER, limit)),
|
||||
)
|
||||
|
||||
|
||||
@@ -249,6 +253,7 @@ async def ki_suche(
|
||||
jahr_max: int | None = Body(None, embed=True),
|
||||
note_min: float | None = Body(None, embed=True),
|
||||
note_max: float | None = Body(None, embed=True),
|
||||
limit: int = Body(ki.ANZAHL, embed=True),
|
||||
filmabend_sid: str | None = Cookie(None),
|
||||
):
|
||||
"""Vorschläge von der KI, bei TMDB nachgeschlagen. Die eigene Sammlung
|
||||
@@ -278,7 +283,11 @@ async def ki_suche(
|
||||
gesehen = watched.alle(sid)
|
||||
try:
|
||||
vorschlaege = await ki.fragen(
|
||||
beschreibung, sammlung, [ki.etikett(g) for g in gesehen], filter_
|
||||
beschreibung,
|
||||
sammlung,
|
||||
[ki.etikett(g) for g in gesehen],
|
||||
filter_,
|
||||
max(1, min(ki.MAX_ANZAHL, limit)),
|
||||
)
|
||||
except (httpx.HTTPError, KeyError, IndexError):
|
||||
raise HTTPException(status_code=502, detail="Die KI antwortet gerade nicht.")
|
||||
@@ -286,6 +295,29 @@ async def ki_suche(
|
||||
return await ki.aufloesen(vorschlaege, filter_, ausser=ausser)
|
||||
|
||||
|
||||
@app.get("/api/movies/{movie_id}/credits")
|
||||
async def film_credits(movie_id: int):
|
||||
"""Regie und Besetzung, live von TMDB."""
|
||||
return await search.credits(movie_id)
|
||||
|
||||
|
||||
@app.get("/api/personen")
|
||||
async def personen_suchen(q: str):
|
||||
"""Schauspieler und Regisseure bei TMDB suchen."""
|
||||
if len(q.strip()) < 2:
|
||||
return []
|
||||
return await search.personen(q.strip())
|
||||
|
||||
|
||||
@app.get("/api/personen/{person_id}/filme")
|
||||
async def personen_filme(person_id: int):
|
||||
"""Was jemand gespielt hat und wo er Regie geführt hat."""
|
||||
try:
|
||||
return await search.person_filme(person_id)
|
||||
except httpx.HTTPError:
|
||||
raise HTTPException(status_code=502, detail="TMDB antwortet gerade nicht.")
|
||||
|
||||
|
||||
@app.get("/api/search/{movie_id}")
|
||||
async def search_detail(movie_id: int):
|
||||
"""Volle Daten zu einem Suchtreffer. Erst der Katalog, dann TMDB."""
|
||||
|
||||
Reference in New Issue
Block a user