# -*- 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={('