yt-dlp: 添加 cookie 支持和代理绕过功能#90
Open
shawnhdx0710 wants to merge 1 commit into
Open
Conversation
Bilibili's CDN frequently blocks proxy/VPN nodes, causing HTTP 412 or SSL errors during download. This adds two features: - Auto-detect cookies.txt in the workspace (or B2T_COOKIE_FILE env var) for authenticated Bilibili access. - Default to bypassing the system proxy for Bilibili requests, since direct connections are typically more reliable. Set B2T_USE_PROXY=1 to re-enable proxy if needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #82
简介
为 yt-dlp 下载器添加两个功能,提升 Bilibili 访问的稳定性:
Cookie 文件自动检测 — 如果工作目录下存在
cookies.txt(或设置了B2T_COOKIE_FILE环境变量),会自动传递给 yt-dlp,用于需要登录才能访问的视频。默认绕过系统代理 — 代理/VPN(如 Clash Verge)的节点经常被 Bilibili CDN 封锁,导致 HTTP 412 或 SSL 错误。直连通常更稳定,因此默认关闭代理。如需使用代理,设置
B2T_USE_PROXY=1即可恢复。问题背景
国内用户在使用 Clash Verge 等代理软件时,经常遇到以下错误而无法下载 Bilibili 视频:
根本原因是 Bilibili 的反爬虫系统会拦截代理节点的请求。由于直连 Bilibili 对大多数用户来说是稳定可用的,默认绕过代理可以避免这个问题。
改动内容
src/b2t/downloaders/ytdlp.py—_build_ydl_opts方法新增 18 行$B2T_COOKIE_FILE>$WORKSPACE/cookies.txtB2T_USE_PROXY=1可恢复使用系统代理