Stop spamming upstream: drop video download from probe, kill re-rolls
- CDN probe no longer downloads 64KB of video (or even a variant playlist): one small master-playlist fetch proves reachability. State stays OK/DEGRADED, kbps is no longer measured, and the pill/ panel only show a rate when one exists. - hianime: 5x getSourcesNew re-roll -> 1 attempt. The enc payload is deterministic per data-id (observed identical across calls), so re-rolling only hammered the provider. - anikoto: 2x re-roll -> 1 attempt per server, same reason. Kept: idle-gated + 30-min degraded backoff from the previous commit, the single _get retry (protects real user playback from CF blips), and the origin page check (the 'down' signal). Net upstream traffic is now what an actual viewer would generate, nothing more.
This commit is contained in:
1 parent
1154203569
commit
e3ef51d141
4 files changed
+43
-53
No files matched your search
@@ -117,15 +117,16 @@ def _master_m3u8(ep_id, lang="eng"):
|
||||
url = (d.get("result") or {}).get("url")
|
||||
if not url:
|
||||
continue
|
||||
for _ in range(2): # re-roll: CDN domains rotate, most 403 our IP
|
||||
try:
|
||||
f = _player_file(url)
|
||||
if not f:
|
||||
break
|
||||
_get(f, timeout=10) # prove this CDN serves us before committing
|
||||
return f
|
||||
except Exception as ex:
|
||||
errs.append(str(ex)[:60])
|
||||
# ponytail: one attempt per server — the enc payload is deterministic,
|
||||
# re-rolling would just spam the provider
|
||||
try:
|
||||
f = _player_file(url)
|
||||
if not f:
|
||||
break
|
||||
_get(f, timeout=10) # prove this CDN serves us before committing
|
||||
return f
|
||||
except Exception as ex:
|
||||
errs.append(str(ex)[:60])
|
||||
raise RuntimeError("anikoto: no working server: " + "; ".join(errs[:3]))
|
||||
|
||||
|
||||
|
||||
+15
-14
@@ -105,21 +105,22 @@ def _embed_payload(embed):
|
||||
if not mid:
|
||||
return None, [], None
|
||||
host = re.match(r'https?://([^/]+)', embed).group(1)
|
||||
for _ in range(5):
|
||||
d = megaplay_sources(_get(f"https://{host}/stream/getSourcesNew?id={mid.group(1)}",
|
||||
headers={"Referer": embed, "X-Requested-With": "XMLHttpRequest"},
|
||||
timeout=15).json())
|
||||
src = (d.get("sources") or {}).get("file")
|
||||
if not src:
|
||||
# ponytail: one attempt — the enc payload is deterministic per data-id,
|
||||
# so re-rolling getSourcesNew would just spam the provider
|
||||
d = megaplay_sources(_get(f"https://{host}/stream/getSourcesNew?id={mid.group(1)}",
|
||||
headers={"Referer": embed, "X-Requested-With": "XMLHttpRequest"},
|
||||
timeout=15).json())
|
||||
src = (d.get("sources") or {}).get("file")
|
||||
if not src:
|
||||
return None, [], None
|
||||
subs = [{"label": (x or {}).get("label", ""), "src": (x or {}).get("file")}
|
||||
for x in d.get("tracks") or []]
|
||||
for cand, refr in (({"Referer": embed}, embed), ({}, None)):
|
||||
try:
|
||||
_get(src, headers=cand, timeout=10)
|
||||
return src, subs, refr
|
||||
except Exception:
|
||||
continue
|
||||
subs = [{"label": (x or {}).get("label", ""), "src": (x or {}).get("file")}
|
||||
for x in d.get("tracks") or []]
|
||||
for cand, refr in (({"Referer": embed}, embed), ({}, None)):
|
||||
try:
|
||||
_get(src, headers=cand, timeout=10)
|
||||
return src, subs, refr
|
||||
except Exception:
|
||||
continue
|
||||
return None, [], None
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user