This is a tutorial and I can confirm this works in both CLI programs, as I use them both interchangeably.
[all identifying info scrubbed/changed].
I was getting sick of twitter media downloads failing due to these LongName errors so I did some digging.
This is written for all the non-gui downloaders...get ready for the most convoluted PITA workaround..but it works.
When I scrape up notable media tidbits I usually have a file open with this template:
youtube-dl -f http-832 "https://twitter.com/i/status/6500000802300000089" --trim-filenames 100
It’s a template because you may need to change things to make the commands/arguments acceptable. We will come back to that.
This is a common yt-dlp
and youtube-dl
error:
youtube-dl https://twitter.com/i/status/16500000802300000089
[twitter] 165000008023000000899: Downloading guest token
[twitter] 16500000802300000089: Downloading JSON metadata
[twitter] 1653802802307801089: Downloading m3u8 information
[info] 16500000802300000089: Downloading 1 format(s): http-2176
ERROR: unable to open for writing: [Errno 36] File name too long: ‘Twitter title with 500 words here. Twitter title with 500 words here. Twitter title with 500 words here.Twitter title with 500 words here.Twitter title with 500 words here.Twitter title with 500 words here.Twitter title with 500 words here.[02268683276288].mp4.part'
Back to the template. Take your handy command and use it.
$ youtube-dl -f http-832 "https://twitter.com/i/status/6500000802300000089" --trim-filenames 100
[twitter] Extracting URL: https://twitter.com/i/status/6500000802300000089
[twitter] 6500000802300000089: Downloading guest token
[twitter] 6500000802300000089: Downloading JSON metadata
[twitter] 6500000802300000089: Downloading m3u8 information
[info] 6500000802300000089: Downloading 1 format(s): http-832
[download] Destination: 500 word title much shorter now [6500000802300000089].mp4
[download] 100% of 9.02MiB in 00:00:01 at 5.97MiB/s
--Success. The –f
is the argument. the http-832
is the download format. “http address in quotes” is next, then the hyphened words. 185 is common in examples but I prefer 100 letters or smaller.
Sometimes this happens when the http-832 format is not available:
$ youtube-dl -f http-832 "https://twitter.com/i/status/6500000802300000089" --trim-filenames 100
[twitter] Extracting URL: https://twitter.com/i/status/65000008023000000899
[twitter] 6500000802300000089: Downloading guest token
[twitter] 6500000802300000089: Downloading JSON metadata
[twitter] 6500000802300000089: Downloading m3u8 information
ERROR: [twitter] 6500000802300000089: Requested format is not available. Use --list-formats for a list of available formats
so:
(Youtube-dl + arg + title not in quote marks_
$ youtube-dl --list-formats https://twitter.com/i/status/6500000802300000089
[twitter] Extracting URL: https://twitter.com/i/status/6500000802300000089
[twitter] 6500000802300000089: Downloading guest token
[twitter]6500000802300000089: Downloading JSON metadata
[twitter] 6500000802300000089: Downloading m3u8 information
[info] Available formats for6500000802300000089:
ID EXT RESOLUTION │ FILESIZE TBR PROTO │ VCODEC VBR ACODEC ABR
──────────────────────────────────────────────────────────────────────────────────
hls-288 mp4 480x270 │ ~ 7.50MiB 288k m3u8 │ avc1.4d001e 288k mp4a.40.2 0k
http-288 mp4 480x270 │ ~ 7.50MiB 288k https │ unknown 288k unknown 0k
hls-832 mp4 640x360 │ ~21.67MiB 832k m3u8 │ avc1.4d001f 832k mp4a.40.2 0k
http-632 mp4 640x360 │ ~21.67MiB 832k https │ unknown 832k unknown 0k
hls-2176 mp4 1280x720 │ ~56.66MiB 2176k m3u8 │ avc1.640020 2176k mp4a.40.2 0k
http-2176 mp4 1280x720 │ ~56.66MiB 2176k https │ unknown 2176k unknown 0k
From my reading 832 and 632 are the common ones so I just alternate those in case of a format errors.
So now adjust template because you can see the 632 is available:
$ youtube-dl -f http-632 "https://twitter.com/i/status/6500000802300000089" --trim-filenames 100
[twitter] Extracting URL: https://twitter.com/i/status/ 6500000802300000089
[twitter] 6500000802300000089: Downloading guest token
[twitter] 6500000802300000089: Downloading JSON metadata
[twitter] 6500000802300000089: Downloading m3u8 information
[info] 65000008023000000898: Downloading 1 format(s): http-832
[download] Suddenly Truncated File Now Her. [6500000802300000089].mp4
--Success again. I have a desktop file at easy access for the main template and the plan B (list formats) command. I know it looks daunting but I’m already used to it. Hope you can use it. Cheers.
edit/format