In yt-dlp, the "too long filename" issue is a faq. (See e.g. Issue 1136 and PR 12450.) In particular it's problematic about these two points:
1. When you're downloading multiple files: The process can abort unpredictably at the moment when it encounters one long filename.
2. When downloading the video file took long, and only the audio file is bad. For example in the hls format the intermediate audio filename is long, like this: hls-3470-1+hls-ts_AUDIO-0_2-pro_a69fdcaecd6b46e781a9363dfb93006. In such case you can avoid downloading again by doing some manual fix (with multiple steps), but it's cumbersome.
I created a "definitive" patch. It does:
1. The temporary files are named "<id>.<ext>". This always succeeds except absurdly long IDs.
2. If possible, rename it to the final name.
3. If it's too long, the final name is "<id>.<ext>", and the intended filename is saved in the file "<id>.target_filename" (This too succeeds 99.9999%.)
4. (Probably you're not intested.) It works with temporary directory, '--paths temp:foo', i.e. the final files are moved to the final directory.
"-o / --output" works as before. For example you can try it with this 1sec video with the dtoo long filename.
The limitation is that only the main, media file is handled, and other files (thumbnails, subtitle, info-json etc) are left unfixed. For example if you don't give any option, yt-dlp tries to save them in <title>-<id>.<ext> as before.
This is why I don't open a new issue or a PR to the upstream.
For the complete fix, you have to overhaul prepare_filename() in <top>/yt_dlp/YoutubeDL.py. Don't ask me to carry it out.
For other bugs, let me know.
Hope this helps. Best regards.
My project home: https://gitlab.com/teika/yt-dlp-fix
