fix: a YouTube video behind the bot wall is downloadable with cookies
A YouTube link can fail with "Sign in to confirm you're not a bot" while every other YouTube download works — YouTube gates INDIVIDUAL videos behind a signed-in session. Measured on prod job 273: all twelve of yt-dlp's player clients fail on that one video while its neighbours download fine, the bgutil PO-token sidecar is live and answering, and the newest yt-dlp fails identically. So the download is not broken by our stack or a stale yt-dlp, and no retry, client switch or upgrade gets past it. A cookie is the only way in. The failure copy already sends the user to Settings -> Account -> Download authentication, but YouTube was not in the cookie host registry, so that dropdown could not help them: the app asked for something it did not offer. credentials: YouTube joins SUPPORTED_HOSTS (youtube.com, youtu.be, youtube-nocookie.com). The Settings dropdown, the SEC-12 host scope and the private-asset cache salt all derive from the row, so that is the whole wiring. adapters: a signed-in YouTube download runs only cookie-capable player clients. Measured against yt-dlp's own INNERTUBE_CLIENTS table: with account cookies attached yt-dlp REMOVES every client whose SUPPORTS_COOKIES is False, and a set it empties that way raises "No player clients have been requested" — which is not a per-client flake it retries past. Our primary set is android_vr, one of those, so without this the cookie would have failed the download on attempt 1 and never reached the POT-backed web fallback it exists for. A test pins the client list against the installed yt-dlp so a version bump turns the gate red instead of silently un-authing every YouTube download, and the empty-set message joins the retriable markers as the second line of defence. errors: catalog entries for the wall with and without a cookie, so a user who has already added cookies is told they were rejected (YouTube rotates exported ones) rather than to add some. The marker is quote-agnostic: YouTube writes the apostrophe as U+2019, so "you're not a bot" with a straight quote never matches the real text. EN + HU copy.
This commit is contained in:
@@ -84,6 +84,49 @@ _REEL = "https://www.facebook.com/reel/1736360027626346/?fs=e&fs=e"
|
||||
_GROUP_POST = "https://www.facebook.com/groups/983554479435596/permalink/1755988225525547/?"
|
||||
|
||||
|
||||
# Verbatim from prod job 273 (2026-09-15). YouTube writes the apostrophe as U+2019, which is why
|
||||
# neither the rule nor the catalog entry may spell out "you’re" with a straight quote.
|
||||
_YT_BOT_WALL = (
|
||||
"ERROR: [youtube] 7JPmS_bWjhI: Sign in to confirm you’re not a bot. Use "
|
||||
"--cookies-from-browser or --cookies for the authentication. See "
|
||||
"https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp for how to manually "
|
||||
"pass cookies."
|
||||
)
|
||||
_YT = "https://www.youtube.com/watch?v=7JPmS_bWjhI"
|
||||
|
||||
|
||||
def test_youtube_bot_wall_is_that_video_own_signed_out_gate():
|
||||
# Measured on prod: all 12 player clients fail on this video while its neighbours download, the
|
||||
# POT sidecar answers, and the newest yt-dlp fails identically — a cookie is the only way in.
|
||||
assert classify(_YT_BOT_WALL) == "login_required"
|
||||
for url in (
|
||||
_YT,
|
||||
"https://youtu.be/7JPmS_bWjhI",
|
||||
"https://www.youtube-nocookie.com/embed/7JPmS_bWjhI",
|
||||
"https://music.youtube.com/watch?v=7JPmS_bWjhI",
|
||||
):
|
||||
assert dlerrors.diagnose(_YT_BOT_WALL, url=url) == (
|
||||
"login_required",
|
||||
"youtube.bot_wall",
|
||||
), url
|
||||
|
||||
|
||||
def test_youtube_bot_wall_with_a_cookie_is_the_cookie_refused():
|
||||
# Telling a user who already gave a cookie to add one is what this entry exists to avoid.
|
||||
assert dlerrors.diagnose(_YT_BOT_WALL, url=_YT, cookie_attached=True) == (
|
||||
"login_required",
|
||||
"youtube.cookie_rejected",
|
||||
)
|
||||
|
||||
|
||||
def test_the_youtube_entries_never_match_another_site():
|
||||
# Host-scoped: the same words about a Facebook link stay the bare category.
|
||||
assert dlerrors.diagnose(
|
||||
"ERROR: [facebook] 1: Sign in to confirm you’re not a bot",
|
||||
url="https://www.facebook.com/reel/1/",
|
||||
) == ("login_required", None)
|
||||
|
||||
|
||||
def test_facebook_cannot_parse_data_is_the_login_wall_without_a_cookie():
|
||||
for url in (
|
||||
_REEL,
|
||||
|
||||
Reference in New Issue
Block a user