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>
62 lines
2.2 KiB
Python
62 lines
2.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
import sys
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
REMOTE = r'''
|
|
import pickle, secrets, string
|
|
from pathlib import Path
|
|
import requests
|
|
p = Path("/opt/douyinWEB/backend/data/tiktok_cookies")
|
|
f = next(p.glob("*.cookie"))
|
|
data = pickle.load(f.open("rb"))
|
|
sid = next((x["value"] for x in data if x.get("name") == "sessionid"), "")
|
|
dc = next((x["value"] for x in data if x.get("name") == "tt-target-idc"), "")
|
|
print("sid_len", len(sid), "dc", dc)
|
|
seen = []
|
|
for d in [dc, "useast2a", "useast1a", "useast5a", "euwest1a", "alisg"]:
|
|
if not d or d in seen:
|
|
continue
|
|
seen.append(d)
|
|
s = requests.Session()
|
|
s.cookies.set("sessionid", sid, domain=".tiktok.com")
|
|
s.cookies.set("sessionid_ss", sid, domain=".tiktok.com")
|
|
s.cookies.set("tt-target-idc", d, domain=".tiktok.com")
|
|
s.headers.update({
|
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
|
"Accept": "application/json, text/plain, */*",
|
|
})
|
|
cid = "".join(secrets.choice(string.ascii_letters + string.digits + "_") for _ in range(21))
|
|
url = "https://www.tiktok.com/api/v1/web/project/create/?creation_id=%s&type=1&aid=1988" % cid
|
|
r = s.post(url, timeout=20)
|
|
try:
|
|
j = r.json()
|
|
except Exception:
|
|
print(d, "http", r.status_code, "not_json")
|
|
continue
|
|
print(
|
|
"dc", d,
|
|
"http", r.status_code,
|
|
"status_code", j.get("status_code"),
|
|
"has_project", "project" in j,
|
|
"msg", str(j.get("status_msg") or "")[:80],
|
|
"keys", sorted(j.keys()),
|
|
)
|
|
'''
|
|
|
|
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_tt_project.py", "w") as f:
|
|
f.write(REMOTE)
|
|
sftp.close()
|
|
_s, out, err = c.exec_command("/opt/douyinWEB/backend/.venv/bin/python /tmp/_probe_tt_project.py", timeout=60)
|
|
print(out.read().decode("utf-8", "replace"))
|
|
e = err.read().decode("utf-8", "replace")
|
|
if e:
|
|
print("ERR:", e[:800])
|
|
c.exec_command("rm -f /tmp/_probe_tt_project.py")
|
|
c.close()
|