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

output filename formats don't work as expected #26953

Closed
Eli-the-Bearded opened this issue Oct 21, 2020 · 3 comments
Closed

output filename formats don't work as expected #26953

Eli-the-Bearded opened this issue Oct 21, 2020 · 3 comments
Labels

Comments

@Eli-the-Bearded
Copy link

@Eli-the-Bearded Eli-the-Bearded commented Oct 21, 2020

Checklist

  • I'm reporting a feature request
  • I've verified that I'm running youtube-dl version 2020.09.20
  • I've searched the bugtracker for similar feature requests including closed ones

Description

Quoth the youtube-dl docs:

The basic usage is not to set any template arguments when downloading a single file, like in youtube-dl -o funny_video.flv "https://some/video". However, it may contain special sequences that will be replaced when downloading each video. The special sequences may be formatted according to python string formatting operations. For example, %(NAME)s or %(NAME)05d. To clarify, that is a percent symbol followed by a name in parentheses, followed by formatting operations.

Quoth the linked python string formatting operations:

's' String (converts any Python object using str()). (6)

6 If the object or format provided is a unicode string, the resulting string will also be unicode. The precision determines the maximal number of characters used.

$ youtube-dl -U
youtube-dl is up-to-date (2020.09.20)
$ youtube-dl -o '%(title)40s-%(id)s.%(ext)s' https://twitter.com/RebeccaRHelm/status/1318207763164573697
[twitter] 1318207763164573697: Downloading guest token
[twitter] 1318207763164573697: Downloading JSON metadata
[twitter] 1318207763164573697: Downloading m3u8 information
ERROR: unable to open for writing: [Errno 36] File name too long: "Open Ocean Exploration - In 2018 the @oceanexplorer saw THIS in the Gulf of Mexico!! According to their cephalopod biologist, it's \xe2\x80\x9cprobably the most bizarre squid I\xe2\x80\x99ve ever seen.\xe2\x80\x9d As far as I can tell we don't know much more about it! A stunning deep-sea mystery! \xf0\x9f\x8e\xa5https -_t.co_9vS5S0HLqC #DailyJelly-1318207763164573697.mp4.part"

If "maximal number of characters" can be used on strings, please document how it works since Python hasn't bothered. (I'm a C programmer, not a Python programmer.)

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Oct 21, 2020

It works exactly the same as C's printf, so that there must be a dot before precision.

@dstftw dstftw closed this Oct 21, 2020
@dstftw dstftw added the invalid label Oct 21, 2020
@Eli-the-Bearded
Copy link
Author

@Eli-the-Bearded Eli-the-Bearded commented Oct 22, 2020

Did you fix the docs? No. I don't believe this should be closed. Here:

diff --git a/README.md b/README.md
index cd8856828..e4be8a972 100644
--- a/README.md
+++ b/README.md
@@ -594,7 +594,9 @@ To use percent literals in an output template use `%%`. To output to stdout use
 
 The current default template is `%(title)s-%(id)s.%(ext)s`.
 
-In some cases, you don't want special characters such as 中, spaces, or &, such as when transferring the downloaded filename to a Windows system or the filename through an 8bit-unsafe channel. In these cases, add the `--restrict-filenames` flag to get a shorter title:
+In some cases, you don't want special characters such as 中, spaces, or &, such as when transferring the downloaded filename to a Windows system or the filename through an 8bit-unsafe channel. In these cases, add the `--restrict-filenames` flag to get a shorter title.
+
+In some other cases the title may make the file name too long for the system. Specifying a maximum length for the title is one option, eg limit the title part to 60 characters: `%(title).60s-%(id)s.%(ext)s`.
 
 #### Output template and Windows batch files
@Eli-the-Bearded
Copy link
Author

@Eli-the-Bearded Eli-the-Bearded commented Oct 22, 2020

That was my request after all: please document how it works

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.