Commit b5b5587

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-04-06 09:12:18
fix(ytdlp): fallback on geo-restricted videos
1 parent d1ec54c
Changed files (1)
src
preview
src/preview/ytdlp.py
@@ -110,7 +110,7 @@ async def preview_ytdlp(
     json_file = f"{DOWNLOAD_DIR}/{quote_plus(url)}.json"
     info = download_video_info(url, ydl_opts, json_file)
     if ytdlp_error := info.get("ytdlp_error"):
-        if proxy != PROXY.YTDLP_FALLBACK and ("Sign in" in ytdlp_error or "请登录" in ytdlp_error):
+        if proxy != PROXY.YTDLP_FALLBACK and any(x in ytdlp_error.lower() for x in ["sign in", "请登录", "地区", "国家", "country", "删除", "deleted"]):
             raise ProxyError(ytdlp_error)
         await modify_progress(text=ytdlp_error, force_update=True, **kwargs)
         return
@@ -400,7 +400,7 @@ def retry(func, max_retries=5):
                 msg = f"ExtractorError: {str(e.orig_msg).removeprefix('ERROR: ')}"
             except DownloadError as e:
                 msg = f"DownloadError: {str(e.msg).removeprefix('ERROR: ')}"
-                if any(x in msg for x in ["Sign in", "请登录", "deleted", "geo-restricted"]):
+                if any(x in msg.lower() for x in ["sign in", "请登录", "地区", "国家", "country", "删除", "deleted"]):
                     retries += 1
                     break
             except YoutubeDLError as e: