mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-22 18:17:17 -05:00
Don't download entire video when no matching --download-sections
This commit is contained in:
parent
46a5b335e7
commit
0500ee3d81
@ -2700,24 +2700,21 @@ class YoutubeDL:
|
|||||||
# Process what we can, even without any available formats.
|
# Process what we can, even without any available formats.
|
||||||
formats_to_download = [{}]
|
formats_to_download = [{}]
|
||||||
|
|
||||||
requested_ranges = self.params.get('download_ranges')
|
requested_ranges = tuple(self.params.get('download_ranges', lambda *_: [{}])(info_dict, self))
|
||||||
if requested_ranges:
|
|
||||||
requested_ranges = tuple(requested_ranges(info_dict, self))
|
|
||||||
|
|
||||||
best_format, downloaded_formats = formats_to_download[-1], []
|
best_format, downloaded_formats = formats_to_download[-1], []
|
||||||
if download:
|
if download:
|
||||||
if best_format:
|
if best_format and requested_ranges:
|
||||||
def to_screen(*msg):
|
def to_screen(*msg):
|
||||||
self.to_screen(f'[info] {info_dict["id"]}: {" ".join(", ".join(variadic(m)) for m in msg)}')
|
self.to_screen(f'[info] {info_dict["id"]}: {" ".join(", ".join(variadic(m)) for m in msg)}')
|
||||||
|
|
||||||
to_screen(f'Downloading {len(formats_to_download)} format(s):',
|
to_screen(f'Downloading {len(formats_to_download)} format(s):',
|
||||||
(f['format_id'] for f in formats_to_download))
|
(f['format_id'] for f in formats_to_download))
|
||||||
if requested_ranges:
|
if requested_ranges != ({}, ):
|
||||||
to_screen(f'Downloading {len(requested_ranges)} time ranges:',
|
to_screen(f'Downloading {len(requested_ranges)} time ranges:',
|
||||||
(f'{c["start_time"]:.1f}-{c["end_time"]:.1f}' for c in requested_ranges))
|
(f'{c["start_time"]:.1f}-{c["end_time"]:.1f}' for c in requested_ranges))
|
||||||
max_downloads_reached = False
|
max_downloads_reached = False
|
||||||
|
|
||||||
for fmt, chapter in itertools.product(formats_to_download, requested_ranges or [{}]):
|
for fmt, chapter in itertools.product(formats_to_download, requested_ranges):
|
||||||
new_info = self._copy_infodict(info_dict)
|
new_info = self._copy_infodict(info_dict)
|
||||||
new_info.update(fmt)
|
new_info.update(fmt)
|
||||||
offset, duration = info_dict.get('section_start') or 0, info_dict.get('duration') or float('inf')
|
offset, duration = info_dict.get('section_start') or 0, info_dict.get('duration') or float('inf')
|
||||||
|
@ -3793,6 +3793,9 @@ class download_range_func:
|
|||||||
self.chapters, self.ranges = chapters, ranges
|
self.chapters, self.ranges = chapters, ranges
|
||||||
|
|
||||||
def __call__(self, info_dict, ydl):
|
def __call__(self, info_dict, ydl):
|
||||||
|
if not self.ranges and not self.chapters:
|
||||||
|
yield {}
|
||||||
|
|
||||||
warning = ('There are no chapters matching the regex' if info_dict.get('chapters')
|
warning = ('There are no chapters matching the regex' if info_dict.get('chapters')
|
||||||
else 'Cannot match chapters since chapter information is unavailable')
|
else 'Cannot match chapters since chapter information is unavailable')
|
||||||
for regex in self.chapters or []:
|
for regex in self.chapters or []:
|
||||||
|
Loading…
Reference in New Issue
Block a user