douyinWEB/scripts/probe_cover_speed.py
eric 47d17aee3c Document YouTube groups and Shorts side-path; sync dual-platform pipeline.
Add isolated Shorts OAuth/clip/upload worker (default off), youtube-svc + group poller, Beijing time UX, and SHORTS.md.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-10 00:04:06 -05:00

51 lines
1.9 KiB
Python

# -*- coding: utf-8 -*-
import paramiko
SCRIPT = r'''
import json, urllib.request, time
raw = urllib.request.urlopen("http://127.0.0.1:8014/api/sessions?limit=5").read()
d = json.loads(raw)
for s in (d.get("sessions") or [])[:4]:
cu = (s.get("cover_url") or "")
cp = (s.get("cover_path") or "")
print("ID", s.get("id"))
print(" path", cp[:110])
print(" url ", cu[:110])
if cu.startswith("http"):
try:
req = urllib.request.Request(cu, method="HEAD")
with urllib.request.urlopen(req, timeout=8) as r:
print(" HEAD", r.status, r.headers.get("Content-Type"), r.headers.get("Content-Length"))
except Exception as e:
print(" HEAD_ERR", type(e).__name__, str(e)[:160])
t0 = time.time()
try:
with urllib.request.urlopen(cu, timeout=15) as r:
body = r.read()
print(" DIRECT", r.status, len(body), "%dms" % int((time.time() - t0) * 1000))
except Exception as e:
print(" DIRECT_ERR", type(e).__name__, str(e)[:160])
t0 = time.time()
try:
with urllib.request.urlopen("http://127.0.0.1:8014/api/sessions/%s/cover" % s["id"], timeout=15) as r:
body = r.read()
print(" PROXY", r.status, len(body), "%dms" % int((time.time() - t0) * 1000))
except Exception as e:
print(" PROXY_ERR", type(e).__name__, str(e)[:160])
print("---")
'''
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False)
sftp = c.open_sftp()
with sftp.file("/tmp/probe_cover_speed.py", "w") as f:
f.write(SCRIPT)
sftp.close()
stdin, stdout, stderr = c.exec_command("python3 /tmp/probe_cover_speed.py", timeout=90)
print(stdout.read().decode("utf-8", "replace"))
err = stderr.read().decode("utf-8", "replace")
if err:
print("ERR", err[-1000:])
c.close()