diff options
author | Jeff Crouse <[email protected]> | 2013-01-22 00:50:42 -0500 |
---|---|---|
committer | Philipp Hagemeister <[email protected]> | 2013-02-01 18:09:34 +0100 |
commit | 9e982f9e4eff4219f8c10df7529280b7eab16236 (patch) | |
tree | 01a8740d961e31b7977c2e480c2a007789428e75 /youtube_dl/FileDownloader.py | |
parent | c7a725cfad52dd82ed4695eb526c053c7d48944d (diff) | |
download | youtube-dl-9e982f9e4eff4219f8c10df7529280b7eab16236.tar.gz youtube-dl-9e982f9e4eff4219f8c10df7529280b7eab16236.zip |
Added "min-filesize" and "max-filesize" options
Diffstat (limited to 'youtube_dl/FileDownloader.py')
-rw-r--r-- | youtube_dl/FileDownloader.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/youtube_dl/FileDownloader.py b/youtube_dl/FileDownloader.py index e3131bbe6..49b032a1b 100644 --- a/youtube_dl/FileDownloader.py +++ b/youtube_dl/FileDownloader.py @@ -82,6 +82,8 @@ class FileDownloader(object): subtitleslang: Language of the subtitles to download test: Download only first bytes to test the downloader. keepvideo: Keep the video file after post-processing + min_filesize: Skip files smaller than this size + max_filesize: Skip files larger than this size """ params = None @@ -712,6 +714,15 @@ class FileDownloader(object): data_len = data.info().get('Content-length', None) if data_len is not None: data_len = int(data_len) + resume_len + min_data_len = self.params.get("min_filesize", None) + max_data_len = self.params.get("max_filesize", None) + if min_data_len is not None and data_len < min_data_len: + self.to_screen(u'\r[download] File is smaller than min-filesize (%s bytes < %s bytes). Aborting.' % (data_len, min_data_len)) + return False + if max_data_len is not None and data_len > max_data_len: + self.to_screen(u'\r[download] File is larger than max-filesize (%s bytes > %s bytes). Aborting.' % (data_len, max_data_len)) + return False + data_len_str = self.format_bytes(data_len) byte_counter = 0 + resume_len block_size = self.params.get('buffersize', 1024) |