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

48 lines
1.8 KiB
Python

# -*- coding: utf-8 -*-
"""Check dylive + physical for nomdfs dupes; also probe board API shape."""
from __future__ import annotations
import json
import sys
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
def run(host, port, user, pw, label, db_path):
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(host, port, user, pw, timeout=45, allow_agent=False, look_for_keys=False)
remote = f"""
import sqlite3
con=sqlite3.connect({db_path!r}); con.row_factory=sqlite3.Row
print('LABEL', {label!r})
print('shorts nomdfs')
for r in con.execute("SELECT id,name,youtube_channel_id,oauth_profile_id,enabled FROM shorts_channels WHERE name LIKE '%nomdfs%' OR youtube_channel_id='UCk6CoQG0q9grwIr5UgxiXEQ'"):
print(dict(r))
print('shorts dups by yt id')
for r in con.execute("SELECT youtube_channel_id yid, COUNT(*) n, GROUP_CONCAT(name,' | ') names FROM shorts_channels WHERE TRIM(youtube_channel_id)!='' GROUP BY youtube_channel_id HAVING n>1"):
print(dict(r))
print('yt_long nomdfs')
for r in con.execute("SELECT id,name,youtube_channel_id,source_shorts_channel_pk FROM yt_long_channels WHERE name LIKE '%nomdfs%' OR youtube_channel_id='UCk6CoQG0q9grwIr5UgxiXEQ'"):
print(dict(r))
con.close()
"""
sftp = c.open_sftp()
path = f"/tmp/_dup_{label}.py"
with sftp.file(path, "w") as f:
f.write(remote)
sftp.close()
if user == "root":
cmd = f"python3 {path}"
else:
cmd = f"echo '4669805' | sudo -S -p '' python3 {path}"
_, o, e = c.exec_command(cmd, timeout=60)
print((o.read() + e.read()).decode("utf-8", "replace"))
c.close()
run("107.173.30.245", 4014, "eric", "4669805", "physical", "/opt/douyinWEB/backend/data/monitor.db")
run("107.173.30.245", 22, "root", "Xiao4669805", "dylive", "/opt/douyinWEB/backend/data/monitor.db")