Repository navigation
Try yt-dlp cookie-free first; use cookies only as a fallback - #147
Merged
Merged
Conversation
With --cookies, yt-dlp drops every client that does not support cookies, including visionos, the only one that serves YouTube's high-bitrate HLS formats. A loaded cookies.txt therefore silently hid 617 (VP9 1080p60, 7547k) and left 303 (3191k). Every yt-dlp call now runs cookie-free first and retries once with cookies only when an ERROR line says YouTube wants a signed-in viewer (sign in, age gate, bot check, members-only, private). Covers the /video-info flat probe, _get_formats and the fetch_item download. Closes #145 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
prekabreki
force-pushed
the
fix/145-cookies-as-fallback
branch
from
December 4, 2026 11:11
09aba03 to
930f282
Compare
4 tasks
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.
Why
With
--cookies, yt-dlp drops every client whoseSUPPORTS_COOKIESis false.visionosis one of them, and it is the only client that serves YouTube's HLS formats. So loadingcookies.txtsilently hid617(VP9 1080p60, 7547k) and left303(3191k) as the best 1080p60 stream.From yt-dlp 2026.11.23's
_get_requested_clients:Adding
player_client=visionoscannot fix it, because yt-dlp removes cookie-unsupported clients whenever it is authenticated.What
Cookies are now a fallback, never the first try:
ytdlp._run_probe()runs a captured probe cookie-free. It retries once with cookies only when anERROR:line matches_COOKIE_WALL_MARKERS(sign in, age gate, bot check, members-only, private)./video-info's flat probe and_get_formatsuse it.fetch_itemwraps its download in the same two-attempt loop and logsYouTube wants a signed-in viewer — retrying with cookies.ERROR:lines count, so a title or WARNING mentioning "sign in" never triggers a retry.Trade-off, chosen deliberately: YouTube Premium enhanced-bitrate formats are no longer offered automatically when cookies are loaded.
Verify
.venv/Scripts/python.exe -m unittest discover -s tests→ OKtests/test_cookie_fallback.py(10 tests, fake yt-dlp that refuses cookie-free calls whenwallis set).test_download_behind_a_cookie_wall_retries_with_cookies._get_formats("…tlaxhiJ_l5U")with a cookies file present now lists1080p60 ~7546k(617) and~8977k(312).Not verified live
The cookie-wall retry against a real age-gated video. The only cookie file at hand is no longer signed in, so that path is covered by the fake only. Review should try one age-restricted video with fresh cookies.
Closes #145