mirror of
https://github.com/yt-dlp/yt-dlp
synced 2024-12-26 21:59:08 +01:00
[outtmpl] Make %s
work in strfformat for all systems
This commit is contained in:
parent
2b24afa6d7
commit
9665f15a96
1 changed files with 2 additions and 0 deletions
|
@ -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