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>
55 lines
2.0 KiB
Python
55 lines
2.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
REMOTE = r"""
|
|
import asyncio, json
|
|
from app import db
|
|
from app.shorts_oauth import channel_oauth_creds
|
|
from app.shorts_upload import refresh_access_token
|
|
import httpx
|
|
from app.shorts_upload import _client_kwargs
|
|
|
|
async def main():
|
|
target = None
|
|
for ch in db.list_shorts_channels(enabled=None):
|
|
if "nomad vlog" in str(ch.get("name") or "").lower():
|
|
target = ch
|
|
break
|
|
print("channel", target.get("name"), "yt_id", target.get("youtube_channel_id"))
|
|
creds = channel_oauth_creds(target)
|
|
access = await refresh_access_token(
|
|
client_id=str(creds["client_id"]),
|
|
client_secret=str(creds["client_secret"]),
|
|
refresh_token=str(creds["refresh_token"]),
|
|
)
|
|
async with httpx.AsyncClient(**_client_kwargs(timeout=45.0)) as client:
|
|
r = await client.get(
|
|
"https://www.googleapis.com/youtube/v3/videos",
|
|
params={"part": "status,snippet,contentDetails", "id": "ch1MMlZMfU0"},
|
|
headers={"Authorization": f"Bearer {access}"},
|
|
)
|
|
print("video", r.status_code, json.dumps(r.json(), ensure_ascii=False)[:800])
|
|
r2 = await client.get(
|
|
"https://www.googleapis.com/youtube/v3/channels",
|
|
params={"part": "id,snippet", "mine": "true"},
|
|
headers={"Authorization": f"Bearer {access}"},
|
|
)
|
|
print("mine", json.dumps(r2.json(), ensure_ascii=False)[:400])
|
|
|
|
asyncio.run(main())
|
|
"""
|
|
|
|
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)
|
|
_, out, err = c.exec_command(f"cd /opt/douyinWEB/backend && .venv/bin/python - <<'PY'\n{REMOTE}\nPY", timeout=90)
|
|
print(out.read().decode("utf-8", "replace"))
|
|
if err.read().decode().strip():
|
|
print("ERR", err.read().decode()[:500])
|
|
c.close()
|