mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-08-10 10:49:45 +00:00
Add option --break-match-filters
* Deprecates `--break-on-reject` Closes #5962
This commit is contained in:
@@ -1230,8 +1230,8 @@ class ExistingVideoReached(DownloadCancelled):
|
||||
|
||||
|
||||
class RejectedVideoReached(DownloadCancelled):
|
||||
""" --break-on-reject triggered """
|
||||
msg = 'Encountered a video that did not match filter, stopping due to --break-on-reject'
|
||||
""" --break-match-filter triggered """
|
||||
msg = 'Encountered a video that did not match filter, stopping due to --break-match-filter'
|
||||
|
||||
|
||||
class MaxDownloadsReached(DownloadCancelled):
|
||||
@@ -3911,16 +3911,21 @@ def match_str(filter_str, dct, incomplete=False):
|
||||
for filter_part in re.split(r'(?<!\\)&', filter_str))
|
||||
|
||||
|
||||
def match_filter_func(filters):
|
||||
if not filters:
|
||||
def match_filter_func(filters, breaking_filters=None):
|
||||
if not filters and not breaking_filters:
|
||||
return None
|
||||
filters = set(variadic(filters))
|
||||
breaking_filters = match_filter_func(breaking_filters) or (lambda _, __: None)
|
||||
filters = set(variadic(filters or []))
|
||||
|
||||
interactive = '-' in filters
|
||||
if interactive:
|
||||
filters.remove('-')
|
||||
|
||||
def _match_func(info_dict, incomplete=False):
|
||||
ret = breaking_filters(info_dict, incomplete)
|
||||
if ret is not None:
|
||||
raise RejectedVideoReached(ret)
|
||||
|
||||
if not filters or any(match_str(f, info_dict, incomplete) for f in filters):
|
||||
return NO_DEFAULT if interactive and not incomplete else None
|
||||
else:
|
||||
|
Reference in New Issue
Block a user