]> jfr.im git - yt-dlp.git/blobdiff - youtube_dl/YoutubeDL.py
Set 'NA' as the default value for missing fields in the output template (fixes #1931)
[yt-dlp.git] / youtube_dl / YoutubeDL.py
index 2dd7e490710eb81ae5300bbfa5ee03cce932040a..11d4972dd668722b4db93dd3cb7bd7b9d95b1050 100644 (file)
@@ -3,6 +3,7 @@
 
 from __future__ import absolute_import
 
+import collections
 import errno
 import io
 import json
@@ -401,13 +402,11 @@ def prepare_filename(self, info_dict):
                 is_id=(k == u'id'))
             template_dict = dict((k, sanitize(k, v))
                                  for k, v in template_dict.items())
+            template_dict = collections.defaultdict(lambda: u'NA', template_dict)
 
             tmpl = os.path.expanduser(self.params['outtmpl'])
             filename = tmpl % template_dict
             return filename
-        except KeyError as err:
-            self.report_error(u'Erroneous output template')
-            return None
         except ValueError as err:
             self.report_error(u'Error in output template: ' + str(err) + u' (encoding: ' + repr(preferredencoding()) + ')')
             return None