Playback: retry flaky upstream, faster proxy fail, cache /stream in browser

- upstream._get: one 300ms retry on transient errors (CF 403/503, 429,
  5xx); 404 stays final. Fixes the 502 cluster that hls.js couldn't
  recover from (fragLoadTimeOut x3 in error log)
- /stream: upstream timeout 12s < hls.js fragLoadingTimeOut (20s), so a
  hung segment 502s first and hls.js retries instead of fatal-timing-out
- /stream responses: Cache-Control public max-age=86400 (VOD + token is
  the exact upstream URL => immutable); re-opens/re-seeks skip the proxy
- /api/stream: drop unused qualities (frontend never read it; saved a
  ~0.2s cold upstream round-trip per episode)
- app.js/style.css: max-age=300 instead of no-store
- test_history_page_and_delete: stale selector (home redesign removed
  the 'view all' link; use 'history ->')
This commit is contained in:
jozamudi committed 2026-08-30 17:23:57 +00:00
1 parent 36be7d0a02
commit 0fd06f036a
4 files changed
+43 -29

No files matched your search

+5 -5
View File
@@ -115,7 +115,7 @@ async def _history_page_and_delete():
op.open(urllib.request.Request(BASE + "/login",
data=json.dumps({"username": "erin", "password": "erinpw12345"}).encode(),
headers={"Content-Type": "application/json"}, method="POST"))
for n in range(1, 6): # 5 entries: makes the home "view all" link render
for n in range(1, 6): # 5 entries: makes the home "history →" link render
e = {"title": f"Hist {n}", "slug_id": f"hist-{n}", "season_id": n, "ep_id": n,
"lang": "eng", "ep": n, "pos": 5, "dur": 600}
op.open(urllib.request.Request(BASE + "/api/history",
@@ -129,11 +129,11 @@ async def _history_page_and_delete():
page.on("pageerror", lambda e: errors.append(str(e)))
await _login(page, "erin", "erinpw12345")
# regression: "view all" must go to the ?history query, not the /history path
# regression: the home history link must go to the ?history query, not the /history path
await page.goto(BASE + "/")
await page.wait_for_selector("a:has-text('view all')", timeout=15000)
assert (await page.get_attribute("a:has-text('view all')", "href")).endswith("/?history")
await page.click("a:has-text('view all')", force=True)
await page.wait_for_selector("a:has-text('history →')", timeout=15000)
assert (await page.get_attribute("a:has-text('history →')", "href")).endswith("/?history")
await page.click("a:has-text('history →')", force=True)
await page.wait_for_selector(".card.hist", timeout=15000)
await page.wait_for_function(
"document.querySelectorAll('.card.hist').length == 5", timeout=15000, polling=POLL)