-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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» should not error #29912
Comments
The general solution to this is a (new) FAQ entry
|
But my ticket is addressing a different point. Shrinking/truncating long filenames should be *default*. It would be an immense step forward in terms of UX to go to «it just works, emits a warning» from «it does not work, errors out; search the error / skim the FAQ».
Of course, if the user has specific needs, they should be able to turn this off and get an error. (maybe via `--fixup` option).
Il 06 settembre 2021 alle 19:33 dirkf ha scritto:
… The general solution to this is a FAQ entry
```
### My download fails because youtube-dl is trying to write to a file whose name is too long for the file system.
Use the `--get-filename` option to see what filename is being proposed. Then adjust, or add, the `-o`/`--output-template` option in your original youtube-dl command to make the filename shorter. For instance, if the extractor for the site sets a very long `title` field and you are using the default output template `%(title)s-%(id)s.%(ext)s`. you could try `-o %(title).50s-%(id)s.%(ext)s` instead to limit length of the filename.
```
--
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#29912 (comment)
|
The previous discussions on this point show that the maintainers (Sergey, at least) won't accept any solution that they see as ad hoc. The project sees the It could have been reasonable to add some sort of filename truncation functionality to the The cross-platform Python APIs don't offer a way of telling if the proposed file name is too long. In general this is a tricky issue because the error is only found once the OS kernel has called into the filesystem driver for the device that is to be written to. We could try modifying
Concerns here:
There might also be additional guidance for developers to avoid extracting |
This is particularly annoying when downloading videos from Twitter as it takes the whole post as file name. |
That's really a bug in the Twitter extractor, IMO. But feel free to apply the patch from the PR linked above and see if it does what you want. |
I don't see any other reasonable solution for the Twitter extractor. Maybe it could pre-truncate the post? That's not any better than just doing it later when constructing the output file name though. I've run into this issue many times, as I usually want to use I would really, really love it if somebody made a |
The defaults really do work in the vast majority of cases. You can write a config file with your preferred options and select it with For instance, you could put If anyone has a suggestion for what (reliably concise) metadata item could be used as the title for media extracted from Twitter, we could make a PR for Twitter specifically. |
I've just tonight run into this bug with the Twitter extractor. You can reproduce it with the following: youtube-dl https://twitter.com/TulsiGabbard/status/1555878318469091330
[twitter] 1555878318469091330: Downloading guest token
[twitter] 1555878318469091330: Downloading JSON metadata
[twitter] 1555878318469091330: Downloading m3u8 information
ERROR: unable to open for writing: [Errno 36] File name too long: 'Tulsi Gabbard 🌺 - Puberty-blocking procedures promoted by the Biden_Harris Admin are child abuse. The FDA has recently confirmed these hormones_drugs have extremely dangerous side effects, like brain swelling and vision loss.-1555878318469091330.mp4.part' Would you be open to a Twitter specific workaround patch? Perhaps the title could be changed to a combination of the uploader name and date, with the tweet text moved to the description field? |
I am also running into this issue. |
Depends on who/what you blame. |
@bryanpaget, you might like to reveal more details of how you "[ran] into this issue", or is it just Twitter again? Also, feel free to review the discussion in PR #29989 to understand why this is a difficult issue to fix retrospectively (other than by following the approach in #29912 (comment)), and possibly contribute to the design of a general solution. |
The forked project,
... By setting a value of ca.
... whereas:
In the case of Twitter, |
I don't see that A good solution would:
Clearly these are not completely consistent requirements, as an output template might be, say, I still hold that the excessive filename length provoked by Twitter is an extractor bug. |
This is actually a bug and shows how poorly implemented the option is! See yt-dlp/yt-dlp#2314. Do not rely on this behavior... |
Geez...
It's not Twitter-specific after all. Just trim the filename length to 255 chars unless a specific parameter is provided by the user to override this limit. |
As before, see #29912 (comment) and #29912 (comment) for why this doesn't happen, at least not as you suggest and not yet. |
Error message seems to come from this part of the code. Could probably catch |
Indeed, as explained by the immediately preceding comment and its linked comments. |
If the file name is too long, its word-by-word name is cuting until it is acceptable for filesystems (255 bytes) (ytdl-org/youtube-dl#29912 and more more more issues)
the first one |
#30839: "if you were actually running yt-dlp ..." Also, 90 isn't a "constant": pick a number that works. |
In C programs, a library limits.h is available on POSIX systems, including vars like PATH_MAX denoting the uniform system limit for the length of an entire file name. The same should be available in Python somehow, just use it to make it work, default behavior should be safe - https://en.wikipedia.org/wiki/Best-effort_delivery |
Some fields are more important than others, like the unique ID's, hashes, and file extensions can never be allowed to be truncated. As few as possible known fields could have an importance priority floating point number internally assigned in the extractor. ^ Then, generally, you can truncate all other fields equally to fit, as it'll be more important to have some knowledge of the contents in the filename than have none at all, and 125, not to mention 255, chars per segment (or even a full path) is a lotta text. If the User is hellbent on changing a sensible default into something very much non-sensible like Something like that. |
I think #29912 (comment) is a reasonable statement of the problem (further suggestions welcome). Unfortunately we haven't been able to make any progress in creating an implementation to meet those requirements, or even in refining the problem to make it more tractable. |
personally I think its good for a project to have goals, and as important if not more important, non goals. the current |
Plainly it's not a showstopping issue but it is one that generates repeated complaints. It's still open in case someone is eventually intrigued enough to work out a solution that meets an adequate subset of the problem constraints, after spending however long it takes locked in the basement with the necessary cold towels wrapped round the head. But we should fix Twitter/X if the extractor is ever viable and updated post-Musk. |
Yeah, having the tool just fail on long file names without the user applying different parameters to mitigate the issue is very rational and an awesome user experience. I mean just defaulting to a template that causes video downloads not to fail with reasonable truncation would be ridiculous. The legions of people coming to the Issues and hopefully reading the FAQ before creating this issue repeatedly shows the wisdom of this decision. 👍 |
What is wrong with following the best-effort rule and utilizing limits.h or similar library if available on some systems? |
When we see your PR implementing that idea and explaining how it meets (or not) the outline requirements above, we'll be able say what, if anything, is wrong with it. |
Perhaps you shouldn't maintain this project if you cant "see" a simple idea. Obviously this algorithm is sub-optimal and poorly implemented, but you should "see" what is missing in your code now. Just use MAX_LENGTH to either:
|
We know how to detect a filename that is too long; the question is how to truncate it in a way that meets the linked requirements as much as possible, when the output template mechanism means that the user can't necessarily know how long the constructed filename will be, and yet almost certainly doesn't want the download to fail if the filename is too long. The proposal doesn't address the hard part of the problem, unlike the not completely successful attempt in #29989. |
What is the current estimate of closing the ticket? PS. From the wall of text you linked I understand, that people who use |
It works the other way. Just set maximum lengths for the fields in the output template that will meet the limits of your OS/filesystem, as well as any others to which you might copy the downloaded file. You should do this for the documented default (set in a config file), and for any specific output template that you pass in The combined abilities of the many contributors to this project and yt-dlp have not so far found an acceptable solution to the general problem posed by this issue. I don't expect the issue to be closed soon or ever, but who knows? |
Don't forget to also add a |
Checklist
Description
To reproduce:
ERROR: unable to open for writing: [Errno 36] File name too long:
My suggestion:
ERROR
put aWARNING
This will improve UX, check bug tracker to see how common this issue is.
#7765 talks about this too (with a linked pull request) but:
The text was updated successfully, but these errors were encountered: