douyinWEB/scripts/_probe_picker_on_edges.py
eric d409e416da Ship physical dual-edge stack, Studio CDP live metrics, and ops tooling.
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>
2026-09-04 22:42:40 -05:00

80 lines
2.9 KiB
Python

# -*- coding: utf-8 -*-
"""Search served JS on .com/.cn for channel picker markers."""
from __future__ import annotations
import re
import sys
import httpx
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
NEEDLES = [
"AuthorizedChannelPicker", # may be stripped
"选择已授权频道",
"YtChannelProfileSnippet",
"aria-haspopup",
"listbox",
]
def check(base: str):
print(f"\n===== {base} =====")
with httpx.Client(follow_redirects=True, timeout=40) as c:
# unauthenticated /youtube may redirect login on .com; try with cookie bypass by fetching static chunk list from build
r = c.get(f"{base}/youtube")
print("html", r.status_code, len(r.content), "set-cookie", bool(r.headers.get("set-cookie")))
html = r.text
# find all next static refs including RSC flight
paths = sorted(set(re.findall(r"/_next/static/[^\"'\s)]+", html)))
print("static refs", len(paths))
# also try known youtube page path from earlier
extra = [
"/_next/static/chunks/app/youtube/page-7a6c91c3bf577da9.js",
"/_next/static/chunks/933-63b960ae3cfdcfdb.js",
"/_next/static/chunks/647-0fe1b0d631b25b8f.js",
]
for p in paths + extra:
if not p.endswith(".js"):
continue
try:
body = c.get(base + p).text
except Exception as e:
print(" fail", p, e)
continue
hits = [n for n in NEEDLES if n in body]
# also native select leftover pattern
native = "选择已授权频道…" in body and "<option" in body
if hits or native or "选择已授权" in body:
print(f" {p} len={len(body)} hits={hits} native_selectish={native}")
def main():
for base in ("https://dy.nomadro.cn", "https://dy.nomadro.com"):
check(base)
# also read directly from guest filesystem via FRP
import paramiko
g = paramiko.SSHClient()
g.set_missing_host_key_policy(paramiko.AutoAddPolicy())
g.connect("107.173.30.245", 4014, "eric", "4669805", timeout=45, allow_agent=False, look_for_keys=False)
cmd = r"""
echo '4669805' | sudo -S -p '' bash -lc '
grep -R "选择已授权频道" /opt/douyinWEB/frontend/.next/static/chunks 2>/dev/null | head -20
echo ---
grep -R "AuthorizedChannelPicker\|aria-haspopup" /opt/douyinWEB/frontend/.next/static/chunks 2>/dev/null | head -10
echo ---
# source file on disk
grep -n AuthorizedChannelPicker /opt/douyinWEB/frontend/src/components/YtAssignPanel.tsx | head
ls -la /opt/douyinWEB/frontend/.next/BUILD_ID 2>/dev/null; cat /opt/douyinWEB/frontend/.next/BUILD_ID 2>/dev/null
'
"""
_, o, e = g.exec_command(cmd, timeout=60)
print("\n===== physical disk =====")
print((o.read() + e.read()).decode("utf-8", "replace")[-4000:])
g.close()
if __name__ == "__main__":
main()