Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Checklist
Downloading Videos from Twitter
[X ] I've verified that I'm running youtube-dl version 2020.05.08
% /tmp/youtube-dl -v
[debug] youtube-dl version 2020.05.08
[X ] I've checked that all provided URLs are alive and playable in a browser
youtube-dl 'https://twitter.com/mknrdt/status/1263357611950342145'
Verbose log
% youtube-dl 'https://twitter.com/mknrdt/status/1263357611950342145'
[twitter] 1263357611950342145: Downloading guest token
[twitter] 1263357611950342145: Downloading JSON metadata
[twitter] 1263357611950342145: Downloading m3u8 information
ERROR: unable to open for writing: [Errno 36] File name too long: "Mathijs Koenraadt - Absolutely shocking footage has emerged from a black male nurse from Detroit (Jadon H.), who filmed himself beating elderly white men into a bloody pulp. 'Get the fuck off my bed, N.,' he is heard saying. Viewer discretion advised.-1263357611950342145.mp4.part"
Description
It might be a general problem and affect other sites as well, but I've observed it for downloadings from twitter only (but many times):
youtube-dl tries to put the whole tweet into the filename and fails because of exceeding the maximum file name length.
In this case the maximum file name length is 255 (ext4 file system) but youtube-dl tries to use around 285 characters
Workaround: give a filename with option -o (cumbersome)
Solution: Use the statfs system call to get the maximum file name length supported by the file system you're trying to write to and shorten the text put into the filename accordingly (i.e. keep and respect the file name endings like .mp4 and .mp4.part, and the tweet number, and just take a fitting number of characters from the tweet).
See
http://man7.org/linux/man-pages/man2/statfs.2.html