]> jfr.im git - yt-dlp.git/commitdiff
[metadataparser] Don't set `None` when the field didn't match
authorpukkandan <redacted>
Fri, 29 Jul 2022 12:44:06 +0000 (18:14 +0530)
committerpukkandan <redacted>
Sat, 30 Jul 2022 20:50:10 +0000 (02:20 +0530)
Fixes: https://github.com/ytdl-org/youtube-dl/issues/31118#issuecomment-1198254512
yt_dlp/postprocessor/metadataparser.py

index 51b927b9116a103c07e16721c473474652b19702..f574f23300e0cb7ba822cdc597e197b04614ca61 100644 (file)
@@ -1,7 +1,7 @@
 import re
 
 from .common import PostProcessor
-from ..utils import Namespace
+from ..utils import Namespace, filter_dict
 
 
 class MetadataParserPP(PostProcessor):
@@ -68,9 +68,9 @@ def f(info):
             if match is None:
                 self.to_screen(f'Could not interpret {inp!r} as {out!r}')
                 return
-            for attribute, value in match.groupdict().items():
+            for attribute, value in filter_dict(match.groupdict()).items():
                 info[attribute] = value
-                self.to_screen('Parsed %s from %r: %r' % (attribute, template, value if value is not None else 'NA'))
+                self.to_screen(f'Parsed {attribute} from {template!r}: {value!r}')
 
         template = self.field_to_template(inp)
         out_re = re.compile(self.format_to_regex(out))