mirror of
https://github.com/yt-dlp/yt-dlp
synced 2024-12-26 21:59:08 +01:00
Improve fixed template checks
This commit is contained in:
parent
14c300687e
commit
22899cea59
1 changed files with 8 additions and 1 deletions
|
@ -153,8 +153,15 @@ class FileDownloader(object):
|
||||||
"""Print message to stderr."""
|
"""Print message to stderr."""
|
||||||
sys.stderr.write('%s\n' % message)
|
sys.stderr.write('%s\n' % message)
|
||||||
|
|
||||||
|
def fixed_template(self):
|
||||||
|
"""Checks if the output template is fixed."""
|
||||||
|
return (re.search(ur'%\(.+?\)s', self._params['outtmpl']) is None)
|
||||||
|
|
||||||
def download(self, url_list):
|
def download(self, url_list):
|
||||||
"""Download a given list of URLs."""
|
"""Download a given list of URLs."""
|
||||||
|
if len(url_list) > 1 and self.fixed_template():
|
||||||
|
sys.exit('ERROR: fixed output name but more than one file to download')
|
||||||
|
|
||||||
for url in url_list:
|
for url in url_list:
|
||||||
suitable_found = False
|
suitable_found = False
|
||||||
for ie in self._ies:
|
for ie in self._ies:
|
||||||
|
@ -164,7 +171,7 @@ class FileDownloader(object):
|
||||||
suitable_found = True
|
suitable_found = True
|
||||||
results = [x for x in ie.extract(url) if x is not None]
|
results = [x for x in ie.extract(url) if x is not None]
|
||||||
|
|
||||||
if (len(url_list) > 1 or len(results) > 1) and re.search(r'%\(.+?\)s', self._params['outtmpl']) is None:
|
if len(results) > 1 and self.fixed_template():
|
||||||
sys.exit('ERROR: fixed output name but more than one file to download')
|
sys.exit('ERROR: fixed output name but more than one file to download')
|
||||||
|
|
||||||
if self._params.get('simulate', False):
|
if self._params.get('simulate', False):
|
||||||
|
|
Loading…
Reference in a new issue