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>
57 lines
1.8 KiB
Python
57 lines
1.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
REMOTE = """
|
|
import sqlite3
|
|
p = "/opt/douyinWEB/backend/data/monitor.db"
|
|
con = sqlite3.connect(p)
|
|
con.row_factory = sqlite3.Row
|
|
cols = [r[1] for r in con.execute("PRAGMA table_info(shorts_channels)")]
|
|
want = [c for c in (
|
|
"id", "name", "youtube_channel_id", "oauth_profile_id", "enabled",
|
|
"daily_max", "note", "oauth_ok", "oauth_email", "created_at", "updated_at",
|
|
"account_label", "brand_hint"
|
|
) if c in cols]
|
|
print("want", want)
|
|
sql = "SELECT " + ",".join(want) + " FROM shorts_channels ORDER BY rowid"
|
|
for r in con.execute(sql):
|
|
d = dict(r)
|
|
blob = " ".join(str(v) for v in d.values()).lower()
|
|
if "nomdfs" in blob or "ewfwef" in blob or "digitl" in blob:
|
|
print("HIT", d)
|
|
|
|
print("--- dup by youtube_channel_id ---")
|
|
for r in con.execute(
|
|
"SELECT youtube_channel_id AS yid, COUNT(*) AS n, "
|
|
"GROUP_CONCAT(id, ' | ') AS ids, GROUP_CONCAT(name, ' | ') AS names "
|
|
"FROM shorts_channels WHERE TRIM(youtube_channel_id) != '' "
|
|
"GROUP BY youtube_channel_id HAVING COUNT(*) > 1"
|
|
):
|
|
print(dict(r))
|
|
|
|
print("--- dup by name ---")
|
|
for r in con.execute(
|
|
"SELECT name, COUNT(*) AS n, GROUP_CONCAT(id, ' | ') AS ids "
|
|
"FROM shorts_channels GROUP BY name HAVING COUNT(*) > 1"
|
|
):
|
|
print(dict(r))
|
|
con.close()
|
|
"""
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("107.173.30.245", 4014, "eric", "4669805", timeout=45, allow_agent=False, look_for_keys=False)
|
|
sftp = c.open_sftp()
|
|
with sftp.file("/tmp/_dup_ch.py", "w") as f:
|
|
f.write(REMOTE)
|
|
sftp.close()
|
|
_, o, e = c.exec_command("echo '4669805' | sudo -S -p '' python3 /tmp/_dup_ch.py", timeout=60)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"))
|
|
c.close()
|