# -*- coding: utf-8 -*- """More detail on ypp assign + oauth settings vs dy.""" from __future__ import annotations import sys import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") YPP_PROBE = r""" import sqlite3, json conn = sqlite3.connect('/opt/douyinWEB/backend/data/monitor.db') conn.row_factory = sqlite3.Row # assign groups full for r in conn.execute('SELECT * FROM yt_assign_groups').fetchall(): d=dict(r) sk=str(d.get('stream_key') or '') d['stream_key']=sk if sk else '' print('ASSIGN', json.dumps(d, ensure_ascii=False)) # rooms count + ids print('ROOMS', conn.execute('SELECT count(*) FROM rooms').fetchone()[0]) print('ROOM_IDS', sorted(r[0] for r in conn.execute('SELECT room_id FROM rooms').fetchall())) # oauth related settings full (secrets included for migration) keys = [ 'shorts_oauth_client_id','shorts_oauth_client_secret','shorts_oauth_profiles', 'shorts_oauth_redirect_uri','shorts_oauth_brand_hints', 'tiktok_oauth_client_key','tiktok_oauth_client_secret','tiktok_oauth_redirect_uri', ] for k in keys: row = conn.execute('SELECT value FROM kv_settings WHERE key=?',(k,)).fetchone() print('KV', k, (row[0] if row else None)) # shorts full secrets for r in conn.execute('SELECT * FROM shorts_channels').fetchall(): d=dict(r) print('SC_FULL', json.dumps({k:d.get(k) for k in ['id','name','youtube_channel_id','client_id','client_secret','refresh_token','enabled','daily_min','daily_max','title_template','description_template','privacy','note','oauth_ok','oauth_profile_id','upload_priority']}, ensure_ascii=False)) for r in conn.execute('SELECT * FROM yt_long_channels').fetchall(): d=dict(r) print('YL_FULL', json.dumps({k:d.get(k) for k in ['id','name','youtube_channel_id','oauth_profile_id','client_id','client_secret','refresh_token','enabled','daily_max','title_template','description_template','privacy','note','source_shorts_channel_pk','ypp_ok','monetize_default','upload_priority']}, ensure_ascii=False)) """ DY_PROBE = r""" import sqlite3, json conn = sqlite3.connect('/opt/douyinWEB/backend/data/monitor.db') conn.row_factory = sqlite3.Row print('ROOMS', conn.execute('SELECT count(*) FROM rooms').fetchone()[0]) print('ROOM_IDS', sorted(r[0] for r in conn.execute('SELECT room_id FROM rooms').fetchall())) print('SC_COUNT', conn.execute('SELECT count(*) FROM shorts_channels').fetchone()[0]) for r in conn.execute('SELECT id,name,youtube_channel_id,oauth_profile_id,oauth_ok,length(coalesce(refresh_token,\"\")) rt FROM shorts_channels').fetchall(): print('SC', dict(r)) print('YL_COUNT', conn.execute('SELECT count(*) FROM yt_long_channels').fetchone()[0]) for r in conn.execute('SELECT id,name,youtube_channel_id,oauth_profile_id,length(coalesce(refresh_token,\"\")) rt FROM yt_long_channels').fetchall(): print('YL', dict(r)) for r in conn.execute('SELECT id,name,youtube_channel_id,length(coalesce(stream_key,\"\")) sk,channel_pk FROM yt_assign_groups').fetchall(): print('AG', dict(r)) for k in ['shorts_oauth_client_id','shorts_oauth_profiles','shorts_oauth_redirect_uri']: row=conn.execute('SELECT value FROM kv_settings WHERE key=?',(k,)).fetchone() v=(row[0] if row else '')[:300] print('KV', k, v) """ def run(host, password, script, label): print("=" * 40, label) c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(host, 22, "root", password, timeout=45, allow_agent=False, look_for_keys=False) sftp = c.open_sftp() with sftp.file("/tmp/_probe2.py", "w") as f: f.write(script) sftp.close() _, o, e = c.exec_command("cd /opt/douyinWEB/backend && .venv/bin/python /tmp/_probe2.py 2>&1", timeout=120) print(o.read().decode("utf-8", "replace")) err = e.read().decode("utf-8", "replace") if err.strip(): print("ERR", err) c.close() run("192.227.152.110", "Leaf448772566", YPP_PROBE, "YPP") run("108.174.50.68", "Xiao4669805", DY_PROBE, "DY")