|
|
@ -478,11 +478,7 @@ class YoutubeDL(object):
|
|
|
|
i for i, a in enumerate(argv)
|
|
|
|
i for i, a in enumerate(argv)
|
|
|
|
if re.match(r'^-[0-9A-Za-z_-]{10}$', a)]
|
|
|
|
if re.match(r'^-[0-9A-Za-z_-]{10}$', a)]
|
|
|
|
if idxs:
|
|
|
|
if idxs:
|
|
|
|
correct_argv = (
|
|
|
|
correct_argv = ['youtube-dl', *[a for i, a in enumerate(argv) if i not in idxs], '--', *[argv[i] for i in idxs]]
|
|
|
|
['youtube-dl']
|
|
|
|
|
|
|
|
+ [a for i, a in enumerate(argv) if i not in idxs]
|
|
|
|
|
|
|
|
+ ['--'] + [argv[i] for i in idxs]
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
self.report_warning(
|
|
|
|
self.report_warning(
|
|
|
|
'Long argument string detected. '
|
|
|
|
'Long argument string detected. '
|
|
|
|
'Use -- to separate parameters and URLs, like this:\n%s\n' %
|
|
|
|
'Use -- to separate parameters and URLs, like this:\n%s\n' %
|
|
|
@ -554,7 +550,7 @@ class YoutubeDL(object):
|
|
|
|
elif not check_quiet or not self.params.get('quiet', False):
|
|
|
|
elif not check_quiet or not self.params.get('quiet', False):
|
|
|
|
message = self._bidi_workaround(message)
|
|
|
|
message = self._bidi_workaround(message)
|
|
|
|
terminator = ['\n', ''][skip_eol]
|
|
|
|
terminator = ['\n', ''][skip_eol]
|
|
|
|
output = message + terminator
|
|
|
|
output = '{0}{1}'.format(message, terminator)
|
|
|
|
|
|
|
|
|
|
|
|
self._write_string(output, self._screen_file, only_once=only_once)
|
|
|
|
self._write_string(output, self._screen_file, only_once=only_once)
|
|
|
|
|
|
|
|
|
|
|
@ -580,18 +576,14 @@ class YoutubeDL(object):
|
|
|
|
self._write_string('\033]0;%s\007' % message, self._screen_file)
|
|
|
|
self._write_string('\033]0;%s\007' % message, self._screen_file)
|
|
|
|
|
|
|
|
|
|
|
|
def save_console_title(self):
|
|
|
|
def save_console_title(self):
|
|
|
|
if not self.params.get('consoletitle', False):
|
|
|
|
if not self.params.get('consoletitle', False) or self.params.get('simulate', False):
|
|
|
|
return
|
|
|
|
|
|
|
|
if self.params.get('simulate', False):
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
if compat_os_name != 'nt' and 'TERM' in os.environ:
|
|
|
|
if compat_os_name != 'nt' and 'TERM' in os.environ:
|
|
|
|
# Save the title on stack
|
|
|
|
# Save the title on stack
|
|
|
|
self._write_string('\033[22;0t', self._screen_file)
|
|
|
|
self._write_string('\033[22;0t', self._screen_file)
|
|
|
|
|
|
|
|
|
|
|
|
def restore_console_title(self):
|
|
|
|
def restore_console_title(self):
|
|
|
|
if not self.params.get('consoletitle', False):
|
|
|
|
if not self.params.get('consoletitle', False) or self.params.get('simulate', False):
|
|
|
|
return
|
|
|
|
|
|
|
|
if self.params.get('simulate', False):
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
if compat_os_name != 'nt' and 'TERM' in os.environ:
|
|
|
|
if compat_os_name != 'nt' and 'TERM' in os.environ:
|
|
|
|
# Restore the title from stack
|
|
|
|
# Restore the title from stack
|
|
|
@ -771,7 +763,7 @@ class YoutubeDL(object):
|
|
|
|
# correspondingly that is not what we want since we need to keep
|
|
|
|
# correspondingly that is not what we want since we need to keep
|
|
|
|
# '%%' intact for template dict substitution step. Working around
|
|
|
|
# '%%' intact for template dict substitution step. Working around
|
|
|
|
# with boundary-alike separator hack.
|
|
|
|
# with boundary-alike separator hack.
|
|
|
|
sep = ''.join([random.choice(ascii_letters) for _ in range(32)])
|
|
|
|
sep = ''.join(random.choice(ascii_letters) for _ in range(32))
|
|
|
|
outtmpl = outtmpl.replace('%%', '%{0}%'.format(sep)).replace('$$', '${0}$'.format(sep))
|
|
|
|
outtmpl = outtmpl.replace('%%', '%{0}%'.format(sep)).replace('$$', '${0}$'.format(sep))
|
|
|
|
|
|
|
|
|
|
|
|
# outtmpl should be expand_path'ed before template dict substitution
|
|
|
|
# outtmpl should be expand_path'ed before template dict substitution
|
|
|
@ -787,8 +779,7 @@ class YoutubeDL(object):
|
|
|
|
filename = encodeFilename(filename, True).decode(preferredencoding())
|
|
|
|
filename = encodeFilename(filename, True).decode(preferredencoding())
|
|
|
|
return sanitize_path(filename)
|
|
|
|
return sanitize_path(filename)
|
|
|
|
except ValueError as err:
|
|
|
|
except ValueError as err:
|
|
|
|
self.report_error('Error in output template: ' + error_to_compat_str(err) + ' (encoding: ' + repr(preferredencoding()) + ')')
|
|
|
|
self.report_error('Error in output template: {0}{1})'.format(error_to_compat_str(err), ' (encoding: ' + repr(preferredencoding())))
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _match_entry(self, info_dict, incomplete):
|
|
|
|
def _match_entry(self, info_dict, incomplete):
|
|
|
|
""" Returns None iff the file should be downloaded """
|
|
|
|
""" Returns None iff the file should be downloaded """
|
|
|
@ -830,15 +821,13 @@ class YoutubeDL(object):
|
|
|
|
if ret is not None:
|
|
|
|
if ret is not None:
|
|
|
|
return ret
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
@staticmethod
|
|
|
|
def add_extra_info(info_dict, extra_info):
|
|
|
|
def add_extra_info(info_dict, extra_info):
|
|
|
|
'''Set the keys from extra_info in info dict if they are missing'''
|
|
|
|
'''Set the keys from extra_info in info dict if they are missing'''
|
|
|
|
for key, value in extra_info.items():
|
|
|
|
for key, value in extra_info.items():
|
|
|
|
info_dict.setdefault(key, value)
|
|
|
|
info_dict.setdefault(key, value)
|
|
|
|
|
|
|
|
|
|
|
|
def extract_info(self, url, download=True, ie_key=None, extra_info={},
|
|
|
|
def extract_info(self, url, download=True, ie_key=None, extra_info: dict = None,
|
|
|
|
process=True, force_generic_extractor=False):
|
|
|
|
process=True, force_generic_extractor=False):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Return a list with a dictionary for each video extracted.
|
|
|
|
Return a list with a dictionary for each video extracted.
|
|
|
@ -855,6 +844,9 @@ class YoutubeDL(object):
|
|
|
|
force_generic_extractor -- force using the generic extractor
|
|
|
|
force_generic_extractor -- force using the generic extractor
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if extra_info is None:
|
|
|
|
|
|
|
|
extra_info = {}
|
|
|
|
|
|
|
|
|
|
|
|
if not ie_key and force_generic_extractor:
|
|
|
|
if not ie_key and force_generic_extractor:
|
|
|
|
ie_key = 'Generic'
|
|
|
|
ie_key = 'Generic'
|
|
|
|
|
|
|
|
|
|
|
|