mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-12 14:26:49 +01:00
Handle more playlist errors with -i
This commit is contained in:
parent
165efb823b
commit
8e5fecc88c
@ -1211,7 +1211,8 @@ def extract_info(self, url, download=True, ie_key=None, extra_info=None,
|
|||||||
else:
|
else:
|
||||||
self.report_error('no suitable InfoExtractor for URL %s' % url)
|
self.report_error('no suitable InfoExtractor for URL %s' % url)
|
||||||
|
|
||||||
def __handle_extraction_exceptions(func, handle_all_errors=True):
|
def __handle_extraction_exceptions(func):
|
||||||
|
|
||||||
def wrapper(self, *args, **kwargs):
|
def wrapper(self, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
return func(self, *args, **kwargs)
|
return func(self, *args, **kwargs)
|
||||||
@ -1228,10 +1229,10 @@ def wrapper(self, *args, **kwargs):
|
|||||||
self.to_stderr('\r')
|
self.to_stderr('\r')
|
||||||
self.report_warning('The download speed is below throttle limit. Re-extracting data')
|
self.report_warning('The download speed is below throttle limit. Re-extracting data')
|
||||||
return wrapper(self, *args, **kwargs)
|
return wrapper(self, *args, **kwargs)
|
||||||
except (MaxDownloadsReached, ExistingVideoReached, RejectedVideoReached):
|
except (MaxDownloadsReached, ExistingVideoReached, RejectedVideoReached, LazyList.IndexError):
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if handle_all_errors and self.params.get('ignoreerrors', False):
|
if self.params.get('ignoreerrors', False):
|
||||||
self.report_error(error_to_compat_str(e), tb=encode_compat_str(traceback.format_exc()))
|
self.report_error(error_to_compat_str(e), tb=encode_compat_str(traceback.format_exc()))
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
@ -1436,13 +1437,17 @@ def iter_playlistitems(format):
|
|||||||
msg = (
|
msg = (
|
||||||
'Downloading %d videos' if not isinstance(ie_entries, list)
|
'Downloading %d videos' if not isinstance(ie_entries, list)
|
||||||
else 'Collected %d videos; downloading %%d of them' % len(ie_entries))
|
else 'Collected %d videos; downloading %%d of them' % len(ie_entries))
|
||||||
if not isinstance(ie_entries, (list, PagedList)):
|
|
||||||
|
if isinstance(ie_entries, list):
|
||||||
|
def get_entry(i):
|
||||||
|
return ie_entries[i - 1]
|
||||||
|
else:
|
||||||
|
if not isinstance(ie_entries, PagedList):
|
||||||
ie_entries = LazyList(ie_entries)
|
ie_entries = LazyList(ie_entries)
|
||||||
|
|
||||||
def get_entry(i):
|
def get_entry(i):
|
||||||
return YoutubeDL.__handle_extraction_exceptions(
|
return YoutubeDL.__handle_extraction_exceptions(
|
||||||
lambda self, i: ie_entries[i - 1],
|
lambda self, i: ie_entries[i - 1]
|
||||||
False
|
|
||||||
)(self, i)
|
)(self, i)
|
||||||
|
|
||||||
entries = []
|
entries = []
|
||||||
|
@ -3972,6 +3972,9 @@ class LazyList(collections.abc.Sequence):
|
|||||||
''' Lazy immutable list from an iterable
|
''' Lazy immutable list from an iterable
|
||||||
Note that slices of a LazyList are lists and not LazyList'''
|
Note that slices of a LazyList are lists and not LazyList'''
|
||||||
|
|
||||||
|
class IndexError(IndexError):
|
||||||
|
pass
|
||||||
|
|
||||||
def __init__(self, iterable):
|
def __init__(self, iterable):
|
||||||
self.__iterable = iter(iterable)
|
self.__iterable = iter(iterable)
|
||||||
self.__cache = []
|
self.__cache = []
|
||||||
@ -4015,22 +4018,28 @@ def __getitem__(self, idx):
|
|||||||
or (stop is None and step > 0)):
|
or (stop is None and step > 0)):
|
||||||
# We need to consume the entire iterable to be able to slice from the end
|
# We need to consume the entire iterable to be able to slice from the end
|
||||||
# Obviously, never use this with infinite iterables
|
# Obviously, never use this with infinite iterables
|
||||||
return self.__exhaust()[idx]
|
self.__exhaust()
|
||||||
|
try:
|
||||||
|
return self.__cache[idx]
|
||||||
|
except IndexError as e:
|
||||||
|
raise self.IndexError(e) from e
|
||||||
n = max(start or 0, stop or 0) - len(self.__cache) + 1
|
n = max(start or 0, stop or 0) - len(self.__cache) + 1
|
||||||
if n > 0:
|
if n > 0:
|
||||||
self.__cache.extend(itertools.islice(self.__iterable, n))
|
self.__cache.extend(itertools.islice(self.__iterable, n))
|
||||||
|
try:
|
||||||
return self.__cache[idx]
|
return self.__cache[idx]
|
||||||
|
except IndexError as e:
|
||||||
|
raise self.IndexError(e) from e
|
||||||
|
|
||||||
def __bool__(self):
|
def __bool__(self):
|
||||||
try:
|
try:
|
||||||
self[-1] if self.__reversed else self[0]
|
self[-1] if self.__reversed else self[0]
|
||||||
except IndexError:
|
except self.IndexError:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
self.exhaust()
|
self.__exhaust()
|
||||||
return len(self.__cache)
|
return len(self.__cache)
|
||||||
|
|
||||||
def reverse(self):
|
def reverse(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user