| import json, re, urllib.parse, urllib.request, urllib.error |
|
|
| BASE = 'http://127.0.0.1:5001' |
| UA = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/126 Safari/537.36'} |
|
|
| def req(url, timeout=120): |
| r = urllib.request.Request(url, headers=UA) |
| try: |
| with urllib.request.urlopen(r, timeout=timeout) as resp: |
| return resp.status, dict(resp.headers), resp.read() |
| except urllib.error.HTTPError as e: |
| return e.code, dict(e.headers), e.read() |
| except Exception as e: |
| return 0, {}, str(e).encode() |
|
|
| def first_rewritten(text): |
| for ln in text.splitlines(): |
| if '/api/stream-proxy' in ln and ln.strip(): |
| return ln if ln.startswith('http') else f'{BASE}{ln}' |
| return None |
|
|
| |
| q = urllib.parse.urlencode({'url': 'https://playeng.animeapps.top/r2/cachehd/5114ebd1/index.m3u8', 'ref': 'https://playeng.animeapps.top/'}) |
| st, hd, master = req(f'{BASE}/api/stream-proxy?{q}') |
| print('1) master:', st, hd.get('Content-Type')) |
| mt = master.decode('utf-8', 'replace') |
|
|
| |
| v = first_rewritten(mt) |
| st, hd, var = req(v) |
| print('2) variant:', st, hd.get('Content-Type'), len(var), 'bytes') |
| vt = var.decode('utf-8', 'replace') |
|
|
| |
| seg_line = None |
| for ln in vt.splitlines(): |
| t = ln.strip() |
| if t and not t.startswith('#') and ('.ts' in t or '/api/stream-proxy' in t): |
| seg_line = t |
| break |
| if seg_line: |
| seg_url = seg_line if seg_line.startswith('http') else f'{BASE}{seg_line}' |
| st, hd, seg = req(seg_url) |
| ct = hd.get('Content-Type') or '' |
| print(f'3) SEGMENT: st={st} ctype={ct} bytes={len(seg)}') |
| |
| if st == 200 and len(seg) > 10000: |
| sync = seg[0] == 0x47 or (b'\x47' in seg[:64]) |
| print(f' TS sync byte present: {sync}') |
| print(' => REAL VIDEO FLOWS THROUGH THE PROXY' if sync else ' => bytes flow but not TS (may be mp4/fmp4)') |
| else: |
| print(f' segment fetch failed: {seg[:150]!r}') |
| else: |
| print('3) no segment line found in variant playlist') |
| print(' playlist head:', vt[:400]) |
|
|
| |
| q2 = urllib.parse.urlencode({'anime_id': 5114, 'episode_number': 1, 'language': 'sub', 'provider': 'anikoto'}) |
| st, hd, body = req(f'{BASE}/api/watch/sources?{q2}') |
| print('\n4) (anikoto sources via GET is wrong method; skip)') |
|
|