mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-13 23:02:34 +00:00
[downloader/http] Simplify
This commit is contained in:
parent
8d5b8b477e
commit
c3124c3085
1 changed files with 3 additions and 7 deletions
|
@ -58,20 +58,16 @@ class HttpFD(FileDownloader):
|
||||||
# Establish connection
|
# Establish connection
|
||||||
try:
|
try:
|
||||||
data = self.ydl.urlopen(request)
|
data = self.ydl.urlopen(request)
|
||||||
|
|
||||||
if resume_len > 0:
|
if resume_len > 0:
|
||||||
content_range = data.headers.get('Content-Range')
|
content_range = data.headers.get('Content-Range')
|
||||||
if content_range:
|
if content_range:
|
||||||
content_range_m = re.search(r'bytes (\d+)-', content_range)
|
content_range_m = re.search(r'bytes (\d+)-', content_range)
|
||||||
if content_range_m:
|
# Content-Range is correct - go on
|
||||||
# Content-Range is correct - go on
|
if content_range_m and resume_len == int(content_range_m.group(1)):
|
||||||
if resume_len == int(content_range_m.group(1)):
|
break
|
||||||
break
|
|
||||||
|
|
||||||
# Content-Range is invalid - wipe the file and do entire redownload
|
# Content-Range is invalid - wipe the file and do entire redownload
|
||||||
resume_len = 0
|
resume_len = 0
|
||||||
open_mode = 'wb'
|
open_mode = 'wb'
|
||||||
|
|
||||||
break
|
break
|
||||||
except (compat_urllib_error.HTTPError, ) as err:
|
except (compat_urllib_error.HTTPError, ) as err:
|
||||||
if (err.code < 500 or err.code >= 600) and err.code != 416:
|
if (err.code < 500 or err.code >= 600) and err.code != 416:
|
||||||
|
|
Loading…
Reference in a new issue