How do I change the youtube-dl date format in filenames? (From %Y%m%d to %Y-%m-%d)

Viewed 1756

I would like to save youtube-dl files in the upload date first. However, I dislike the default date format.

I'm working on a Python script. How can I change the dates from say:

20171024

to:

2017-10-24

I don't understand how I can do a date conversion when the output template is a string. Like so:

'%(upload_date)s_%(title)s.%(ext)s'

If I could directly access (upload_date) and wrap it in a function to reformat the date, this would be simple.

date = %(upload_date)s
date.strftime('%Y-%m-%d')

This obviously won't work, but I'm looking a solution that would be the equivalent of doing that.

Within it's code, I can see the youtube-dl uses the function unified_strdate to add the upload date. But, when I've tried changing the format to %Y-%m-%d I get a ValueError. (I'm also reluctant to mess around in a Python package and possibly lose those changes if I update the package).

0 Answers
Related