Repository navigation
feat: apply yt-dlp config files to downloads - #428
Open
manbearwiz wants to merge 1 commit into
Open
manbearwiz wants to merge 1 commit into
manbearwiz wants to merge 1 commit into
Conversation
The README documents mounting a yt-dlp config directory at /root/.config/yt-dlp, and the 32-bit ARM images write --js-runtimes node to /etc/yt-dlp/config. Neither has had any effect since the server moved from the youtube-dl command line to the embedding API (98bc4fa, 2018): only yt-dlp's command line reads config files. The server now reads them at startup with yt-dlp's own reader, from its system and user lookup, and builds each download's params the way the yt-dlp command line does: one argument list, lowest precedence first -- the server's defaults, the config files, the YDL_* options that are set, then the request's format -- passed to yt-dlp's public parse_options. yt-dlp itself then merges them, so postprocessor order, output templates and metadata options follow its rules with no merging code here. The one exception is a request format, which replaces the conversion from every other source: -x has no negation, so the other converters are dropped and final_ext is the request's. Each YDL_* value yt-dlp takes, and each config file, is checked by yt-dlp at startup; a bad one warns and is ignored, as an unparseable option already is. The log names the config files used, never their contents. /healthz checks the output template downloads actually use. Downloads now start from yt-dlp's command-line defaults rather than its API defaults, e.g. the playlist-stage FFmpegConcat for multi-part videos and --embed-metadata also embedding chapters. Refs #24, #29, #298 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Refs #24, #29, #298. An alternative to #427.
Why
The README tells you to mount a yt-dlp config directory at
/root/.config/yt-dlp, and the 32-bit ARM images write--js-runtimes nodeto/etc/yt-dlp/config. Neither has ever had any effect. Only yt-dlp's command line reads config files; theYoutubeDLembedding API never does. Config support was lost when the server moved from shelling out to the CLI to the Python API in 98bc4fa (Dec 2018); #24 was filed 17 days later. The docs and the ARM config came later, in #329, assuming CLI behavior.How
Instead of merging a config file's params into the server's by hand, the server builds each download the way the yt-dlp command line does. It makes one argument list, lowest precedence first:
.env.example)Config.read_fileYDL_*options the environment or.envsetsformatand passes it to yt-dlp's public
parse_options. yt-dlp then does all the merging: postprocessor order, extra output templates (pl_thumbnail), metadata and chapter options. There is no merging code in the server. EachYDL_*option is now one row mapping it to its CLI flag (YDL_ARGS).The one rule yt-dlp can't express: a request
formatthat names a codec or container replaces the conversion from every other source (the existing one-pipeline rule from #403).-xhas no negation, so the other converters are filtered out afterwards andfinal_extis the request's.Robustness
YDL_*value yt-dlp takes, and each config file, is checked by yt-dlp at startup. A bad one is logged as a warning and ignored, like an unparseable option today, so it can't fail every download.Configand the config-dir helpers aren't in yt-dlp's__all__. If an upgrade moves them, the server logs a warning and runs without config files instead of failing to start./healthzchecks the output template downloads actually use, so a config file's-ocounts.Behavior changes
/etc/yt-dlp/confignow takes effect, so yt-dlp uses the node runtime the image installs.FFmpegConcatfor multi-part videos is present, andYDL_EMBED_METADATAmaps to--embed-metadata, which also embeds chapters.-f best) now appear in the log.Tests
The existing option tests are kept and now compare the postprocessors that run on each file, which leaves out the playlist-stage
FFmpegConcat. New tests cover: system-then-user lookup, no config file, an unparseable config file, a config file replacing defaults, a setYDL_*winning over a config file,/healthzfollowing a config-o, pass-through options, a request format replacing a config conversion (with yt-dlp's ordering andfinal_ext), and a badYDL_*value warning.ruff check,ruff format --checkandpytest(53) pass. I also imported the module with a real config file (--embed-thumbnail,--sponsorblock-remove,-o) and builtYoutubeDLfrom the options for no format,mp3andmp4. The config's output path, SponsorBlock and EmbedThumbnail applied, and the request's converter ran first in each case. No real download was run.🤖 Generated with Claude Code