diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-06-03 23:30:38 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-06-06 00:59:04 +0530 |
commit | 752cda3880f30a46bed1d27b69188ab93ad1a368 (patch) | |
tree | 1a6bc38ff775f70f4723be63d6f635f6781d38d6 /yt_dlp/utils.py | |
parent | 9d83ad93d04a1e16fe4a2acadf5f9f10bef6d1b9 (diff) | |
download | hypervideo-pre-752cda3880f30a46bed1d27b69188ab93ad1a368.tar.lz hypervideo-pre-752cda3880f30a46bed1d27b69188ab93ad1a368.tar.xz hypervideo-pre-752cda3880f30a46bed1d27b69188ab93ad1a368.zip |
Fix and refactor `prepare_outtmpl`
The following tests would have failed previously:
%(id)d %(id)r
%(ext)s-%(ext|def)d
%(width|)d
%(id)r %(height)r
%(formats.0)r
%s
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r-- | yt_dlp/utils.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index dea7d85cd..72fd8a0e7 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -4393,15 +4393,17 @@ OUTTMPL_TYPES = { # As of [1] format syntax is: # %[mapping_key][conversion_flags][minimum_width][.precision][length_modifier]type # 1. https://docs.python.org/2/library/stdtypes.html#string-formatting -FORMAT_RE = r'''(?x) +STR_FORMAT_RE = r'''(?x) (?<!%) % - \({0}\) # mapping key - (?:[#0\-+ ]+)? # conversion flags (optional) - (?:\d+)? # minimum field width (optional) - (?:\.\d+)? # precision (optional) - [hlL]? # length modifier (optional) - (?P<type>[diouxXeEfFgGcrs%]) # conversion type + (?P<has_key>\((?P<key>{0})\))? # mapping key + (?P<format> + (?:[#0\-+ ]+)? # conversion flags (optional) + (?:\d+)? # minimum field width (optional) + (?:\.\d+)? # precision (optional) + [hlL]? # length modifier (optional) + [diouxXeEfFgGcrs] # conversion type + ) ''' |