|
|
|
@ -793,21 +793,14 @@ class YoutubeDL(object):
|
|
|
|
|
self.report_warning('The program functionality for this site has been marked as broken, '
|
|
|
|
|
'and will probably not work.')
|
|
|
|
|
|
|
|
|
|
return self.__extract_info(url, ie, download, extra_info, process)
|
|
|
|
|
else:
|
|
|
|
|
self.report_error('no suitable InfoExtractor for URL %s' % url)
|
|
|
|
|
|
|
|
|
|
def __handle_extraction_exceptions(func):
|
|
|
|
|
def wrapper(self, *args, **kwargs):
|
|
|
|
|
try:
|
|
|
|
|
ie_result = ie.extract(url)
|
|
|
|
|
if ie_result is None: # Finished already (backwards compatibility; listformats and friends should be moved here)
|
|
|
|
|
break
|
|
|
|
|
if isinstance(ie_result, list):
|
|
|
|
|
# Backwards compatibility: old IE result format
|
|
|
|
|
ie_result = {
|
|
|
|
|
'_type': 'compat_list',
|
|
|
|
|
'entries': ie_result,
|
|
|
|
|
}
|
|
|
|
|
self.add_default_extra_info(ie_result, ie, url)
|
|
|
|
|
if process:
|
|
|
|
|
return self.process_ie_result(ie_result, download, extra_info)
|
|
|
|
|
else:
|
|
|
|
|
return ie_result
|
|
|
|
|
return func(self, *args, **kwargs)
|
|
|
|
|
except GeoRestrictedError as e:
|
|
|
|
|
msg = e.msg
|
|
|
|
|
if e.countries:
|
|
|
|
@ -815,20 +808,33 @@ class YoutubeDL(object):
|
|
|
|
|
map(ISO3166Utils.short2full, e.countries))
|
|
|
|
|
msg += '\nYou might want to use a VPN or a proxy server (with --proxy) to workaround.'
|
|
|
|
|
self.report_error(msg)
|
|
|
|
|
break
|
|
|
|
|
except ExtractorError as e: # An error we somewhat expected
|
|
|
|
|
self.report_error(compat_str(e), e.format_traceback())
|
|
|
|
|
break
|
|
|
|
|
except MaxDownloadsReached:
|
|
|
|
|
raise
|
|
|
|
|
except Exception as e:
|
|
|
|
|
if self.params.get('ignoreerrors', False):
|
|
|
|
|
self.report_error(error_to_compat_str(e), tb=encode_compat_str(traceback.format_exc()))
|
|
|
|
|
break
|
|
|
|
|
else:
|
|
|
|
|
raise
|
|
|
|
|
return wrapper
|
|
|
|
|
|
|
|
|
|
@__handle_extraction_exceptions
|
|
|
|
|
def __extract_info(self, url, ie, download, extra_info, process):
|
|
|
|
|
ie_result = ie.extract(url)
|
|
|
|
|
if ie_result is None: # Finished already (backwards compatibility; listformats and friends should be moved here)
|
|
|
|
|
return
|
|
|
|
|
if isinstance(ie_result, list):
|
|
|
|
|
# Backwards compatibility: old IE result format
|
|
|
|
|
ie_result = {
|
|
|
|
|
'_type': 'compat_list',
|
|
|
|
|
'entries': ie_result,
|
|
|
|
|
}
|
|
|
|
|
self.add_default_extra_info(ie_result, ie, url)
|
|
|
|
|
if process:
|
|
|
|
|
return self.process_ie_result(ie_result, download, extra_info)
|
|
|
|
|
else:
|
|
|
|
|
self.report_error('no suitable InfoExtractor for URL %s' % url)
|
|
|
|
|
return ie_result
|
|
|
|
|
|
|
|
|
|
def add_default_extra_info(self, ie_result, ie, url):
|
|
|
|
|
self.add_extra_info(ie_result, {
|
|
|
|
@ -1003,9 +1009,8 @@ class YoutubeDL(object):
|
|
|
|
|
self.to_screen('[download] ' + reason)
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
entry_result = self.process_ie_result(entry,
|
|
|
|
|
download=download,
|
|
|
|
|
extra_info=extra)
|
|
|
|
|
entry_result = self.__process_iterable_entry(entry, download, extra)
|
|
|
|
|
# TODO: skip failed (empty) entries?
|
|
|
|
|
playlist_results.append(entry_result)
|
|
|
|
|
ie_result['entries'] = playlist_results
|
|
|
|
|
self.to_screen('[download] Finished downloading playlist: %s' % playlist)
|
|
|
|
@ -1034,6 +1039,11 @@ class YoutubeDL(object):
|
|
|
|
|
else:
|
|
|
|
|
raise Exception('Invalid result type: %s' % result_type)
|
|
|
|
|
|
|
|
|
|
@__handle_extraction_exceptions
|
|
|
|
|
def __process_iterable_entry(self, entry, download, extra_info):
|
|
|
|
|
return self.process_ie_result(
|
|
|
|
|
entry, download=download, extra_info=extra_info)
|
|
|
|
|
|
|
|
|
|
def _build_format_filter(self, filter_spec):
|
|
|
|
|
" Returns a function to filter the formats according to the filter_spec "
|
|
|
|
|
|
|
|
|
|