added a test mode to FileDownloader that fetches only first 10K
authorFilippo Valsorda <filippo.valsorda@gmail.com>
Tue, 11 Dec 2012 08:49:27 +0000 (09:49 +0100)
committerFilippo Valsorda <filippo.valsorda@gmail.com>
Tue, 11 Dec 2012 08:49:27 +0000 (09:49 +0100)
youtube_dl/FileDownloader.py

index c471cc16081d5ff40cd0898ba0149f346d6c574e..aad12fc1ff7737870335210051a09e15c2af082b 100644 (file)
@@ -78,6 +78,7 @@ class FileDownloader(object):
     writeinfojson:     Write the video description to a .info.json file
     writesubtitles:    Write the video subtitles to a .srt file
     subtitleslang:     Language of the subtitles to download
+    test:              Download only first bytes to test the downloader.
     """
 
     params = None
@@ -594,6 +595,9 @@ class FileDownloader(object):
         basic_request = compat_urllib_request.Request(url, None, headers)
         request = compat_urllib_request.Request(url, None, headers)
 
+        if self.params.get('test', False):
+            request.add_header('Range','bytes=0-10240')
+
         # Establish possible resume length
         if os.path.isfile(encodeFilename(tmpfilename)):
             resume_len = os.path.getsize(encodeFilename(tmpfilename))