fix: add web_creator client fallback, friendlier YouTube bot error

- Try multiple YouTube player clients for better compatibility
- Show user-friendly error suggesting upload when YouTube blocks download

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2026-02-09 18:41:19 +00:00
parent be3b1ca706
commit 0e4eec4f12
2 changed files with 11 additions and 1 deletions

View File

@ -45,6 +45,8 @@ def _base_opts() -> dict:
shutil.copy2(COOKIES_FILE, tmp.name)
tmp.close()
opts["cookiefile"] = tmp.name
# Enable remote EJS challenge solver for YouTube
opts["extractor_args"] = {"youtube": {"player_client": ["default", "web_creator"]}}
return opts

View File

@ -76,7 +76,15 @@ async def process_job(ctx: dict, job_id: str):
os.makedirs(job_media_dir, exist_ok=True)
if job.source_type == "youtube":
video_info = await download.download_video(job.source_url, job_media_dir)
try:
video_info = await download.download_video(job.source_url, job_media_dir)
except Exception as dl_err:
if "Sign in to confirm" in str(dl_err) or "bot" in str(dl_err):
raise ValueError(
"YouTube blocked this download (bot detection). "
"Try uploading the video file directly instead."
)
raise
job.title = video_info.title
job.duration = video_info.duration
job.media_path = video_info.video_path