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

More advanced output formatting (fallbacks, etc) #23246

Closed
Mattwmaster58 opened this issue Nov 28, 2019 · 1 comment
Closed

More advanced output formatting (fallbacks, etc) #23246

Mattwmaster58 opened this issue Nov 28, 2019 · 1 comment

Comments

@Mattwmaster58
Copy link

@Mattwmaster58 Mattwmaster58 commented Nov 28, 2019

Checklist

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

Description

I think that it would be helpful to allow more flexible output file formatting. Currently, the only way to format the output is with Python %-string interpolation. I think if we implemented formatting with Python f-strings it would allow for more advanced output formatting operations. For example:

Playlist 1:

  • video 1: {'title': 'video1', 'track': 'NA'}
  • video 2: {'title': 'video2', 'track': 'Video #2'}

Suppose you wanted to download the videos in the playlist in the format %(track)s.%(ext)s, and fallback to %(title)s.%(ext)s if track is NA. With the current system, it's not possible to do this. With f-strings you do something like this:

{t[track] if t[track] != 'NA' else t[title]}.{t[ext]}

Admittedly, it's quite a bit more verbose, but allows for more flexible output formatting. I think such a big change to youtube-dl isn't ideal, especially since in most cases it will only make output filename formatting will become more closely, so I think it would be best for this feature to exist in parallel with the current implementation.

I realize that f-strings are only supported in Python 3.6+, so I'm not sure how/if we would be able to implement this, or if there's a better method of doing this altogether.

@dstftw dstftw closed this Nov 28, 2019
@dstftw dstftw added the duplicate label Nov 28, 2019
@Mattwmaster58
Copy link
Author

@Mattwmaster58 Mattwmaster58 commented Nov 28, 2019

@dstftw Would you mind pointing me to the relevant issue? I search a few different variations of the title but couldn't find anything related.

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.