douyinWEB/scripts/_fix_dup_nomadvps.py
eric d409e416da Ship physical dual-edge stack, Studio CDP live metrics, and ops tooling.
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>
2026-09-04 22:42:40 -05:00

60 lines
2.3 KiB
Python

# -*- coding: utf-8 -*-
"""Disable duplicate nomadvps group (Neko #7) and verify 3-slot schedule."""
import json
import sys
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
DUPLICATE_GID = "1cc3e3f0-02cf-4216-9780-d5015f338a6e"
KEEP_GID = "6c42de20-1577-40c4-bd7b-c2cf0005dd77"
REMOTE = rf"""
set -e
curl -sS -c /tmp/dy.ck -X POST https://dy.nomadro.live/api/auth/login \
-H 'Content-Type: application/json' \
-d '{{"username":"hackrobot","password":"Xiao4669805@"}}' >/dev/null
echo '=== before ==='
curl -sS -b /tmp/dy.ck 'https://dy.nomadro.live/api/youtube/assign/schedule' | python3 -c "
import json,sys
s=json.load(sys.stdin)
print('channel_count', s.get('channel_count'), 'slot_hours', s.get('slot_hours'))
for c in s.get('channels') or []:
print(c.get('start_label'), c.get('end_label'), c.get('name'), c.get('group_id')[:8], 'active', c.get('active'))
"
echo '=== disable duplicate nomadvps (neko 7) ==='
curl -sS -b /tmp/dy.ck -X PATCH "https://dy.nomadro.live/api/youtube/assign/groups/{DUPLICATE_GID}" \
-H 'Content-Type: application/json' \
-d '{{"enabled": false, "neko_enabled": false, "note": "duplicate nomadvps; disabled 2026-09-01"}}' \
-o /tmp/patch.json
python3 -c "import json; print(json.load(open('/tmp/patch.json')).get('enabled', 'ERR'))"
echo '=== after ==='
curl -sS -b /tmp/dy.ck 'https://dy.nomadro.live/api/youtube/assign/schedule' | python3 -c "
import json,sys
s=json.load(sys.stdin)
print('channel_count', s.get('channel_count'), 'slot_hours', s.get('slot_hours'))
for c in s.get('channels') or []:
print(c.get('start_label'), c.get('end_label'), c.get('name'), c.get('group_id')[:8], 'active', c.get('active'))
"
cd /opt/douyinWEB/backend && .venv/bin/python3 <<'PY'
from app import yt_assign_db
for gid in ['{KEEP_GID}', '{DUPLICATE_GID}']:
g = yt_assign_db.get_group(gid) or {{}}
print(g.get('name'), gid[:8], 'enabled', g.get('enabled'), 'neko', g.get('neko_instance_id'))
PY
"""
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("108.174.50.68", 22, "root", "Xiao4669805", timeout=60, allow_agent=False, look_for_keys=False)
_, o, e = c.exec_command(REMOTE, timeout=120)
print(o.read().decode())
err = e.read().decode()
if err:
print("STDERR:", err, file=sys.stderr)
c.close()