diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2015-02-10 03:32:21 +0100 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2015-02-10 03:32:24 +0100 |
commit | 347de4931cb3e496fb7b1dfb0314c213f44cce6b (patch) | |
tree | 778a6d8a67b4ba6e1ecff2d68ee02d44cefb105a /youtube_dl/YoutubeDL.py | |
parent | 88296505131f4b91ff91eaa0af34318664d892c9 (diff) |
[YoutubeDL] Add generic video filtering (Fixes #4916)
This functionality is intended to eventually encompass the current format filtering.
Diffstat (limited to 'youtube_dl/YoutubeDL.py')
-rwxr-xr-x | youtube_dl/YoutubeDL.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 3975ae0bc..dda222fee 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -228,6 +228,11 @@ class YoutubeDL(object): external_downloader: Executable of the external downloader to call. listformats: Print an overview of available video formats and exit. list_thumbnails: Print a table of all thumbnails and exit. + match_filter: A function that gets called with the info_dict of + every video. + If it returns a message, the video is ignored. + If it returns None, the video is downloaded. + match_filter_func in utils.py is one example for this. The following parameters are not used by YoutubeDL itself, they are used by @@ -583,9 +588,16 @@ class YoutubeDL(object): if max_views is not None and view_count > max_views: return 'Skipping %s, because it has exceeded the maximum view count (%d/%d)' % (video_title, view_count, max_views) if age_restricted(info_dict.get('age_limit'), self.params.get('age_limit')): - return 'Skipping "%s" because it is age restricted' % title + return 'Skipping "%s" because it is age restricted' % video_title if self.in_download_archive(info_dict): return '%s has already been recorded in archive' % video_title + + match_filter = self.params.get('match_filter') + if match_filter is not None: + ret = match_filter(info_dict) + if ret is not None: + return ret + return None @staticmethod |