Spaces:
Running
Running
Commit ·
d327e3a
1
Parent(s): 39d80eb
fix(vegamovies): wrong-episode TV files — extract real filenames from R2 signed URLs (response-content-disposition / path basename); unnamed unverifiable files (r2.dev hashes, pixeldrain) are excluded for TV instead of passing the episode filter
Browse files416 unmodified lines41741841942042142212 unmodified lines43543643743843944044145 unmodified lines487488489490491492493494495496497498499500501994 unmodified lines1496149714981499150015011502416 unmodified linesreturn uasync def _sf_resolve_hubcloud(client: httpx.AsyncClient, link: str) -> list:"""Resolve one hubcloud-family page into direct file URLs."""out = []12 unmodified linesu = b.group(1)chunk = page[b.start():b.start() + 800]fm = re.search(r'download="([^"]{5,110})"', chunk)fname = fm.group(1) if fm else ""if "pixeldrain" in u:out.append({"url": _sf_pixeldrain_direct(u), "label": fname or "Direct"})elif any(u.endswith(ext) or f"{ext}?" in u for ext in (".mkv", ".mp4")) and ".zip" not in u:45 unmodified linesresults = []seen_urls = set()for r in resolved:u, label = r["url"], r["label"]if u in seen_urls:continueseen_urls.add(u)if media_type == "tv" and not _sf_episode_matches(label, season or 1, episode or 1):continueresults.append(_sf_stream_result(f"{source_name}/HubCloud", f"{source_name} - {label or 'Direct'}", u,quality=_sf_quality_from_name(label), language=_sf_lang_from_name(label)))return results994 unmodified linesu = b.group(1)chunk = page[b.start():b.start() + 800]fm = re.search(r'download="([^"]{5,110})"', chunk)fname = fm.group(1) if fm else "Direct"if "pixeldrain" in u:out.append({"url": _sf_pixeldrain_direct(u), "label": fname})elif "cloudflarestorage" in u or "workers.dev" in u or ".r2.dev" in u or "googleusercontent" in u:416 unmodified lines41741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645712 unmodified lines47047147247347447547645 unmodified lines522523524525526527528529530531532533534535536537538539540541542543544545994 unmodified lines1540154115421543154415451546416 unmodified linesreturn udef _sf_fname_from_url(u: str) -> str:"""Best-effort FILENAME extraction from a direct-file URL.VegaMovies' hubcloud results are mostly R2 SIGNED URLs whose only humanreadable name lives in `response-content-disposition=<File.Name.mkv>`(or as the /hub2/<File.Name.mkv> path basename). Without the filename theepisode filter sees label="Direct" and passes EVERYTHING - that is thewrong-episode bug (S05E01 served for an S01E01 request). r2.dev contenthashes / pixeldrain ids carry no name at all -> "" (unverifiable)."""try:from urllib.parse import urlsplit, parse_qssp = urlsplit(u)q = parse_qs(sp.query)for k in ("response-content-disposition", "response-content-disposition*"):for v in (q.get(k) or []):v = (v or "").strip()if not v:continue# R2 signs the BARE filename; full headers look like# `attachment; filename="X.mkv"` / `filename*=UTF-8''X.mkv`m = re.search(r"filename\*?=(?:UTF-8'')?\"?([^\";]+)\"?", v)cand = m.group(1).strip() if m else vif "." in cand and len(cand) < 200:return candbase = (sp.path or "").rsplit("/", 1)[-1]if base and "." in base:stem = base.rsplit(".", 1)[0]if re.fullmatch(r"[0-9a-fA-F]{16,64}", stem):return "" # content-hash only - no episode inforeturn baseexcept Exception:passreturn ""async def _sf_resolve_hubcloud(client: httpx.AsyncClient, link: str) -> list:"""Resolve one hubcloud-family page into direct file URLs."""out = []12 unmodified linesu = b.group(1)chunk = page[b.start():b.start() + 800]fm = re.search(r'download="([^"]{5,110})"', chunk)fname = (fm.group(1) if fm else "") or _sf_fname_from_url(u)if "pixeldrain" in u:out.append({"url": _sf_pixeldrain_direct(u), "label": fname or "Direct"})elif any(u.endswith(ext) or f"{ext}?" in u for ext in (".mkv", ".mp4")) and ".zip" not in u:45 unmodified linesresults = []seen_urls = set()for r in resolved:u, label = r["url"], (r.get("label") or "")if u in seen_urls:continueseen_urls.add(u)# Real label = download-attr name or a name recovered from the URL.# "Direct"/"" means UNVERIFIABLE - for TV that is dangerous (the file# can be any episode of any season: this served S05E01 for S01E01 and# the same pixeldrain file for two different shows). Serving nothing# is honest - the player falls back to its next source.eff = label if (label and label != "Direct") else _sf_fname_from_url(u)if media_type == "tv":if not eff:continue # unnamed file - episode cannot be verifiedif not _sf_episode_matches(eff, season or 1, episode or 1):continueresults.append(_sf_stream_result(f"{source_name}/HubCloud", f"{source_name} - {eff or 'Direct'}", u,quality=_sf_quality_from_name(eff), language=_sf_lang_from_name(eff)))return results994 unmodified linesu = b.group(1)chunk = page[b.start():b.start() + 800]fm = re.search(r'download="([^"]{5,110})"', chunk)fname = (fm.group(1) if fm else "") or _sf_fname_from_url(u) or "Direct"if "pixeldrain" in u:out.append({"url": _sf_pixeldrain_direct(u), "label": fname})elif "cloudflarestorage" in u or "workers.dev" in u or ".r2.dev" in u or "googleusercontent" in u:
main.py+51-7