Skip to content

cookies_file: private temp copy when unwritable or shared by workers - #49

Merged
thorwhalen merged 2 commits into
mainfrom
cookies-private-copy-33
Oct 27, 2026
Merged

thorwhalen merged 2 commits into
mainfrom
cookies-private-copy-33

Conversation

@thorwhalen

Copy link
Copy Markdown
Collaborator

Closes #33.

yt-dlp rewrites its cookiefile on exit. Now _final_opts merges the options (base, cookies, extra_opts) and, when the cookie file (from cookies_file, the default, or extra_opts["cookiefile"]) is not writable, or YB_COOKIES_PRIVATE_COPY is truthy, hands yt-dlp a 0600 temporary copy that is deleted afterwards (also on failure). Refreshed cookies are then not persisted. One helper replaces the cookie wiring at the three call sites (_extract_info, video download, playlist download), so search, info, audio and download_audio_bounded all get it.

Design call: the "caller asks" case is an env var rather than a keyword on seven public functions; parallel workers are a deployment property. File lock for the persisting case is not added (documented: every worker must set the env var).

Adversarial review (Opus): mechanism sound; one real problem: a cookiefile in extra_opts (the server-deployment path, and what download_audio_bounded allows) bypassed the copy. Fixed by copying from the merged options; the same fix dedups the wiring (three copies to one helper). Added tests: extra_opts cookiefile for all five entry points, copy mode 0600 and deleted on failure, really-chmod-0444 file (non-root POSIX). Checked fine by the reviewer: ydl use after exit, merge order, browser cookies, KeyboardInterrupt cleanup, Windows os.access.

thorwhalen and others added 2 commits October 27, 2026 01:17
…_COPY (#33)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…le), one helper for the three sites (#33 review)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@thorwhalen
thorwhalen merged commit a53fd2c into main Oct 27, 2026
12 checks passed
@thorwhalen
thorwhalen deleted the cookies-private-copy-33 branch October 27, 2026 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cookies_file: read-only cookies file and parallel workers (yt-dlp rewrites the file on exit)

1 participant