Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File name too long - videos with long/illegal titles cause failure to create new file #31884

Closed
5 of 6 tasks
NeatNit opened this issue Mar 19, 2023 · 2 comments
Closed
5 of 6 tasks

Comments

@NeatNit
Copy link

NeatNit commented Mar 19, 2023

Checklist

  • I'm reporting a broken site support issue
  • I've verified that I'm running youtube-dl version 2021.12.17 sudo pip install "youtube_dl@git+https://github.com/ytdl-org/youtube-dl.git@master" (to fix [YouTube] Unable to extract uploader id #31530)
  • I've checked that all provided URLs are alive and playable in a browser
  • I've checked that all URLs and arguments with special characters are properly quoted or escaped
  • I've searched the bugtracker for similar bug reports including closed ones
  • I've read bugs section in FAQ

Verbose log

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--verbose', 'https://www.youtube.com/watch?v=Gzqoxm9iNKU']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2021.12.17
[debug] Python version 3.10.6 (CPython) - Linux-5.15.0-67-generic-x86_64-with-glibc2.35
[debug] exe versions: none
[debug] Proxy map: {}
[youtube] Gzqoxm9iNKU: Downloading webpage
[debug] [youtube] Decrypted nsig tsvab8J75PtKkv => -Q4dsf1uLbDslQ
[debug] [youtube] Decrypted nsig gFy_EUOcE4rxf7 => 5qz2JrPM0CpqwQ
[debug] Default format spec: best/bestvideo+bestaudio
[debug] Invoking downloader on 'https://rr1---sn-jjjpa-ua8e.googlevideo.com/videoplayback?expire=1679288574&ei=npQXZOXkM9Wq1gamhpn4Cw&ip=2a00%3Ac281%3A1a9b%3Af001%3A4a1b%3Aa4d5%3A589c%3A7037&id=o-AEY1A8NhzqvAumjbMHJ3oPQZXUREreuH9uq5ucQKtjU0&itag=22&source=youtube&requiressl=yes&mh=a4&mm=31%2C29&mn=sn-jjjpa-ua8e%2Csn-ua87zn7l&ms=au%2Crdu&mv=m&mvi=1&pcm2cms=yes&pl=40&initcwndbps=1041250&vprv=1&mime=video%2Fmp4&ns=WQbOPSAPli6CcrUhXcGbYQoL&cnr=14&ratebypass=yes&dur=533.339&lmt=1679242642831295&mt=1679266651&fvip=2&fexp=24007246&c=WEB&txp=6318224&n=5qz2JrPM0CpqwQ&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Ccnr%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRAIgK3RvY9d7US_qYWB8YSHmrPHTTb6iqRHuaqBNHFVfgBsCIF22B9MetmTYkSwv9zeRaABMyIOr05uZhqJDX88ue25h&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpcm2cms%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIgJdu6CyDX-7fzktp8Ygfah3or08ED_YDg8W395I_gfHoCIQCtP96RDaAdHq8ttDfS-nzzAXXJQDBDbKSVj8-bP2WLVw%3D%3D'
ERROR: unable to open for writing: [Errno 36] File name too long: "קורבנות בג'ץ - סדרת כתבות חדשה על האנשים שנרמסו תחת גלגלי מערכת המשפט _ פרק 1-Gzqoxm9iNKU.mp4.part"
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/youtube_dl/downloader/http.py", line 259, in download
    ctx.stream, ctx.tmpfilename = sanitize_open(
  File "/usr/local/lib/python3.10/dist-packages/youtube_dl/utils.py", line 2077, in sanitize_open
    stream = open(encodeFilename(filename), open_mode)
OSError: [Errno 36] File name too long: "קורבנות בג'ץ - סדרת כתבות חדשה על האנשים שנרמסו תחת גלגלי מערכת המשפט _ פרק 1-Gzqoxm9iNKU.mp4.part"

Description

I tried to download this video: https://www.youtube.com/watch?v=Gzqoxm9iNKU
(politics note: the video is basically far-right propaganda in Israel, consider yourself lucky if you don't need to care about the depressing context surrounding this so-called "news report")

The download failed with the error:
ERROR: unable to open for writing: [Errno 36] File name too long: "קורבנות בג'ץ - סדרת כתבות חדשה על האנשים שנרמסו תחת גלגלי מערכת המשפט _ פרק 1-Gzqoxm9iNKU.mp4.part"

Easy workaround was to use the --id flag to remove the video title entirely, which succeeded:

$ youtube-dl --id https://www.youtube.com/watch?v=Gzqoxm9iNKU
[youtube] Gzqoxm9iNKU: Downloading webpage
[download] Destination: Gzqoxm9iNKU.mp4
[download] 100% of 107.94MiB in 00:24

I would expect youtube-dl to implement a fail-safe, especially when no custom filename template was specified: if it failed to create the original file for whatever reason, try again with a safer format e.g. the --id behaviour.

@dirkf
Copy link
Contributor

dirkf commented Mar 19, 2023

This is a long-standing but apparently insoluble problem.

If this is an issue for you, use an output template with a limited title length: say, %(title).50s instead of %(title)s.

Duplicate of #29912, with extensive discussion, and see also linked unmerged PR #29989.

@dirkf dirkf closed this as not planned Won't fix, can't repro, duplicate, stale Mar 19, 2023
@NeatNit
Copy link
Author

NeatNit commented Mar 19, 2023

Interesting, I did search for duplicates but must have missed these. All I found was #30936, which was correctly tagged as "a pity" :)

I will look at the discussion, if I disagree about "apparently insoluble" you will hear from my lawyers-- I mean, from my pull request. (Don't hold your breath, I have a bad habit of never doing what I say I'll do)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants