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
[Bug] aria2 ignores whitespace around filenames, causing postprocessing to fail #276
Comments
$ yt-dlp -o " test.%(ext)s " YBHQbu5rbdQ --get-filename
test.webm |
Actually, this behavior is inconsistent.
The stripping is done only when the argument is taken from the command line. The best solution probably is to "fix" the stripping from command-line and to do a renaming when passing through |
Adding a rename step to the aria2 extractor sounds fine to me (along with restoring the previous @fstirlitz I noticed that you added a thumbs down to the initial post. Was this perhaps accidental, or do you have another opinion on the issue/proposed solutions? |
My stance is just like youtube-dl’s: it’s bug in aria2, so let them fix it. Send a patch their way (apparently someone has already figured out how to fix it); if they refuse it, send it to downstream packagers like Debian. |
I see. For the reasons given in my post (with aria2 barely seeing maintenance as it is) this seems unviable.
Even if Debian were to accept it (I'm not familiar with their policy on disputed patches), this would produce a worse situation than before. Now we'd see diverging behaviour - not just between different versions of aria2 - but depending on how the user obtained the utility. With a package manager vs self-compiled vs official binary, on certain flavours of Linux vs other flavours of Linux vs macOS vs Windows. We'd almost certainly have to end up fixing it on our end eventually as well for non-Debian/non-package-manager users. If this had involved a more commonly reported bug, I'm sure we'd also strongly prefer the ability to diagnose a known issue right away by looking at the version number instead of having to ask the reporting user how they obtained their installation of aria2 and whether it includes unofficial patches. |
It turns out a fix is actually much simpler than I initially thought. It is possible to make aria2c accept the whitespaces as long as they are not the first/last characters in the given argument. So we can simply pass PS: ofc, there needs to be a check for absolute path and |
For what it's worth, all of this is either far worse--or not an issue at all--on Windows, because it basically doesn't allow filenames to begin or end with the space character at all:
Although you can forcibly give files such names by tampering with low-level disk APIs, attempting to access them will likely rampantly fail throughout the OS. So this is already a "diverging behaviour" in But seriously, all this is burying the lede... beyond the platform inconsistency there's actually a full-blown bug in Line 4565 in 14a0860
↓ ↓ 'default': '[%(title)s] %(id)s.%(ext)s', While I realize this will never happen (because it would break just about every user in the world), we should at least acknowledge that changing the specification of the default output template (as shown, or anything else that trivally eliminates the problem) is actually the correct fix here. Of course, if the |
Checklist
Verbose log
Description
aria2 has a long-standing issue causing it to ignore spaces at the beginning and end of filenames provided to its
--out
flag even when the value is quoted. Given that the title of some YouTube videos begin with a space, this causes issues with the default naming pattern.There's an open issue for it in the aria2 repo but given that its not seen much development lately and there are conflicting opinions on whether it should be fixed at all, it seems unlikely to get resolved any time soon. There have been issues created for this in the youtube-dl issue tracker as well, but these have been closed with the stance that aria2 should fix it on their end. I hope the yt-dlp project can be a bit more pragmatic.
I see two ways to handle it. Either by making trimming whitespace a normal step of the filename sanitization process or by renaming the files right after they have been processed by aria2 to restore the lost spaces.
Here's an example of a video with a title displaying this issue when downloaded: https://www.youtube.com/watch?v=8_SepdI_RmU
The text was updated successfully, but these errors were encountered: