fix(yt-long): show Chinese status and friendly cascade-only copy in job list

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
eric 2026-08-21 07:36:11 -05:00
parent 6a033e6326
commit ada999751e
5 changed files with 132 additions and 34 deletions

View File

@ -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:

View File

@ -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 ?
""",

View File

@ -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

View File

@ -98,6 +98,70 @@ const STATUS_STYLE: Record<string, string> = {
skipped: "bg-white/10 text-slate-400",
};
const STATUS_LABEL: Record<string, string> = {
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() {
<h3 className="text-sm font-medium text-slate-100">
任务流水({jobTotal})
<span className="ml-2 text-[11px] font-normal text-slate-500">
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}
</span>
</h3>
<div className="flex flex-wrap items-center gap-2">
@ -851,7 +915,7 @@ export default function YtLongPage() {
{channels.map((c) => (
<option key={c.id} value={c.id}>
{normalizeOauthProfileId(c.oauth_profile_id)
? `[Client ${normalizeOauthProfileId(c.oauth_profile_id)}] ${c.name}`
? `[账号 ${normalizeOauthProfileId(c.oauth_profile_id)}] ${c.name}`
: c.name}
</option>
))}
@ -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"
>
<option value="">全部状态</option>
{["pending", "recording", "recorded", "scheduled", "uploading", "uploaded", "failed"].map((s) => (
{STATUS_FILTERS.map((s) => (
<option key={s} value={s}>
{s}
{STATUS_LABEL[s] || s}
</option>
))}
</select>
@ -888,16 +952,24 @@ export default function YtLongPage() {
<th className="pb-2 pr-2">频道</th>
<th className="pb-2 pr-2">排程上传</th>
<th className="pb-2 pr-2">创建</th>
<th className="pb-2 pr-2">结果</th>
<th className="pb-2 pr-2">说明</th>
<th className="pb-2">操作</th>
</tr>
</thead>
<tbody>
{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 (
<tr key={j.id} className="border-t border-white/5 align-top">
<td className="py-2.5 pr-2">
<span className={`rounded-md px-2 py-0.5 text-[11px] ${STATUS_STYLE[j.status] || "bg-white/10"}`}>
{j.status}
{STATUS_LABEL[j.status] || j.status}
</span>
</td>
<td className="py-2.5 pr-2">
@ -905,13 +977,17 @@ export default function YtLongPage() {
<div className="font-mono text-[10px] text-slate-500">{j.room_id || ""}</div>
</td>
<td className="py-2.5 pr-2 text-xs text-slate-400">
<div className="flex flex-wrap items-center gap-1.5">
<OauthClientBadge
profileId={channelProfileMap[String(j.channel_pk || "")]}
size="sm"
/>
<span>{channelName[String(j.channel_pk || "")] || "—"}</span>
</div>
{j.channel_pk ? (
<div className="flex flex-wrap items-center gap-1.5">
<OauthClientBadge
profileId={channelProfileMap[String(j.channel_pk || "")]}
size="sm"
/>
<span>{channelName[String(j.channel_pk || "")] || "未知频道"}</span>
</div>
) : (
<span className="text-slate-500">未分配频道</span>
)}
</td>
<td className="py-2.5 pr-2 text-xs text-slate-400">
{j.upload_at ? fmtTs(Number(j.upload_at)) : "—"}
@ -920,32 +996,46 @@ export default function YtLongPage() {
<td className="py-2.5 pr-2 text-xs">
{j.youtube_url ? (
<a href={j.youtube_url} target="_blank" rel="noreferrer" className="text-teal-300 hover:underline">
已上传
{result.text}
</a>
) : j.error ? (
<span className="text-rose-300">{j.error}</span>
) : j.clip_ready || j.clip_path ? (
<span className="text-slate-400">成片待传</span>
) : (
"—"
<span
className={
result.tone === "ok"
? "text-teal-300"
: result.tone === "warn"
? "text-amber-200"
: result.tone === "err"
? "text-rose-300"
: "text-slate-400"
}
title={j.error || undefined}
>
{result.text}
</span>
)}
</td>
<td className="py-2.5">
{["failed", "skipped", "recorded", "scheduled"].includes(j.status) ? (
{canRetry ? (
<button
type="button"
onClick={() => void retryJob(j.id)}
className="inline-flex items-center gap-1 rounded bg-white/5 px-2 py-1 text-xs"
>
<RotateCcw className="h-3 w-3" />
重排
重新上传
</button>
) : isCascadeOnly ? (
<span className="text-[10px] text-slate-500" title="成片已用于切片并清理,请等新取样">
无需重传
</span>
) : (
<span className="text-[10px] text-slate-600">—</span>
)}
</td>
</tr>
))}
);
})}
{jobs.length === 0 ? (
<tr>
<td colSpan={7} className="py-8 text-center text-slate-500">

View File

@ -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 —
未绑定
</span>
);
}
@ -43,9 +43,9 @@ export function OauthClientBadge({
return (
<span
className={`inline-flex shrink-0 items-center rounded border font-bold tracking-wide ${style} ${sizeCls} ${className}`}
title={label || `OAuth 配置档 ${id}`}
title={label || `谷歌上传账号 ${id}`}
>
Client {id}
账号 {id}
</span>
);
}
@ -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;
}