diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-09-17 11:34:04 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-09-17 11:34:04 +0530 |
commit | 9665f15a960c4e274b0be5fbf22e6f4a6680d162 (patch) | |
tree | 1265801b8173e705689a5c295d304d1fd571bf15 | |
parent | 2b24afa6d7f0ed09a663b4483d29f7c05258edfe (diff) | |
download | hypervideo-pre-9665f15a960c4e274b0be5fbf22e6f4a6680d162.tar.lz hypervideo-pre-9665f15a960c4e274b0be5fbf22e6f4a6680d162.tar.xz hypervideo-pre-9665f15a960c4e274b0be5fbf22e6f4a6680d162.zip |
[outtmpl] Make `%s` work in strfformat for all systems
-rw-r--r-- | yt_dlp/utils.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index a24ca828e..f6f7c38d1 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -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 |