__init__.py -> new --output format + warn if old

- Edited __init__.py so that it uses the new {NAME} rather than the old %(NAME)s --output format
- Moved the backwards compatibility code from YoutubeDL.py to __init__.py
- Display a warning if the old format is used
This commit is contained in:
cousteau 2015-10-18 20:06:54 +02:00
parent 95d9e48547
commit 736c60eaa5

View File

@ -546,8 +546,7 @@ class YoutubeDL(object):
autonumber_size = self.params.get('autonumber_size')
if autonumber_size is None:
autonumber_size = 5
autonumber_templ = '%0' + str(autonumber_size) + 'd'
template_dict['autonumber'] = autonumber_templ % self._num_downloads
template_dict['autonumber'] = '%0*d' % (autonumber_size, self._num_downloads)
if template_dict.get('playlist_index') is not None:
template_dict['playlist_index'] = '%0*d' % (len(str(template_dict['n_entries'])), template_dict['playlist_index'])
if template_dict.get('resolution') is None:
@ -568,10 +567,7 @@ class YoutubeDL(object):
template_dict = collections.defaultdict(lambda: 'NA', template_dict)
outtmpl = self.params.get('outtmpl', DEFAULT_OUTTMPL)
tmpl = compat_expanduser(outtmpl)
# Backwards compatibility fix (deprecated): %(foo)s -> {foo}, %% -> %
tmpl = re.sub(r'(?<!%)((?:%)*)\1%\(([^)]*)\)s', r'\1{\2}', tmpl).replace('%%','%')
filename = sanitize_path(string.Formatter().vformat(tmpl, None, template_dict))
filename = sanitize_path(string.Formatter().vformat(outtmpl, None, template_dict))
# Temporary fix for #4787
# 'Treat' all problem characters by passing filename through preferredencoding
# to workaround encoding issues with subprocess on python2 @ Windows