mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-10-02 02:24:52 +00:00
Add option --download-sections
to download video partially
Closes #52, Closes #3932
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user