fix(tencent): adapt to Channels revamped editor and improve publish flow

- Open homepage first, then click the visible 'publish video' entry
  button instead of loading /platform/post/create directly, which gets
  bounced back to the homepage and leaves the form iframe un-mounted
- Detect expired cookies up front by watching for the /login.html
  redirect and the qrconnect iframe
- Drop the redundant confirm_thumbnail_crop call that caused a 5s
  timeout on cover upload
- Select collection by exact name after upload completes (form resets
  selections made while the video is still uploading); keep it
  unselected when no matching name is found instead of picking a
  random one
- Scroll the target option into view and fall back to forced click /
  native dispatch for headless visibility issues
- Tighten short-title length to 7~15 chars to pass platform validation
- Dismiss the occasional 'switch account' dialog that blocks the
  description box and the publish button
This commit is contained in:
suihf
2026-08-13 09:49:34 +08:00
parent 008e4ff66a
commit c1617444f9
2 changed files with 218 additions and 152 deletions
+4
View File
@@ -166,6 +166,7 @@ class TencentVideoUploadRequest:
publish_strategy: str = TENCENT_PUBLISH_STRATEGY_IMMEDIATE
debug: bool = True
headless: bool = True
collection_name: str | None = None
@dataclass(slots=True)
@@ -544,6 +545,7 @@ async def upload_tencent_video(request: TencentVideoUploadRequest) -> Path:
publish_strategy=request.publish_strategy,
debug=request.debug,
headless=request.headless,
collection_name=request.collection_name,
)
await app.tencent_upload_video()
return account_file
@@ -714,6 +716,7 @@ def build_parser() -> argparse.ArgumentParser:
tencent_upload_video_parser.add_argument("--short-title", help="Optional WeChat Channels short title")
tencent_upload_video_parser.add_argument("--category", help="Optional original content category")
tencent_upload_video_parser.add_argument("--draft", action="store_true", help="Save as draft instead of publishing")
tencent_upload_video_parser.add_argument("--collection", default=None, help="Optional collection name to add the work into (must already exist)")
add_runtime_flags(tencent_upload_video_parser)
youtube_parser = platform_parsers.add_parser("youtube", help="YouTube operations")
@@ -977,6 +980,7 @@ async def dispatch(args: argparse.Namespace) -> int:
publish_strategy=publish_strategy,
debug=args.debug,
headless=args.headless,
collection_name=args.collection,
)
await upload_tencent_video(request)
print(f"Tencent/WeChat Channels video upload submitted: {request.video_file}")