chore: remove local douyu debug artifacts from repo

This commit is contained in:
liuwei
2026-04-08 17:05:37 +08:00
parent 867ed0a2ec
commit cf675db2da
14 changed files with 0 additions and 21045 deletions

View File

@@ -1,88 +0,0 @@
import requests
import time
# ====== 配置 ======
ROOM_ID = "288016" # 👉 改成你要测试的直播间ID
PAGE_LIMIT = 5 # 拉前几页(避免太重)
SLEEP_INTERVAL = 60 # 采样间隔(秒)
HEADERS = {
"User-Agent": "Mozilla/5.0",
"Referer": f"https://www.douyu.com/{ROOM_ID}"
}
def get_room_status(room_id):
"""获取直播状态"""
url = f"https://www.douyu.com/betard/{room_id}"
try:
res = requests.get(url, headers=HEADERS, timeout=5).json()
return res["room"]["show_status"] # 1=直播中, 2=未开播
except Exception as e:
print("获取直播状态失败:", e)
return None
def get_vip_count(room_id, page_limit=3):
"""获取贵宾数量(简单版)"""
vip_users = set()
for page in range(1, page_limit + 1):
url = "https://www.douyu.com/wfs/web/getFansList"
params = {
"roomid": room_id,
"page": page
}
try:
res = requests.get(url, headers=HEADERS, params=params, timeout=5).json()
data = res.get("data", {}).get("list", [])
if not data:
break
for user in data:
noble = user.get("nobleLevel", 0)
if noble and noble > 0:
uid = user.get("uid")
vip_users.add(uid)
except Exception as e:
print(f"{page}页获取失败:", e)
break
return len(vip_users)
def main():
print(f"开始监控直播间: {ROOM_ID}")
last_status = None
while True:
status = get_room_status(ROOM_ID)
if status == 1:
if last_status != 1:
print("🎬 开播了!")
vip_count = get_vip_count(ROOM_ID, PAGE_LIMIT)
now = time.strftime("%H:%M:%S")
print(f"[{now}] 当前贵宾数(估算): {vip_count}")
elif status == 2:
if last_status == 1:
print("🛑 已下播")
else:
print("未开播...")
else:
print("状态获取异常")
last_status = status
time.sleep(SLEEP_INTERVAL)
if __name__ == "__main__":
main()