fix(uploader): 适配抖音与视频号发布页最新 DOM 结构

抖音 douyin_uploader:
- 填标题/描述:改用 input[placeholder*=填写作品标题] 与 div.zone-container[contenteditable] 定位
- 话题输入后按 Escape 收起下拉,避免浮层拦截
- '选择封面'与'发布'改用 force 点击,并移除拦截点击的新手引导(shepherd)浮层
- 封面弹窗适配:div.dy-creator-content-modal + input.semi-upload-hidden-input;横竖版切换改用'设置竖封面'按钮;完成后等弹窗关闭

视频号 tencent_uploader:
- upload_video_file 遍历所有 frame 查找文件框 + 重试等待

说明:两平台发布均需有头模式(--headed),无头下视频号上传框不渲染。
This commit is contained in:
changyandaoc
2026-06-13 12:01:24 +08:00
parent 90e01c0106
commit f5cb31079c
2 changed files with 44 additions and 21 deletions
+27 -4
View File
@@ -495,12 +495,35 @@ class TencentBaseUploader(BaseVideoUploader):
await page.locator("div.input-editor").click()
async def open_upload_page(self, page: Page) -> None:
await page.goto(TENCENT_UPLOAD_URL)
await page.wait_for_url(TENCENT_UPLOAD_URL)
await page.goto(TENCENT_UPLOAD_URL, timeout=120000, wait_until="domcontentloaded")
await page.wait_for_url(TENCENT_UPLOAD_URL, timeout=120000)
async def upload_video_file(self, page: Page, file_path: str) -> None:
file_input = page.locator('input[type="file"]')
await file_input.set_input_files(file_path)
async def find_file_input():
for fr in page.frames: # 主 frame + 所有 iframe(视频号编辑器可能在 iframe 内)
try:
fi = fr.locator('input[type="file"]')
if await fi.count():
return fi.first
except Exception:
continue
return None
fi = await find_file_input()
if fi is None:
# 助手落在首页:先点「发表视频」唤出编辑器与上传控件
publish_btn = page.get_by_text("发表视频").first
if await publish_btn.count():
await publish_btn.click()
await asyncio.sleep(3)
for _ in range(20):
fi = await find_file_input()
if fi is not None:
break
await asyncio.sleep(1)
if fi is None:
raise RuntimeError("未找到视频号文件上传框")
await fi.set_input_files(file_path)
async def set_short_title(self, page: Page, title: str, short_title: str | None = None) -> None:
short_title_element = (