# -*- 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"], )