Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP. Co-authored-by: Cursor <cursoragent@cursor.com>
102 lines
4.1 KiB
Python
102 lines
4.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Compare .com vs .cn youtube page assets / cache / picker presence."""
|
|
from __future__ import annotations
|
|
|
|
import hashlib
|
|
import re
|
|
import sys
|
|
|
|
import httpx
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
URLS = [
|
|
"https://dy.nomadro.com/youtube",
|
|
"https://dy.nomadro.cn/youtube",
|
|
"https://dy.nomadro.com/api/health",
|
|
"https://dy.nomadro.cn/api/health",
|
|
]
|
|
|
|
|
|
def main():
|
|
with httpx.Client(follow_redirects=True, timeout=30, verify=True) as c:
|
|
for url in URLS:
|
|
r = c.get(url)
|
|
print(f"\n=== {url} ===")
|
|
print("status", r.status_code, "len", len(r.content))
|
|
for h in (
|
|
"cache-control",
|
|
"age",
|
|
"via",
|
|
"cf-cache-status",
|
|
"x-cache",
|
|
"server",
|
|
"content-type",
|
|
"etag",
|
|
"last-modified",
|
|
):
|
|
if h in r.headers:
|
|
print(f" {h}: {r.headers[h]}")
|
|
if "api/health" in url:
|
|
print(" body", r.text[:200])
|
|
continue
|
|
# extract script chunks
|
|
scripts = re.findall(r'src="(/_next/static/[^"]+)"', r.text)
|
|
print(" scripts", len(scripts), scripts[:6])
|
|
# hash of html
|
|
print(" html_sha8", hashlib.sha256(r.content).hexdigest()[:8])
|
|
# fetch first page chunk that might contain youtube
|
|
for s in scripts:
|
|
if "page" in s or "youtube" in s or "app" in s:
|
|
pass
|
|
# pull build id
|
|
m = re.search(r"/_next/static/([^/]+)/_buildManifest", r.text)
|
|
if m:
|
|
print(" buildId", m.group(1))
|
|
else:
|
|
m2 = re.search(r'"buildId":"([^"]+)"', r.text)
|
|
print(" buildId", m2.group(1) if m2 else "?")
|
|
|
|
# compare a shared chunk if same build
|
|
r1 = c.get("https://dy.nomadro.com/youtube")
|
|
r2 = c.get("https://dy.nomadro.cn/youtube")
|
|
scripts1 = set(re.findall(r'src="(/_next/static/[^"]+)"', r1.text))
|
|
scripts2 = set(re.findall(r'src="(/_next/static/[^"]+)"', r2.text))
|
|
print("\n=== script set equal ===", scripts1 == scripts2)
|
|
print("only_com", sorted(scripts1 - scripts2)[:10])
|
|
print("only_cn", sorted(scripts2 - scripts1)[:10])
|
|
|
|
# fetch youtube page chunk and search AuthorizedChannelPicker / 选择已授权
|
|
for base in ("https://dy.nomadro.com", "https://dy.nomadro.cn"):
|
|
html = c.get(f"{base}/youtube").text
|
|
# static page data
|
|
chunks = re.findall(r'/_next/static/chunks/[^"]+\.js', html)
|
|
# also try buildManifest pages
|
|
found = False
|
|
needle = "AuthorizedChannelPicker"
|
|
needle2 = "选择已授权频道"
|
|
# search in page-specific: look for app/youtube
|
|
for path in re.findall(r'src="(/_next/static/chunks/app/youtube/[^"]+)"', html):
|
|
body = c.get(base + path).text
|
|
hit = needle in body or "YtChannelProfileSnippet" in body or "ChevronDown" in body
|
|
print(f"{base} {path} len={len(body)} hit_pickerish={hit} has_select_option={('<option' in body)}")
|
|
found = True
|
|
if not found:
|
|
# fallback: any chunk mentioning 选择已授权
|
|
for path in chunks:
|
|
body = c.get(base + path).text
|
|
if needle2 in body or needle in body:
|
|
print(f"{base} FOUND in {path} picker={needle in body} text={needle2 in body}")
|
|
found = True
|
|
break
|
|
if not found:
|
|
print(f"{base} no youtube chunk in html; scanning all linked chunks…")
|
|
for path in chunks:
|
|
body = c.get(base + path).text
|
|
if "选择已授权" in body:
|
|
print(f" {path} contains 选择已授权; has AuthorizedChannelPicker={needle in body}; has <option={('<option' in body)}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|