Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
More advanced output formatting (fallbacks, etc) #23246
Comments
|
@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. |
Checklist
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:
{'title': 'video1', 'track': 'NA'}{'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)siftrackisNA. 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-dlisn'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.