瀏覽代碼

added a test mode to FileDownloader that fetches only first 10K

Filippo Valsorda 12 年之前
父節點
當前提交
37c8fd4842
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      youtube_dl/FileDownloader.py

+ 4 - 0
youtube_dl/FileDownloader.py

@@ -78,6 +78,7 @@ class FileDownloader(object):
     writeinfojson:     Write the video description to a .info.json file
     writeinfojson:     Write the video description to a .info.json file
     writesubtitles:    Write the video subtitles to a .srt file
     writesubtitles:    Write the video subtitles to a .srt file
     subtitleslang:     Language of the subtitles to download
     subtitleslang:     Language of the subtitles to download
+    test:              Download only first bytes to test the downloader.
     """
     """
 
 
     params = None
     params = None
@@ -594,6 +595,9 @@ class FileDownloader(object):
         basic_request = compat_urllib_request.Request(url, None, headers)
         basic_request = compat_urllib_request.Request(url, None, headers)
         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
         # Establish possible resume length
         if os.path.isfile(encodeFilename(tmpfilename)):
         if os.path.isfile(encodeFilename(tmpfilename)):
             resume_len = os.path.getsize(encodeFilename(tmpfilename))
             resume_len = os.path.getsize(encodeFilename(tmpfilename))