Same disabled-Account double-count bug as yt-long: cap/uploaded ignored channel switches. Co-authored-by: Cursor <cursoragent@cursor.com>
72 lines
2.3 KiB
Python
72 lines
2.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Deploy Shorts enabled-only totals fix to dy + dylive."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
PASS = "Xiao4669805"
|
|
JUMP = "107.173.30.245"
|
|
DY = "108.174.50.68"
|
|
|
|
SH = r'''
|
|
set -e
|
|
install -D -m 644 /tmp/_shorts_page.tsx /opt/douyinWEB/frontend/src/app/shorts/page.tsx
|
|
grep -n "Only \*\*enabled\*\* channels" /opt/douyinWEB/frontend/src/app/shorts/page.tsx | head -3
|
|
cd /opt/douyinWEB/frontend && npm run build 2>&1 | tail -18
|
|
systemctl restart douyinweb-web
|
|
sleep 2
|
|
systemctl is-active douyinweb-web
|
|
echo HOST_DONE
|
|
'''
|
|
|
|
|
|
def wait(c, path, rounds=100):
|
|
out = ""
|
|
for i in range(rounds):
|
|
time.sleep(3)
|
|
_, o, _ = c.exec_command(f"tail -c 12000 {path} 2>/dev/null", timeout=15)
|
|
out = o.read().decode("utf-8", "replace")
|
|
if "HOST_DONE" in out and "EXIT:" in out:
|
|
return out
|
|
if i % 5 == 0:
|
|
print("poll", i, out[-100:].replace("\n", " | "), flush=True)
|
|
return out
|
|
|
|
|
|
def main():
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(JUMP, 22, "root", PASS, timeout=40, allow_agent=False, look_for_keys=False)
|
|
data = (ROOT / "frontend/src/app/shorts/page.tsx").read_bytes().replace(b"\r\n", b"\n")
|
|
sftp = c.open_sftp()
|
|
with sftp.file("/tmp/_shorts_page.tsx", "wb") as f:
|
|
f.write(data)
|
|
with sftp.file("/tmp/_shorts_fix.sh", "w") as f:
|
|
f.write(SH)
|
|
sftp.close()
|
|
print("===== dylive =====", flush=True)
|
|
c.exec_command(
|
|
"bash /tmp/_shorts_fix.sh > /tmp/_shorts_dylive.out 2>&1; echo EXIT:$? >> /tmp/_shorts_dylive.out",
|
|
timeout=1,
|
|
)
|
|
print(wait(c, "/tmp/_shorts_dylive.out")[-6000:], flush=True)
|
|
print("===== dy =====", flush=True)
|
|
c.exec_command(
|
|
f"SSHPASS={PASS} sshpass -e scp -o StrictHostKeyChecking=no /tmp/_shorts_page.tsx /tmp/_shorts_fix.sh root@{DY}:/tmp/ && "
|
|
f"SSHPASS={PASS} sshpass -e ssh -o StrictHostKeyChecking=no root@{DY} "
|
|
f"'bash /tmp/_shorts_fix.sh' > /tmp/_shorts_dy.out 2>&1; echo EXIT:$? >> /tmp/_shorts_dy.out",
|
|
timeout=1,
|
|
)
|
|
print(wait(c, "/tmp/_shorts_dy.out")[-6000:], flush=True)
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|