From c042320ef18fc14a91419e620a185827c2d448a3 Mon Sep 17 00:00:00 2001 From: eric Date: Wed, 16 Sep 2026 21:58:53 -0500 Subject: [PATCH] Clarify Shorts/yt-long quota UI: enabled channels only. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Document fleet-cap rule and drop hardcoded「未达 9 条」copy on Shorts ops cards. Co-authored-by: Cursor --- README.md | 4 ++ frontend/src/app/shorts/page.tsx | 10 +++- frontend/src/app/yt-long/page.tsx | 2 +- scripts/_fix_quota_ui_copy_both.py | 90 ++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 scripts/_fix_quota_ui_copy_both.py diff --git a/README.md b/README.md index 76980a5..8aecb0c 100644 --- a/README.md +++ b/README.md @@ -416,6 +416,10 @@ Windows 上可用 `python scripts\_deploy.py`(需自行配置 SSH 目标,** 长视频后台 `reconcile_yt_long_upload_caps` **不得**把操作员保存的上限强行改回 5;仅在 API 限流日对「高于有效上限」的频道做软封顶。 +#### 配额口径(Shorts / 长视频) + +控制台顶部「北京日配额 / YouTube 上传 / 母片录制」**只合计已启用**频道(停用的 Client B 等不计入)。后端缺口与取样同样只看 `enabled=1`。长视频母片上限 = 已启用 oauth 长视频频道 × 每频道日上限,**不再**按 Shorts 舰队规模抬高。 + #### YouTube 直播状态(receiving-first) 首页 / live-map / 转播门控:**优先** YouTube 是否在收流(Studio receiving / `on_air` / youtubei·OAuth `is_live`),Neko 上下线不得覆盖「已在收流」。`encoder_lost` / LIVE 计时器 + No data **不算** receiving。细则见 `.cursor/rules/youtube-live-receiving-first.mdc`。 diff --git a/frontend/src/app/shorts/page.tsx b/frontend/src/app/shorts/page.tsx index 1313ff5..043e0b0 100644 --- a/frontend/src/app/shorts/page.tsx +++ b/frontend/src/app/shorts/page.tsx @@ -978,8 +978,14 @@ export default function ShortsPage() { <>
{[ - ["北京日配额", `${totals.uploaded} / ${totals.cap || "—"}`, beijingWindow ? `${beijingWindow}(北京时间)` : "按各频道日上限合计"], - ["当日缺口", String(totals.gap || quotaGap), minUnmet > 0 ? `${minUnmet} 个频道未达 9 条` : "各频道已达 9 条"], + ["北京日配额", `${totals.uploaded} / ${totals.cap || "—"}`, beijingWindow ? `${beijingWindow}(北京时间)· 仅已启用` : "仅已启用频道日上限合计"], + [ + "当日缺口", + String(totals.gap || quotaGap), + minUnmet > 0 + ? `${minUnmet} 个启用频道未达每日最少` + : "启用频道已达每日最少", + ], ["已上传", String(totals.uploaded), `待传 ${totals.queuedUpload} · 待录 ${totals.pendingRecord} · 剩余 ${hoursLeft}`], [ "抖音在播源", diff --git a/frontend/src/app/yt-long/page.tsx b/frontend/src/app/yt-long/page.tsx index fe11056..4cf2aaf 100644 --- a/frontend/src/app/yt-long/page.tsx +++ b/frontend/src/app/yt-long/page.tsx @@ -587,7 +587,7 @@ export default function YtLongPage() { &1 | tail -12 +systemctl restart douyinweb-web +sleep 2 +systemctl is-active douyinweb-web +# verify enabled-only caps via API status fields +cd /opt/douyinWEB/backend && .venv/bin/python - <<'PY' +from app import db, yt_long_db +from app.timeutil import push_date_from_ts +import time +day = push_date_from_ts(time.time()) +se = [c for c in (db.list_shorts_channels(enabled=True) or []) if c.get("enabled")] +print("shorts_en", len(se), "cap", sum(int(c.get("daily_max") or 9) for c in se), "gap", db.shorts_total_quota_gap(day)) +print("yt_long_cap", yt_long_db.yt_long_enabled_upload_cap(), "src", yt_long_db.yt_long_source_daily_max(), "gap", yt_long_db.yt_long_source_gap(day)) +PY +echo HOST_DONE +''' + + +def wait(c, path, rounds=100): + out = "" + for i in range(rounds): + time.sleep(3) + _, o, _ = c.exec_command(f"tail -c 16000 {path} 2>/dev/null", timeout=15) + out = o.read().decode("utf-8", "replace") + if "HOST_DONE" in out and "EXIT:" in out: + return out + if i % 5 == 0: + print("poll", i, out[-120:].replace("\n", " | "), flush=True) + return out + + +def main() -> int: + c = paramiko.SSHClient() + c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + c.connect(JUMP, 22, "root", PASS, timeout=40, allow_agent=False, look_for_keys=False) + sftp = c.open_sftp() + for local, remote in ( + ("frontend/src/app/shorts/page.tsx", "/tmp/_q2_shorts.tsx"), + ("frontend/src/app/yt-long/page.tsx", "/tmp/_q2_ytlong.tsx"), + ): + data = (ROOT / local).read_bytes().replace(b"\r\n", b"\n") + with sftp.file(remote, "wb") as f: + f.write(data) + print("staged", local, len(data), flush=True) + with sftp.file("/tmp/_q2.sh", "w") as f: + f.write(SH) + sftp.close() + + print("===== dylive =====", flush=True) + c.exec_command( + "bash /tmp/_q2.sh > /tmp/_q2_dylive.out 2>&1; echo EXIT:$? >> /tmp/_q2_dylive.out", + timeout=1, + ) + print(wait(c, "/tmp/_q2_dylive.out")[-8000:], flush=True) + + print("===== dy =====", flush=True) + c.exec_command( + f"SSHPASS={PASS} sshpass -e scp -o StrictHostKeyChecking=no " + f"/tmp/_q2_shorts.tsx /tmp/_q2_ytlong.tsx /tmp/_q2.sh root@{DY}:/tmp/ && " + f"SSHPASS={PASS} sshpass -e ssh -o StrictHostKeyChecking=no root@{DY} " + f"'bash /tmp/_q2.sh' > /tmp/_q2_dy.out 2>&1; echo EXIT:$? >> /tmp/_q2_dy.out", + timeout=1, + ) + print(wait(c, "/tmp/_q2_dy.out")[-8000:], flush=True) + c.close() + return 0 + + +if __name__ == "__main__": + raise SystemExit(main())