aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/YoutubeDL.py
diff options
context:
space:
mode:
authorLesmiscore <nao20010128@gmail.com>2022-09-17 01:04:23 +0900
committerGitHub <noreply@github.com>2022-09-17 01:04:23 +0900
commitfc2ba496fd09ca68c7e6eeb2c11e7000d08ff099 (patch)
treead124486fdb10343ca0fa13499b900c747d5fa4e /yt_dlp/YoutubeDL.py
parent2b9d02167fdf2fbe5bd8306144ab45027da263c1 (diff)
downloadhypervideo-pre-fc2ba496fd09ca68c7e6eeb2c11e7000d08ff099.tar.lz
hypervideo-pre-fc2ba496fd09ca68c7e6eeb2c11e7000d08ff099.tar.xz
hypervideo-pre-fc2ba496fd09ca68c7e6eeb2c11e7000d08ff099.zip
Allow open ranges for time ranges (#4940)
Authored by: Lesmiscore
Diffstat (limited to 'yt_dlp/YoutubeDL.py')
-rw-r--r--yt_dlp/YoutubeDL.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index 3b6281066..0bfc47767 100644
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -2711,17 +2711,18 @@ class YoutubeDL:
(f['format_id'] for f in formats_to_download))
if requested_ranges:
to_screen(f'Downloading {len(requested_ranges)} time ranges:',
- (f'{int(c["start_time"])}-{int(c["end_time"])}' for c in requested_ranges))
+ (f'{c["start_time"]:.1f}-{c["end_time"]:.1f}' for c in requested_ranges))
max_downloads_reached = False
for fmt, chapter in itertools.product(formats_to_download, requested_ranges or [{}]):
new_info = self._copy_infodict(info_dict)
new_info.update(fmt)
offset, duration = info_dict.get('section_start') or 0, info_dict.get('duration') or float('inf')
+ end_time = offset + min(chapter.get('end_time', duration), duration)
if chapter or offset:
new_info.update({
'section_start': offset + chapter.get('start_time', 0),
- 'section_end': offset + min(chapter.get('end_time', duration), duration),
+ 'section_end': end_time if end_time < offset + duration else None,
'section_title': chapter.get('title'),
'section_number': chapter.get('index'),
})