youtube-dl: [Errno 36] File name too long on eCryptfs

Filesystem: EXT4 OS: Ubuntu Linux 14.04 LTS youtube-dl --version: 2015.06.04.1 When I try to download a Vimeo video:

youtube-dl --ignore-errors --restrict-filenames https://vimeo.com/80352108

I got the following error:

ERROR: unable to open for writing: [Errno 36] File name too long: ...

About this issue

  • Original URL
  • State: open
  • Created 9 years ago
  • Reactions: 6
  • Comments: 27

Most upvoted comments

Bug is still here, running cd /tmp helped thx, but permanent fix would be very nice to have.

Long path names are also a problem on Windows. Using symbolic links or juncture points is also a way to fix the issue (so you don’t have to add some messy movement operation) but it makes file structures cluttered.

Please add support for longer file names or have some way to truncate all or part of the string in the options.

EXAMPLE

--output 'C:\longafname\look\how\long\i\keep\growing\%(uploader)s\%(title)st20\%(title)st20-%(id)s.%(ext)s'

Where t is the truncate delimiter and 20 is the number of characters before the string gets truncated.

@chovy This output format fixes it:

-o %(title).100s-%(id)s.%(ext)s

Replace the 100 with whatever you want, a character limit of 220 works good for me on Windows. This still should be implemented in to youtube-dl, though.

I want to just automatically truncate long filenames.

It is not only for Vimeo, but for all services. I sometimes get this error. I believe it is due to a Linux encrypted home. Encrypted home makes the maximum filename size much shorter. Running cd /tmp before running youtube-dl works as a workaround. A better solution would be to first check the maximum filename size, or at least, if it fails try again with shorter filenames.

Since Twitter increased their char limit from 140 to 280 chars, this service is also affected when saving on eCryptfs

A workaround is to download in /tmp and then move the file to the dest folder with a shorter name or use the youtube-dl [...] -o <filename> option.

Hello everyone! I’ve fix it (sort of kludge) with setting limit for output file name in my fork in corresponded branch Hope it helps for somebody

Command:

youtube-dl --verbose --ignore-errors --restrict-filenames https://vimeo.com/80352108

Output:

[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'--verbose', u'--ignore-errors', u'--restrict-filenames', u'https://vimeo.com/80352108']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2015.06.04.1
[debug] Python version 2.7.6 - Linux-4.0.4-x86_64-with-Ubuntu-14.04-trusty
[debug] exe versions: avconv 9.18-6, avprobe 9.18-6, ffmpeg 2.6.3, ffprobe 2.6.3, rtmpdump 2.4
[debug] Proxy map: {'no': 'localhost,127.0.0.0/8,::1'}
[vimeo] 80352108: Downloading webpage
[vimeo] 80352108: Extracting information
[vimeo] 80352108: Downloading webpage
[debug] Invoking downloader on u'https://pdlvimeocdn-a.akamaihd.net/19466/858/207887776.mp4?token2=1433607436_7bc3e3622d36ab86380807a519b67bb7&aksessionid=021f61e14dcae728'
ERROR: unable to open for writing: [Errno 36] File name too long: 'Oliver_Stone_-_La_historia_no_contada_de_Estados_Unidos_09_-_Bush_y_Clinton_-_El_triunfalismo_americano_y_el_nuevo_orden_mundial-80352108.mp4.part'
Traceback (most recent call last):
  File "/usr/local/bin/youtube-dl/youtube_dl/downloader/http.py", line 155, in real_download
    (stream, tmpfilename) = sanitize_open(tmpfilename, open_mode)
  File "/usr/local/bin/youtube-dl/youtube_dl/utils.py", line 249, in sanitize_open
    stream = open(encodeFilename(filename), open_mode)
IOError: [Errno 36] File name too long: 'Oliver_Stone_-_La_historia_no_contada_de_Estados_Unidos_09_-_Bush_y_Clinton_-_El_triunfalismo_americano_y_el_nuevo_orden_mundial-80352108.mp4.part'

I think the limit depends not on the number of characters, but on the number of bytes.

echo -n "one" | wc --bytes  # 3

# not latin characters
echo -n "раз" | wc --bytes  # 6

In my case(Linux), the limit is 255 bytes for the entire path(filename).