douyinWEB/scripts/_remote_check_room_status.py
eric c1f3bd3c57 Fix exclusive sticky when Douyin probe says offline (status=4).
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 06:03:46 -05:00

50 lines
1.5 KiB
Python

# -*- coding: utf-8 -*-
import json
import asyncio
from app.douyin import check_room
from app import db
cfg = db.get_settings_map()
cookie = str(cfg.get("dy_cookie") or "").strip()
print("cookie_len", len(cookie))
async def main():
for rid, title in [
("881772183814", "apo"),
("690114366322", "luwei"),
]:
url = f"https://live.douyin.com/{rid}"
probe = await check_room(url, cookie=cookie)
print(
title,
rid,
json.dumps(
{
"ok": probe.get("ok"),
"is_live": probe.get("is_live"),
"status_code": probe.get("status_code"),
"risk": probe.get("risk"),
"anchor": (probe.get("anchor_name") or "")[:40],
"err": str(probe.get("error") or "")[:80],
"cands": len(probe.get("stream_candidates") or []),
"stream": str(probe.get("stream_url") or "")[:80],
},
ensure_ascii=False,
),
)
asyncio.run(main())
# monitor live flags for same rooms
import sqlite3
from app.config import settings
path = getattr(settings, "db_path", None) or "data/monitor.db"
con = sqlite3.connect(path)
con.row_factory = sqlite3.Row
for rid in ("881772183814", "690114366322"):
r = con.execute(
"SELECT room_id, last_status, last_anchor, last_checked_at FROM rooms WHERE room_id=?",
(rid,),
).fetchone()
print("DB", dict(r) if r else rid)