Add option --download-sections to download video partially

Closes #52, Closes #3932
This commit is contained in:
pukkandan
2022-06-07 01:43:50 +05:30
parent e0ab98541c
commit 5ec1b6b716
7 changed files with 123 additions and 55 deletions

View File

@@ -3495,6 +3495,23 @@ def match_filter_func(filters):
return _match_func
def download_range_func(chapters, ranges):
def inner(info_dict, ydl):
warning = ('There are no chapters matching the regex' if info_dict.get('chapters')
else 'Chapter information is unavailable')
for regex in chapters or []:
for i, chapter in enumerate(info_dict.get('chapters') or []):
if re.search(regex, chapter['title']):
warning = None
yield {**chapter, 'index': i}
if warning:
ydl.to_screen(f'[info] {info_dict["id"]}: {warning}')
yield from ({'start_time': start, 'end_time': end} for start, end in ranges or [])
return inner
def parse_dfxp_time_expr(time_expr):
if not time_expr:
return