Smart back (mirrors music's artist-detail): the top-left back button now
remembers where you actually came from, many layers deep. It keeps an origin
stack ({page} or {detail title}) and stamps each history entry with its layer
depth, so:
- the label is dynamic — '← Back to Search' / '← Back to The Bear' / '← Back to
<person>' — instead of a hardcoded 'Library'/'Back';
- backing out of the first layer returns to the page you started from (Search,
Watchlist, wherever), not always the Library;
- browser Back and our button both unwind the chain one layer at a time, in sync.
Fixes: search → person → back → movie used to mislabel as 'Library' and dump you
in the library.
Next level:
- Search isn't a blank box when idle — a 'Trending this week' rail (TMDB
trending, owned/preview annotated). Returns when you clear the query.
- Person page gets a 'Known For' hero rail (top titles by popularity) above a
full filmography now sorted chronologically (newest first).
Backend: TMDBClient.trending + engine.trending (+library annotation), route
/api/video/trending. Isolated; 237 video-suite tests pass.
43 lines
1.5 KiB
Python
43 lines
1.5 KiB
Python
"""Video search API (in-app, isolated).
|
|
|
|
GET /api/video/search?q=... → TMDB multi-search (movies / shows / people),
|
|
movie/show results annotated with library_id
|
|
if already owned.
|
|
|
|
Everything resolves back into SoulSync — results link to the library detail
|
|
(owned) or the TMDB-backed detail (not owned); people open the in-app person
|
|
page. Reads only the video engine + video.db.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from flask import jsonify, request
|
|
|
|
from utils.logging_config import get_logger
|
|
|
|
logger = get_logger("video_api.search")
|
|
|
|
|
|
def register_routes(bp):
|
|
@bp.route("/search", methods=["GET"])
|
|
def video_search():
|
|
q = (request.args.get("q") or "").strip()
|
|
if not q:
|
|
return jsonify({"results": [], "query": ""})
|
|
try:
|
|
from core.video.enrichment.engine import get_video_enrichment_engine
|
|
results = get_video_enrichment_engine().search(q)
|
|
except Exception:
|
|
logger.exception("video search failed for %r", q)
|
|
results = []
|
|
return jsonify({"results": results, "query": q})
|
|
|
|
@bp.route("/trending", methods=["GET"])
|
|
def video_trending():
|
|
try:
|
|
from core.video.enrichment.engine import get_video_enrichment_engine
|
|
results = get_video_enrichment_engine().trending()
|
|
except Exception:
|
|
logger.exception("video trending failed")
|
|
results = []
|
|
return jsonify({"results": results})
|