diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-06-07 01:43:50 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-06-07 02:41:55 +0530 |
commit | 5ec1b6b71689d2f0cbdcd2b6c4dd861fb2fcf911 (patch) | |
tree | 303e6842db27634aa217cf2c9490d1d22ead0003 /yt_dlp/utils.py | |
parent | e0ab98541cec9515d94ada8885a0bb999277f0c0 (diff) | |
download | hypervideo-pre-5ec1b6b71689d2f0cbdcd2b6c4dd861fb2fcf911.tar.lz hypervideo-pre-5ec1b6b71689d2f0cbdcd2b6c4dd861fb2fcf911.tar.xz hypervideo-pre-5ec1b6b71689d2f0cbdcd2b6c4dd861fb2fcf911.zip |
Add option `--download-sections` to download video partially
Closes #52, Closes #3932
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r-- | yt_dlp/utils.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index 777b8b3ea..45af4ec61 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -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 |