X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fdownloader%2Fhttp.py;h=0862e90bbb0a5bbc5f6414e6907cdc913d0944e6;hb=c3124c3085e6a9a83ee31ace3a7d528a324c42da;hp=ceacb8522b79ec4e4d3fbef83e242ed457be4a7c;hpb=6800d3372f35e08dcc4d34d06601815bf0cb0a3d;p=youtube-dl diff --git a/youtube_dl/downloader/http.py b/youtube_dl/downloader/http.py index ceacb8522..0862e90bb 100644 --- a/youtube_dl/downloader/http.py +++ b/youtube_dl/downloader/http.py @@ -4,9 +4,9 @@ import errno import os import socket import time +import re from .common import FileDownloader -from .dash import DashSegmentsFD from ..compat import ( compat_urllib_request, compat_urllib_error, @@ -20,9 +20,6 @@ from ..utils import ( class HttpFD(FileDownloader): def real_download(self, filename, info_dict): - if info_dict.get('initialization_url') and list(filter(None, info_dict.get('segment_urls', []))): - return DashSegmentsFD(self.ydl, self.params).real_download(filename, info_dict) - url = info_dict['url'] tmpfilename = self.temp_name(filename) stream = None @@ -61,6 +58,16 @@ class HttpFD(FileDownloader): # Establish connection try: data = self.ydl.urlopen(request) + if resume_len > 0: + content_range = data.headers.get('Content-Range') + if content_range: + content_range_m = re.search(r'bytes (\d+)-', content_range) + # Content-Range is correct - go on + if content_range_m and resume_len == int(content_range_m.group(1)): + break + # Content-Range is invalid - wipe the file and do entire redownload + resume_len = 0 + open_mode = 'wb' break except (compat_urllib_error.HTTPError, ) as err: if (err.code < 500 or err.code >= 600) and err.code != 416: