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

47 lines
1.2 KiB
Python

# -*- coding: utf-8 -*-
import json
import sqlite3
import sys
from pathlib import Path
sys.path.insert(0, "/opt/douyinWEB/backend")
from app.config import settings
conn = sqlite3.connect(str(settings.sqlite_path))
conn.row_factory = sqlite3.Row
rows = conn.execute(
"""
SELECT id, name, youtube_channel_id, oauth_profile_id,
length(yt_profile_json) AS jlen, yt_profile_at,
substr(yt_profile_json, 1, 400) AS jhead
FROM shorts_channels
ORDER BY name
"""
).fetchall()
print("channels", len(rows))
for r in rows:
d = dict(r)
thumb = ""
title = ""
try:
raw = conn.execute(
"SELECT yt_profile_json FROM shorts_channels WHERE id=?", (d["id"],)
).fetchone()
p = json.loads(raw["yt_profile_json"] or "{}") if raw else {}
thumb = str(p.get("thumb_url") or "")
title = str(p.get("title") or "")
if not thumb:
th = p.get("thumbnails") or {}
thumb = str(((th.get("medium") or {}).get("url")) or "")
except Exception as exc:
thumb = f"err:{exc}"
print(
d["name"][:24],
"|",
title[:24],
"| thumb=",
(thumb[:90] if thumb else "EMPTY"),
"| at=",
d["yt_profile_at"],
)