Repository navigation
Conversation
When yt-dlp reports an age restriction, copy AGE_RESTRICTED_COOKIES_FILE to a temporary file and retry once with it. An account is then only used when needed, and the configured file is never written to by yt-dlp. Closes meeb#1623
Collaborator
|
Thanks! Please open an issue for the If you commit your wiki changes under |
tcely
requested changes
Oct 27, 2026
tcely
reviewed
Oct 27, 2026
tcely
requested changes
Oct 28, 2026
Co-authored-by: tcely <tcely@users.noreply.github.com>
tcely
approved these changes
Oct 28, 2026
Collaborator
|
@eunchanp Did you want to make any further changes or update the wiki?? |
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.
Summary
Closes #1623.
Adds a separate cookies file that is only used after YouTube reports an age restriction. Regular requests keep using
cookies.txt(or no cookies), so an account is only used when it is needed.AGE_RESTRICTED_COOKIES_FILE, defaulting toCONFIG_BASE_DIR / 'cookies-age-restricted.txt'(/config/tubesync/cookies-age-restricted.txtin the container).get_media_info()ordownload_media()fails with an age restriction message ("confirm your age", "age-restricted", "inappropriate for some users") and that file exists, the file is copied into a private temporary directory and the request is retried once withcookiefilepointing at the copy.FormatUnavailableErrorand the members-only retry.Usage
Drop the account's Netscape-format cookies into
/config/tubesync/cookies-age-restricted.txt. On a retry the log shows:The Using cookies wiki page does not mention this file yet. I'm happy to draft that addition if it helps.
Tests
New
sync/tests/test_youtube.py(10 tests) mocksyt_dlp.YoutubeDLand covers, for bothget_media_info()anddownload_media():YouTubeErrorcookies.txtis used first and replaced by the copy only for the retryThe full Django suite passes locally (77 tests, Python 3.14 on macOS), and
ruff checkis clean.Unrelated finding
While writing the tests I noticed that
get_media_info()raisesTypeErrorwhenYOUTUBE_DL_CACHEDIRis not set, which is the default outside the container.YOUTUBE_DEFAULTS['cachedir']isFalse, soPath(user_set('cachedir', opts, '/dev/shm'))becomesPath(False). The new tests set a cache directory the way the container settings do. I left the fix out of this PR to keep it focused.