]> jfr.im git - yt-dlp.git/commitdiff
[metadatafromtitle] Fix bug when extracting data from numeric fields
authorpukkandan <redacted>
Sat, 30 Jan 2021 09:06:10 +0000 (14:36 +0530)
committerpukkandan <redacted>
Sat, 30 Jan 2021 09:06:10 +0000 (14:36 +0530)
:ci skip dl

youtube_dlc/postprocessor/metadatafromfield.py

index eb774326b8d7c730564c4cd12df92773975247a9..716911b21f26af10b92d73d04755ea3fe89de333 100644 (file)
@@ -4,6 +4,7 @@
 
 from .common import PostProcessor
 from ..compat import compat_str
+from ..utils import str_or_none
 
 
 class MetadataFromFieldPP(PostProcessor):
@@ -48,8 +49,12 @@ def run(self, info):
             if field not in info:
                 self.report_warning('Video doesnot have a %s' % field)
                 continue
+            data_to_parse = str_or_none(info[field])
+            if data_to_parse is None:
+                self.report_warning('Field %s cannot be parsed' % field)
+                continue
             self.write_debug('Searching for r"%s" in %s' % (regex, field))
-            match = re.search(regex, info[field])
+            match = re.search(regex, data_to_parse)
             if match is None:
                 self.report_warning('Could not interpret video %s as "%s"' % (field, dictn['format']))
                 continue