Expand tilde in template (Fixes #1639)
authorPhilipp Hagemeister <phihag@phihag.de>
Tue, 22 Oct 2013 20:28:19 +0000 (22:28 +0200)
committerPhilipp Hagemeister <phihag@phihag.de>
Tue, 22 Oct 2013 20:28:26 +0000 (22:28 +0200)
youtube_dl/YoutubeDL.py

index 296c0f9924940d145c95226ba0dd27a61f700253..095692bb3eb6db2228ad26d30043fbe82d51df2a 100644 (file)
@@ -288,13 +288,15 @@ class YoutubeDL(object):
             if template_dict['playlist_index'] is not None:
                 template_dict['playlist_index'] = u'%05d' % template_dict['playlist_index']
 
-            sanitize = lambda k,v: sanitize_filename(
+            sanitize = lambda k, v: sanitize_filename(
                 u'NA' if v is None else compat_str(v),
                 restricted=self.params.get('restrictfilenames'),
-                is_id=(k==u'id'))
-            template_dict = dict((k, sanitize(k, v)) for k,v in template_dict.items())
+                is_id=(k == u'id'))
+            template_dict = dict((k, sanitize(k, v))
+                                 for k, v in template_dict.items())
 
-            filename = self.params['outtmpl'] % 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')