[YoutubeDL] Apply expand_path after output template substitution
authorSergey M․ <dstftw@gmail.com>
Sat, 15 Apr 2017 18:39:07 +0000 (01:39 +0700)
committerSergey M․ <dstftw@gmail.com>
Sat, 15 Apr 2017 18:39:07 +0000 (01:39 +0700)
os.path.expandvars translates '%%' into '%' making output template invalid.
Before: '%%(ext)s' -(expand path)-> '%(ext)s' -(outtmpl subst.)-> 'mp4'
After: '%%(ext)s' -(outtmpl subst.)-> '%(ext)s' -(expand path)-> '%(ext)s'

youtube_dl/YoutubeDL.py

index 3da5200d7b87b4b0be2bddae98585eadf572127d..819b374efe67831d7a6bb829800f47ac200bf1a9 100755 (executable)
@@ -672,8 +672,7 @@ class YoutubeDL(object):
                         FORMAT_RE.format(numeric_field),
                         r'%({0})s'.format(numeric_field), outtmpl)
 
-            tmpl = expand_path(outtmpl)
-            filename = tmpl % template_dict
+            filename = expand_path(outtmpl % template_dict)
             # Temporary fix for #4787
             # 'Treat' all problem characters by passing filename through preferredencoding
             # to workaround encoding issues with subprocess on python2 @ Windows