]> jfr.im git - yt-dlp.git/commitdiff
[outtmpl] Fix some minor bugs
authorpukkandan <redacted>
Tue, 20 Jun 2023 23:45:03 +0000 (05:15 +0530)
committerpukkandan <redacted>
Wed, 21 Jun 2023 00:40:39 +0000 (06:10 +0530)
Closes #7164

test/test_YoutubeDL.py
yt_dlp/YoutubeDL.py
yt_dlp/utils/_utils.py

index ee6c52713581071a691ff0ffbcbbf711abb0b206..ccc9e36f34a58c9a514bc810b79e40fce552198a 100644 (file)
@@ -755,7 +755,7 @@ def expect_same_infodict(out):
         test('%(id)d %(id)r', "1234 '1234'")
         test('%(id)r %(height)r', "'1234' 1080")
         test('%(ext)s-%(ext|def)d', 'mp4-def')
-        test('%(width|0)04d', '0000')
+        test('%(width|0)04d', '0')
         test('a%(width|b)d', 'ab', outtmpl_na_placeholder='none')
 
         FORMATS = self.outtmpl_info['formats']
index 077a37b305477a7ea26b705806f5e76151bd8deb..a546ce65ba450710790f7e4fb992ef2f5f73a7fa 100644 (file)
@@ -1286,17 +1286,17 @@ def create_key(outer_mobj):
             if fmt == 's' and value is not None and key in field_size_compat_map.keys():
                 fmt = f'0{field_size_compat_map[key]:d}d'
 
-            if value is None:
-                value = default
-            elif replacement is not None:
+            if None not in (value, replacement):
                 try:
                     value = replacement_formatter.format(replacement, value)
                 except ValueError:
-                    value = na
+                    value, default = None, na
 
             flags = outer_mobj.group('conversion') or ''
             str_fmt = f'{fmt[:-1]}s'
-            if fmt[-1] == 'l':  # list
+            if value is None:
+                value, fmt = default, 's'
+            elif fmt[-1] == 'l':  # list
                 delim = '\n' if '#' in flags else ', '
                 value, fmt = delim.join(map(str, variadic(value, allowed_types=(str, bytes)))), str_fmt
             elif fmt[-1] == 'j':  # json
index 256e2db5a99869dc9f0d5afd4ad567c12b1fff6e..d10d621d544d92f7258d03386f225dcaab9cd452 100644 (file)
@@ -3302,7 +3302,7 @@ def q(qid):
 '''
 
 
-STR_FORMAT_TYPES = 'diouxXeEfFgGcrs'
+STR_FORMAT_TYPES = 'diouxXeEfFgGcrsa'
 
 
 def limit_length(s, length):