mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-01 02:37:29 +01:00
Avoid recursion error when re-extracting info
This commit is contained in:
parent
c62ecf0d90
commit
6da22e7d4f
@ -1348,8 +1348,18 @@ def extract_info(self, url, download=True, ie_key=None, extra_info=None,
|
|||||||
def __handle_extraction_exceptions(func):
|
def __handle_extraction_exceptions(func):
|
||||||
@functools.wraps(func)
|
@functools.wraps(func)
|
||||||
def wrapper(self, *args, **kwargs):
|
def wrapper(self, *args, **kwargs):
|
||||||
|
while True:
|
||||||
try:
|
try:
|
||||||
return func(self, *args, **kwargs)
|
return func(self, *args, **kwargs)
|
||||||
|
except (DownloadCancelled, LazyList.IndexError, PagedList.IndexError):
|
||||||
|
raise
|
||||||
|
except ReExtractInfo as e:
|
||||||
|
if e.expected:
|
||||||
|
self.to_screen(f'{e}; Re-extracting data')
|
||||||
|
else:
|
||||||
|
self.to_stderr('\r')
|
||||||
|
self.report_warning(f'{e}; Re-extracting data')
|
||||||
|
continue
|
||||||
except GeoRestrictedError as e:
|
except GeoRestrictedError as e:
|
||||||
msg = e.msg
|
msg = e.msg
|
||||||
if e.countries:
|
if e.countries:
|
||||||
@ -1358,21 +1368,13 @@ def wrapper(self, *args, **kwargs):
|
|||||||
msg += '\nYou might want to use a VPN or a proxy server (with --proxy) to workaround.'
|
msg += '\nYou might want to use a VPN or a proxy server (with --proxy) to workaround.'
|
||||||
self.report_error(msg)
|
self.report_error(msg)
|
||||||
except ExtractorError as e: # An error we somewhat expected
|
except ExtractorError as e: # An error we somewhat expected
|
||||||
self.report_error(compat_str(e), e.format_traceback())
|
self.report_error(str(e), e.format_traceback())
|
||||||
except ReExtractInfo as e:
|
|
||||||
if e.expected:
|
|
||||||
self.to_screen(f'{e}; Re-extracting data')
|
|
||||||
else:
|
|
||||||
self.to_stderr('\r')
|
|
||||||
self.report_warning(f'{e}; Re-extracting data')
|
|
||||||
return wrapper(self, *args, **kwargs)
|
|
||||||
except (DownloadCancelled, LazyList.IndexError, PagedList.IndexError):
|
|
||||||
raise
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if self.params.get('ignoreerrors'):
|
if self.params.get('ignoreerrors'):
|
||||||
self.report_error(error_to_compat_str(e), tb=encode_compat_str(traceback.format_exc()))
|
self.report_error(str(e), tb=encode_compat_str(traceback.format_exc()))
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
break
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
def _wait_for_video(self, ie_result):
|
def _wait_for_video(self, ie_result):
|
||||||
|
Loading…
Reference in New Issue
Block a user