")
return "\n".join(html)
@app.get("/search")
def search():
qstr = request.args.get("q","")
hits = meili_search(qstr)
out=[]
for h in hits:
t = h.get("title","")
src = h.get("source","")
typ = h.get("type","")
ctx = h.get("_formatted",{}).get("text", h.get("text","")[:300])
segs = h.get("segments",[])
ts = int(segs[0]["start"]) if segs else 0
open_link = f"/open?file={{requests.utils.quote(src)}}&t={ts}" if typ=='podcast' else f"/open?file={{requests.utils.quote(src)}}"
badge = f"{typ}"
out.append(
f"
{badge}{t} {src}"
f"
{ctx}
"
f"Open"
f"{' | Transcript' if typ=='podcast' else ''}"
f"
"
)
return "\n".join(out) or "No results yet."
@app.get("/open")
def open_local():
file = request.args.get("file","")
t = int(request.args.get("t","0"))
return f"
{file}\nStart at: {t} sec
"
@app.get("/subtitle")
def subtitle():
file = request.args.get("file","")
base = os.path.splitext(os.path.basename(file))[0]
p = f"/transcripts/{base}.vtt"
if os.path.exists(p):
with open(p,"r",encoding="utf-8") as f:
return f"