mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 02:21:29 +00:00
[outtmpl] Make %s
work in strfformat for all systems
This commit is contained in:
parent
2b24afa6d7
commit
9665f15a96
|
@ -2567,6 +2567,8 @@ def strftime_or_none(timestamp, date_format, default=None):
|
|||
datetime_object = datetime.datetime.utcfromtimestamp(timestamp)
|
||||
elif isinstance(timestamp, str): # assume YYYYMMDD
|
||||
datetime_object = datetime.datetime.strptime(timestamp, '%Y%m%d')
|
||||
date_format = re.sub( # Support %s on windows
|
||||
r'(?<!%)(%%)*%s', rf'\g<1>{int(datetime_object.timestamp())}', date_format)
|
||||
return datetime_object.strftime(date_format)
|
||||
except (ValueError, TypeError, AttributeError):
|
||||
return default
|
||||
|
|
Loading…
Reference in a new issue