diff options
Diffstat (limited to 'yt_dlp/YoutubeDL.py')
-rw-r--r-- | yt_dlp/YoutubeDL.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 85219ac95..7e9c0949b 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -319,9 +319,14 @@ class YoutubeDL: default_search: Prepend this string if an input url is not valid. 'auto' for elaborate guessing encoding: Use this encoding instead of the system-specified. - extract_flat: Do not resolve URLs, return the immediate result. - Pass in 'in_playlist' to only show this behavior for - playlist items. + extract_flat: Whether to resolve and process url_results further + * False: Always process (default) + * True: Never process + * 'in_playlist': Do not process inside playlist/multi_video + * 'discard': Always process, but don't return the result + from inside playlist/multi_video + * 'discard_in_playlist': Same as "discard", but only for + playlists (not multi_video) wait_for_video: If given, wait for scheduled streams to become available. The value should be a tuple containing the range (min_secs, max_secs) to wait between retries @@ -1725,6 +1730,12 @@ class YoutubeDL: self.to_screen(f'[{ie_result["extractor"]}] Playlist {title}: Downloading {n_entries} videos' f'{format_field(ie_result, "playlist_count", " of %s")}') + keep_resolved_entries = self.params.get('extract_flat') != 'discard' + if self.params.get('extract_flat') == 'discard_in_playlist': + keep_resolved_entries = ie_result['_type'] != 'playlist' + if keep_resolved_entries: + self.write_debug('The information of all playlist entries will be held in memory') + failures = 0 max_failures = self.params.get('skip_playlist_after_errors') or float('inf') for i, (playlist_index, entry) in enumerate(entries): @@ -1765,7 +1776,8 @@ class YoutubeDL: self.report_error( f'Skipping the remaining entries in playlist "{title}" since {failures} items failed extraction') break - resolved_entries[i] = (playlist_index, entry_result) + if keep_resolved_entries: + resolved_entries[i] = (playlist_index, entry_result) # Update with processed data ie_result['requested_entries'], ie_result['entries'] = tuple(zip(*resolved_entries)) or ([], []) |