mirror of
https://github.com/alexta69/metube.git
synced 2026-09-21 13:35:01 +00:00
6461924bf8
Sites that put a description in the title produce output names past what the filesystem accepts, and the download fails outright with "[Errno 36] File name too long". The name is now shortened to fit inside prepare_filename, which every output path already passes through, so the main file, its chapter files, thumbnails and subtitles stay consistent. The limit is read from the filesystem (PC_NAME_MAX, falling back to 255) and counted in bytes, not characters: a title of accented or CJK characters reaches it in a third of the characters. The extension is kept, a cut landing inside a multi-byte character does not leave a broken sequence, and a reserve is held back for the suffixes yt-dlp appends afterwards -- '.part', '.ytdl', '.f<format_id>', '-Frag<n>' -- since it is those that pushed the reported name over the limit. Names that already fit are untouched, so nothing that downloads today changes name. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>