projects
/
youtube-dl
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
25a4c5a
)
[utils] restart download if server does not support byte ranges
author
remitamine
<remitamine@gmail.com>
Sun, 2 Aug 2015 02:28:04 +0000
(
03:28
+0100)
committer
Sergey M․
<dstftw@gmail.com>
Sun, 2 Aug 2015 20:23:31 +0000
(
02:23
+0600)
youtube_dl/downloader/http.py
patch
|
blob
|
history
diff --git
a/youtube_dl/downloader/http.py
b/youtube_dl/downloader/http.py
index b7f144af9ea33a102246632e04e71707be3d98ad..b2e82cfde3ad1c659d7d71368f8285b6ca5788db 100644
(file)
--- a/
youtube_dl/downloader/http.py
+++ b/
youtube_dl/downloader/http.py
@@
-57,6
+57,20
@@
class HttpFD(FileDownloader):
# Establish connection
try:
data = self.ydl.urlopen(request)
# 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)
+ if content_range_m:
+ # Content-Range is correct - go on
+ if 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:
break
except (compat_urllib_error.HTTPError, ) as err:
if (err.code < 500 or err.code >= 600) and err.code != 416: