douyinWEB/scripts/_diag_4key.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

53 lines
2.2 KiB
Python

# -*- coding: utf-8 -*-
import sys, paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
REMOTE = r"""
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
cd /opt/douyinWEB/backend && .venv/bin/python3 <<'PY'
from app import yt_assign_db, db
groups = yt_assign_db.list_groups(include_urls=False, include_secret=True)
print('=== ALL enabled groups with stream key ===')
keyed = []
for g in groups:
sk = bool(str(g.get('stream_key') or '').strip())
if not sk:
continue
keyed.append(g)
pk = str(g.get('channel_pk') or '')
ch = db.get_shorts_channel(pk) if pk else None
yt_group = str(g.get('youtube_channel_id') or '')
yt_shorts = str(ch.get('youtube_channel_id') or '') if ch else ''
ch_key = yt_assign_db._group_yt_channel_key(g)
print(f"{g.get('name')} enabled={g.get('enabled')} neko={g.get('neko_instance_id')}")
print(f" group_id={g.get('id')[:8]}")
print(f" group yt_id={yt_group}")
print(f" shorts yt_id={yt_shorts} name={ch.get('name') if ch else 'N/A'} handle={ch.get('handle') if ch else ''}")
print(f" channel_pk={pk[:8]}...")
print(f" dedupe_key={ch_key}")
print(f" key_prefix={str(g.get('stream_key') or '')[:12]}")
print()
print('=== dedupe buckets ===')
from app.yt_assign_db import _dedupe_groups_by_yt_channel
enabled_keyed = [g for g in keyed if g.get('enabled')]
rows = _dedupe_groups_by_yt_channel(enabled_keyed)
for canon, aliases in rows:
print(f"SLOT: {canon.get('name')} yt={canon.get('youtube_channel_id')} aliases={len(aliases)}")
sched = yt_assign_db.build_rotation_schedule(include_urls=False, keyed_only=True)
print('\n=== schedule ===')
print('channel_count', sched.get('channel_count'), 'slot_hours', sched.get('slot_hours'))
for c in sched.get('channels') or []:
print(c.get('start_label'), c.get('end_label'), c.get('name'), 'yt', c.get('youtube_channel_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,_=c.exec_command(REMOTE,timeout=90)
print(o.read().decode())
c.close()