]> jfr.im git - yt-dlp.git/commitdiff
[outtmpl] Change filename sanitization type to `S`
authorpukkandan <redacted>
Thu, 23 Dec 2021 03:33:46 +0000 (09:03 +0530)
committerpukkandan <redacted>
Thu, 23 Dec 2021 03:45:05 +0000 (09:15 +0530)
`F` is already used for float!
Bug in e0fd95737d1a3c4a2bfb470c5408a396c8545ca5

README.md
test/test_YoutubeDL.py
yt_dlp/YoutubeDL.py

index 381e1b263e0f8f65ac3c447fbda8efb78011f702..6a7977d25e9b987b0e5b641c3c989e5135f8e531 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1087,7 +1087,7 @@ # OUTPUT TEMPLATE
 
 1. **Default**: A literal default value can be specified for when the field is empty using a `|` separator. This overrides `--output-na-template`. Eg: `%(uploader|Unknown)s`
 
-1. **More Conversions**: In addition to the normal format types `diouxXeEfFgGcrs`, `B`, `j`, `l`, `q`, `D`, 'F' can be used for converting to **B**ytes, **j**son (flag `#` for pretty-printing), a comma separated **l**ist (flag `#` for `\n` newline-separated), a string **q**uoted for the terminal (flag `#` to split a list into different arguments), to add **D**ecimal suffixes (Eg: 10M), and to sanitize as **F**ilename (flag `#` for restricted), respectively
+1. **More Conversions**: In addition to the normal format types `diouxXeEfFgGcrs`, `B`, `j`, `l`, `q`, `D`, `S` can be used for converting to **B**ytes, **j**son (flag `#` for pretty-printing), a comma separated **l**ist (flag `#` for `\n` newline-separated), a string **q**uoted for the terminal (flag `#` to split a list into different arguments), to add **D**ecimal suffixes (Eg: 10M), and to **S**anitize as filename (flag `#` for restricted), respectively
 
 1. **Unicode normalization**: The format type `U` can be used for NFC [unicode normalization](https://docs.python.org/3/library/unicodedata.html#unicodedata.normalize). The alternate form flag (`#`) changes the normalization to NFD and the conversion flag `+` can be used for NFKC/NFKD compatibility equivalence normalization. Eg: `%(title)+.100U` is NFKC
 
index ee0e5eca58815ee3d12a52585dedfc90fea8a118..61923513eec02bc8624040876ee4caf2e1fee158 100644 (file)
@@ -780,8 +780,8 @@ def expect_same_infodict(out):
         test('%(title5)+#U', 'a\u0301e\u0301i\u0301 A')
         test('%(height)D', '1K')
         test('%(height)5.2D', ' 1.08K')
-        test('%(title4)#F', 'foo_bar_test')
-        test('%(title4).10F', ('foo \'bar\' ', 'foo \'bar\'' + ('#' if compat_os_name == 'nt' else ' ')))
+        test('%(title4)#S', 'foo_bar_test')
+        test('%(title4).10S', ('foo \'bar\' ', 'foo \'bar\'' + ('#' if compat_os_name == 'nt' else ' ')))
         if compat_os_name == 'nt':
             test('%(title4)q', ('"foo \\"bar\\" test"', "'foo _'bar_' test'"))
             test('%(formats.:.id)#q', ('"id 1" "id 2" "id 3"', "'id 1' 'id 2' 'id 3'"))
index 3bbde9b00f25e100f96c279414a53d44c38697e5..6fcd52b9957ce991d10af261af88f6ec9851b350 100644 (file)
@@ -1006,7 +1006,7 @@ def escape_outtmpl(outtmpl):
     def validate_outtmpl(cls, outtmpl):
         ''' @return None or Exception object '''
         outtmpl = re.sub(
-            STR_FORMAT_RE_TMPL.format('[^)]*', '[ljqBUDF]'),
+            STR_FORMAT_RE_TMPL.format('[^)]*', '[ljqBUDS]'),
             lambda mobj: f'{mobj.group(0)[:-1]}s',
             cls._outtmpl_expandpath(outtmpl))
         try:
@@ -1048,7 +1048,7 @@ def prepare_outtmpl(self, outtmpl, info_dict, sanitize=False):
         }
 
         TMPL_DICT = {}
-        EXTERNAL_FORMAT_RE = re.compile(STR_FORMAT_RE_TMPL.format('[^)]*', f'[{STR_FORMAT_TYPES}ljqBUDF]'))
+        EXTERNAL_FORMAT_RE = re.compile(STR_FORMAT_RE_TMPL.format('[^)]*', f'[{STR_FORMAT_TYPES}ljqBUDS]'))
         MATH_FUNCTIONS = {
             '+': float.__add__,
             '-': float.__sub__,
@@ -1167,7 +1167,7 @@ def create_key(outer_mobj):
                     value), str_fmt
             elif fmt[-1] == 'D':  # decimal suffix
                 value, fmt = format_decimal_suffix(value, f'%{fmt[:-1]}f%s' if fmt[:-1] else '%d%s'), 's'
-            elif fmt[-1] == 'F':  # filename sanitization
+            elif fmt[-1] == 'S':  # filename sanitization
                 value, fmt = filename_sanitizer(initial_field, value, restricted='#' in flags), str_fmt
             elif fmt[-1] == 'c':
                 if value: