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>
37 lines
1.9 KiB
Python
37 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import annotations
|
|
import sys, paramiko
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
REMOTE = r"""
|
|
import sqlite3
|
|
p='/opt/douyinWEB/backend/data/monitor.db'
|
|
con=sqlite3.connect(p); con.row_factory=sqlite3.Row
|
|
orphan='9d35678f-afb3-4bf6-b614-e44e73a0708a'
|
|
print('orphan in shorts?', con.execute('SELECT id,name FROM shorts_channels WHERE id=?',(orphan,)).fetchone())
|
|
print('=== yt_long all for same yt ===')
|
|
for r in con.execute("SELECT * FROM yt_long_channels WHERE youtube_channel_id='UCk6CoQG0q9grwIr5UgxiXEQ' OR name LIKE '%nomdfs%'"):
|
|
print({k:r[k] for k in r.keys() if k in ('id','name','youtube_channel_id','oauth_profile_id','source_shorts_channel_pk','enabled','created_at','updated_at','oauth_ok')})
|
|
print('=== sync logic orphans: yt_long whose source missing ===')
|
|
for r in con.execute('''
|
|
SELECT y.id,y.name,y.youtube_channel_id,y.source_shorts_channel_pk,y.oauth_profile_id
|
|
FROM yt_long_channels y
|
|
LEFT JOIN shorts_channels s ON s.id=y.source_shorts_channel_pk
|
|
WHERE y.source_shorts_channel_pk!='' AND s.id IS NULL
|
|
'''):
|
|
print('ORPHAN', dict(r))
|
|
print('=== dup yt_long by youtube_channel_id ===')
|
|
for r in con.execute('''
|
|
SELECT youtube_channel_id yid, COUNT(*) n, GROUP_CONCAT(id,' | ') ids, GROUP_CONCAT(name,' | ') names, GROUP_CONCAT(source_shorts_channel_pk,' | ') srcs
|
|
FROM yt_long_channels WHERE TRIM(youtube_channel_id)!=''
|
|
GROUP BY youtube_channel_id 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(); f=sftp.file('/tmp/_dup3.py','w'); f.write(REMOTE); f.close(); sftp.close()
|
|
_,o,e=c.exec_command("echo '4669805' | sudo -S -p '' python3 /tmp/_dup3.py", timeout=60)
|
|
print((o.read()+e.read()).decode())
|
|
c.close()
|