]> jfr.im git - yt-dlp.git/commitdiff
Pre-check archive and filters during playlist extraction
authorpukkandan <redacted>
Fri, 28 May 2021 16:38:01 +0000 (22:08 +0530)
committerpukkandan <redacted>
Fri, 28 May 2021 20:42:09 +0000 (02:12 +0530)
This makes `--break-on-existing` much faster.
It also helps `--break-on-reject` if the playlist extractor can extract the relevant fields

yt_dlp/YoutubeDL.py

index a5892a5a731a23a996432d702046d66c6af7526a..80f54fd3e31dc3347189b1d9a866ff671dbabc43 100644 (file)
@@ -1017,7 +1017,7 @@ def prepare_filename(self, info_dict, dir_type='', warn=False):
             path = encodeFilename(path, True).decode(preferredencoding())
         return sanitize_path(path, force=self.params.get('windowsfilenames'))
 
-    def _match_entry(self, info_dict, incomplete=False):
+    def _match_entry(self, info_dict, incomplete=False, silent=False):
         """ Returns None if the file should be downloaded """
 
         video_title = info_dict.get('title', info_dict.get('id', 'video'))
@@ -1065,7 +1065,8 @@ def check_filter():
             reason = check_filter()
             break_opt, break_err = 'break_on_reject', RejectedVideoReached
         if reason is not None:
-            self.to_screen('[download] ' + reason)
+            if not silent:
+                self.to_screen('[download] ' + reason)
             if self.params.get(break_opt, False):
                 raise break_err()
         return reason
@@ -1351,6 +1352,11 @@ def iter_playlistitems(format):
                 elif not playlistitems:
                     break
             entries.append(entry)
+            try:
+                if entry is not None:
+                    self._match_entry(entry, incomplete=True, silent=True)
+            except (ExistingVideoReached, RejectedVideoReached):
+                break
         ie_result['entries'] = entries
 
         # Save playlist_index before re-ordering