fix(tencent): 视频号「声明原创」缺失时跳过而非中止发布

视频号原创声明是可选项,但 apply_original_statement 在未找到声明入口时
会 raise RuntimeError 中止整个发布。在改版后的发布页(部分账号用 wujie
微前端,DOM 结构不同)经常匹配不到入口,导致本可正常发布的视频全部失败。

改为:未找到声明入口时记录 warning 并继续发布,不再中止。同时给诊断分支的
body 定位加 .first,避免页面存在多个 <body> 时 Playwright strict mode 崩溃。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
智行olo
2026-05-30 02:11:38 -07:00
co-authored by Claude Opus 4.8
parent 99a392af2c
commit 3ef4cd322a
+3 -2
View File
@@ -627,12 +627,13 @@ class TencentBaseUploader(BaseVideoUploader):
try:
diagnostic_path = Path(BASE_DIR) / "debug_tencent_original_missing.png"
await page.screenshot(path=str(diagnostic_path), full_page=True)
visible_text = (await page.locator("body").inner_text())[-4000:]
visible_text = (await page.locator("body").first.inner_text())[-4000:]
tencent_logger.warning(_msg("😵", f"未确认声明原创,诊断截图: {diagnostic_path}"))
tencent_logger.warning(_msg("🧾", f"页面末尾文本: {visible_text}"))
except Exception as exc:
tencent_logger.warning(_msg("😵", f"生成原创声明诊断信息失败: {exc}"))
raise RuntimeError("未能在视频号发布页找到并设置“声明原创”,已停止发布")
# 视频号「声明原创」为可选项:页面无对应入口时跳过并继续发布,而非中止。
tencent_logger.warning(_msg("📭", "本视频未声明原创(页面无入口或为可选项),跳过并继续发布"))
async def wait_for_upload_complete(self, page: Page) -> None:
while True: