# -*- coding: utf-8 -*- """Deploy OAuth refresh_token fix + recreate channel A + set DY_PUBLIC_BASE_URL.""" from __future__ import annotations import json import sys import time from pathlib import Path import httpx import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") ROOT = Path(__file__).resolve().parents[1] FILES = { "shorts_oauth.py": ROOT / "backend" / "app" / "shorts_oauth.py", } VPS = "107.173.30.245" GUEST_PORT, GUEST_USER, GUEST_PASS = 4014, "eric", "4669805" SECRET = "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" CID = "685779248822-dnrq7043r03rlviktjhr8orre8e273gc.apps.googleusercontent.com" def main(): g = paramiko.SSHClient() g.set_missing_host_key_policy(paramiko.AutoAddPolicy()) g.connect(VPS, GUEST_PORT, GUEST_USER, GUEST_PASS, timeout=40, banner_timeout=80, allow_agent=False, look_for_keys=False) sftp = g.open_sftp() sftp.put(str(FILES["shorts_oauth.py"]), "/tmp/_up_shorts_oauth.py") sftp.close() remote = rf""" echo '{GUEST_PASS}' | sudo -S -p '' bash -lc ' set -e install -m 644 /tmp/_up_shorts_oauth.py /opt/douyinWEB/backend/app/shorts_oauth.py # ensure public base for OAuth redirects API=/etc/systemd/system/douyinweb-api.service grep -q DY_PUBLIC_BASE_URL=https://dy.nomadro.com "$API" || \ sed -i "/\[Service\]/a Environment=DY_PUBLIC_BASE_URL=https://dy.nomadro.com" "$API" systemctl daemon-reload systemctl restart douyinweb-api sleep 2 cd /opt/douyinWEB/backend .venv/bin/python - <