Repository navigation
fix(ytdlp): cap title length in default filename template - #258
Merged
Merged
Conversation
Long post captions used as titles produced names over the 255-byte NAME_MAX limit, so yt-dlp failed with "[Errno 36] Filename too long". Truncate the title to 200 bytes in the default template, leaving room for the extension and the .fNNN/.part suffixes yt-dlp appends. Signed-off-by: Ilham Syahid S <ilhamsyahids@gmail.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.
Problem
yt-dlp downloads fail for posts whose caption becomes the title, because the default output template
%(title)s.%(ext)shas no length limit:That title is about 330 bytes. Linux caps a file name at 255 bytes (
NAME_MAX), and yt-dlp also appends.fNNNand.partwhile downloading.Fix
Change
DefaultYtdlpFilenameTemplateto%(title).200B.%(ext)s. yt-dlp'sBmodifier truncates by bytes, not characters, and doesn't split multi-byte UTF-8 sequences, so this also holds for non-Latin titles whenrestrict_filenamesis off. The 55 bytes left over cover the extension and the temporary suffixes.Custom templates set through
ytdlp.filename_templateor-oare unchanged.Also updated:
web/ui/src/settingsFields.ts)docs/content/{en,zh}/usage/ytdlp.mdTesting
core/tasks/ytdlp/output_test.gorenders the default template with the localyt-dlpfrom an info JSON (--load-info-json --print filename), so no network is used. It checks that a long ASCII title and a long Arabic title both fit in 255 bytes with the download suffixes added. The test is skipped whenyt-dlpisn't installed.go test ./core/tasks/ytdlp/andgo vetpass.The same change has been running on a v0 deployment, where the title from the error above now produces a 204-byte name.
Note
On an existing install,
ytdlp.filename_templateis a stored setting. If the old default was saved to the database, it keeps it until changed in Settings. New installs get the new default.