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 lines41741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645712 unmodified lines47047147243847347447547645 unmodified lines522523524490525526527528529530531532533534535536537494495538539540497498541542543544545994 unmodified lines15401541154214991543154415451546416 unmodified lines return u
def _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 human readable name lives in `response-content-disposition=<File.Name.mkv>` (or as the /hub2/<File.Name.mkv> path basename). Without the filename the episode filter sees label="Direct" and passes EVERYTHING - that is the wrong-episode bug (S05E01 served for an S01E01 request). r2.dev content hashes / pixeldrain ids carry no name at all -> "" (unverifiable).""" try: from urllib.parse import urlsplit, parse_qs sp = 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 v if "." in cand and len(cand) < 200: return cand base = (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 info return base except Exception: pass return ""
async def _sf_resolve_hubcloud(client: httpx.AsyncClient, link: str) -> list: """Resolve one hubcloud-family page into direct file URLs.""" out = []12 unmodified lines u = 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 "" 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 lines results = [] seen_urls = set() for r in resolved: u, label = r["url"], r["label"] u, label = r["url"], (r.get("label") or "") if u in seen_urls: continue seen_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 verified if media_type == "tv" and not _sf_episode_matches(label, season or 1, episode or 1): continue if not _sf_episode_matches(eff, season or 1, episode or 1): continue results.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))) f"{source_name}/HubCloud", f"{source_name} - {eff or 'Direct'}", u, quality=_sf_quality_from_name(eff), language=_sf_lang_from_name(eff))) return results
994 unmodified lines u = 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" 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