From ada999751e0ee7f74eaa267c5cb5ee57d25e7e7a Mon Sep 17 00:00:00 2001 From: eric Date: Fri, 21 Aug 2026 07:36:11 -0500 Subject: [PATCH] fix(yt-long): show Chinese status and friendly cascade-only copy in job list Co-authored-by: Cursor --- backend/app/clip_retention.py | 2 +- backend/app/yt_long_db.py | 4 +- backend/app/yt_long_pipeline.py | 12 +- frontend/src/app/yt-long/page.tsx | 138 +++++++++++++++---- frontend/src/components/OauthClientBadge.tsx | 10 +- 5 files changed, 132 insertions(+), 34 deletions(-) diff --git a/backend/app/clip_retention.py b/backend/app/clip_retention.py index d36b806..0309b25 100644 --- a/backend/app/clip_retention.py +++ b/backend/app/clip_retention.py @@ -88,7 +88,7 @@ def _accelerate_jobs_for_path(path: str, now: float) -> int: "yt_long_jobs", "UPDATE yt_long_jobs SET upload_at = ?, updated_at = ?, error = 'retention_rush' " "WHERE clip_path = ? AND status IN ('recorded','scheduled') AND IFNULL(youtube_video_id,'') = '' " - "AND IFNULL(error,'') != 'cascade_only'", + "AND IFNULL(error,'') NOT LIKE 'cascade_only%'", ), ) try: diff --git a/backend/app/yt_long_db.py b/backend/app/yt_long_db.py index aeb87ad..89a9c77 100644 --- a/backend/app/yt_long_db.py +++ b/backend/app/yt_long_db.py @@ -318,7 +318,7 @@ def room_blocks_yt_long_sample(room_id: str, push_date: str, *, need_upload_slot WHERE room_id = ? AND push_date = ? AND ( status IN ('pending', 'recording', 'scheduled', 'uploading', 'uploaded') - OR (status = 'recorded' AND IFNULL(clip_path, '') != '' AND IFNULL(error, '') != 'cascade_only') + OR (status = 'recorded' AND IFNULL(clip_path, '') != '' AND IFNULL(error, '') NOT LIKE 'cascade_only%') ) LIMIT 1 """, @@ -421,7 +421,7 @@ def list_cascade_only_ready(limit: int = 20, push_date: str = "") -> list[dict[s AND status = 'recorded' AND clip_path != '' AND IFNULL(youtube_video_id, '') = '' - AND (upload_at = 0 OR error = 'cascade_only') + AND (upload_at = 0 OR IFNULL(error, '') LIKE 'cascade_only%') ORDER BY created_at ASC LIMIT ? """, diff --git a/backend/app/yt_long_pipeline.py b/backend/app/yt_long_pipeline.py index c4be574..a38a096 100644 --- a/backend/app/yt_long_pipeline.py +++ b/backend/app/yt_long_pipeline.py @@ -702,7 +702,11 @@ class YtLongPipeline: # Only schedule YouTube long upload when upload quota remains if yt_long_db.yt_long_upload_gap(cfg=cfg) <= 0: yt_long_db.update_yt_long_job( - jid, status="recorded", error="cascade_only", upload_at=0, clip_path="" + jid, + status="recorded", + error="cascade_only:当日上传名额已满,只做了切片,未传YouTube", + upload_at=0, + clip_path="", ) _drop_master_after_cascade() return @@ -713,7 +717,11 @@ class YtLongPipeline: channel = pick_yt_long_channel(cfg, str(fresh.get("push_date") or "")) if not channel: yt_long_db.update_yt_long_job( - jid, status="recorded", error="cascade_only", upload_at=0, clip_path="" + jid, + status="recorded", + error="cascade_only:当日上传名额已满,只做了切片,未传YouTube", + upload_at=0, + clip_path="", ) _drop_master_after_cascade() return diff --git a/frontend/src/app/yt-long/page.tsx b/frontend/src/app/yt-long/page.tsx index aa9d1b3..eaf105e 100644 --- a/frontend/src/app/yt-long/page.tsx +++ b/frontend/src/app/yt-long/page.tsx @@ -98,6 +98,70 @@ const STATUS_STYLE: Record = { skipped: "bg-white/10 text-slate-400", }; +const STATUS_LABEL: Record = { + pending: "待录制", + recording: "录制中", + recorded: "已录制", + scheduled: "排队上传", + uploading: "上传中", + uploaded: "已上传", + failed: "失败", + skipped: "已跳过", +}; + +const STATUS_FILTERS = [ + "pending", + "recording", + "recorded", + "scheduled", + "uploading", + "uploaded", + "failed", + "skipped", +] as const; + +function jobResultZh(job: { + youtube_url?: string; + error?: string; + clip_ready?: boolean; + clip_path?: string; + status?: string; +}): { text: string; tone: "ok" | "warn" | "err" | "muted" } { + if (job.youtube_url) return { text: "已上传 YouTube", tone: "ok" }; + const err = String(job.error || "").trim(); + if (!err) { + if (job.clip_ready || job.clip_path) return { text: "成片已好,等待上传", tone: "muted" }; + if (job.status === "pending") return { text: "排队录制", tone: "muted" }; + if (job.status === "recording") return { text: "正在录直播", tone: "muted" }; + if (job.status === "scheduled") return { text: "已排好上传时间", tone: "muted" }; + if (job.status === "uploading") return { text: "正在上传", tone: "muted" }; + return { text: "—", tone: "muted" }; + } + const low = err.toLowerCase(); + if (err === "cascade_only" || low.includes("cascade_only")) { + const zh = err.includes(":") ? err.split(":").slice(1).join(":").trim() : ""; + return { + text: zh || "当日上传名额已满,只做了切片,未传 YouTube", + tone: "warn", + }; + } + if (err === "source_quota_full" || low.includes("source_quota")) { + return { text: "今日录制名额已满,已跳过", tone: "warn" }; + } + if (low.includes("quota") || low.includes("配额") || low.includes("429")) { + return { text: "YouTube 接口限流/配额用尽", tone: "err" }; + } + if (err.includes("无可用长视频频道") || err.includes("未授权")) { + return { text: err, tone: "err" }; + } + if (err.includes("成片文件不存在") || low.includes("clip")) { + return { text: "成片文件已清理,无法直接重传", tone: "warn" }; + } + // Keep Chinese messages; trim long English API dumps + if (/[\u4e00-\u9fff]/.test(err)) return { text: err.slice(0, 120), tone: "err" }; + return { text: err.slice(0, 100), tone: "err" }; +} + const JOB_PAGE = 50; export default function YtLongPage() { @@ -819,8 +883,8 @@ export default function YtLongPage() {

任务流水({jobTotal}) - pending {stats.pending || 0} · scheduled {stats.scheduled || 0} · uploaded {stats.uploaded || 0} · - failed {stats.failed || 0} + 待录 {stats.pending || 0} · 排队 {stats.scheduled || 0} · 已上传 {stats.uploaded || 0} · 失败{" "} + {stats.failed || 0}

@@ -851,7 +915,7 @@ export default function YtLongPage() { {channels.map((c) => ( ))} @@ -868,9 +932,9 @@ export default function YtLongPage() { className="rounded-lg border border-white/10 bg-slate-900 px-3 py-1.5 text-xs" > - {["pending", "recording", "recorded", "scheduled", "uploading", "uploaded", "failed"].map((s) => ( + {STATUS_FILTERS.map((s) => ( ))} @@ -888,16 +952,24 @@ export default function YtLongPage() { 频道 排程上传 创建 - 结果 + 说明 操作 - {jobs.map((j) => ( + {jobs.map((j) => { + const result = jobResultZh(j); + const isCascadeOnly = + String(j.error || "").includes("cascade_only") || + String(j.error || "").includes("当日上传名额已满"); + const canRetry = + ["failed", "skipped", "scheduled"].includes(j.status) || + (j.status === "recorded" && !isCascadeOnly && Boolean(j.clip_path || j.clip_ready)); + return ( - {j.status} + {STATUS_LABEL[j.status] || j.status} @@ -905,13 +977,17 @@ export default function YtLongPage() {
{j.room_id || ""}
-
- - {channelName[String(j.channel_pk || "")] || "—"} -
+ {j.channel_pk ? ( +
+ + {channelName[String(j.channel_pk || "")] || "未知频道"} +
+ ) : ( + 未分配频道 + )} {j.upload_at ? fmtTs(Number(j.upload_at)) : "—"} @@ -920,32 +996,46 @@ export default function YtLongPage() { {j.youtube_url ? ( - 已上传 + {result.text} - ) : j.error ? ( - {j.error} - ) : j.clip_ready || j.clip_path ? ( - 成片待传 ) : ( - "—" + + {result.text} + )} - {["failed", "skipped", "recorded", "scheduled"].includes(j.status) ? ( + {canRetry ? ( + ) : isCascadeOnly ? ( + + 无需重传 + ) : ( — )} - ))} + ); + })} {jobs.length === 0 ? ( diff --git a/frontend/src/components/OauthClientBadge.tsx b/frontend/src/components/OauthClientBadge.tsx index 25e27bc..44c97b2 100644 --- a/frontend/src/components/OauthClientBadge.tsx +++ b/frontend/src/components/OauthClientBadge.tsx @@ -31,9 +31,9 @@ export function OauthClientBadge({ className={`inline-flex shrink-0 items-center rounded border border-white/15 bg-white/5 font-semibold tracking-wide text-slate-400 ${ size === "lg" ? "px-2 py-0.5 text-xs" : size === "sm" ? "px-1.5 py-0 text-[10px]" : "px-1.5 py-0.5 text-[10px]" } ${className}`} - title="未绑定 OAuth 配置档" + title="未绑定谷歌上传账号" > - Client — + 未绑定 ); } @@ -43,9 +43,9 @@ export function OauthClientBadge({ return ( - Client {id} + 账号 {id} ); } @@ -53,5 +53,5 @@ export function OauthClientBadge({ export function channelLabelWithProfile(name?: string | null, profileId?: string | null): string { const n = String(name || "").trim() || "未命名"; const id = normalizeOauthProfileId(profileId); - return id ? `${n} · Client ${id}` : n; + return id ? `${n} · 账号 ${id}` : n; }