aboutsummaryrefslogtreecommitdiffhomepage
path: root/youtube_dl/downloader
diff options
context:
space:
mode:
authorOri Avtalion <[email protected]>2020-09-17 23:15:44 +0300
committerGitHub <[email protected]>2020-09-18 03:15:44 +0700
commit86b7c00adca578b36138b165b0add5978972917e (patch)
tree8b7e46094beb515c0090910ad5e135a311007de5 /youtube_dl/downloader
parente8c5d40bc840b9e3ec8b4e8070291a64a4fa75b2 (diff)
downloadyoutube-dl-86b7c00adca578b36138b165b0add5978972917e.tar.gz
youtube-dl-86b7c00adca578b36138b165b0add5978972917e.zip
[downloader/http] Retry download when urlopen times out (#26603) (refs #10935)
Diffstat (limited to 'youtube_dl/downloader')
-rw-r--r--youtube_dl/downloader/http.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/youtube_dl/downloader/http.py b/youtube_dl/downloader/http.py
index 5046878df..e14ddce58 100644
--- a/youtube_dl/downloader/http.py
+++ b/youtube_dl/downloader/http.py
@@ -106,7 +106,12 @@ class HttpFD(FileDownloader):
set_range(request, range_start, range_end)
# Establish connection
try:
- ctx.data = self.ydl.urlopen(request)
+ try:
+ ctx.data = self.ydl.urlopen(request)
+ except (compat_urllib_error.URLError, ) as err:
+ if isinstance(err.reason, socket.timeout):
+ raise RetryDownload(err)
+ raise err
# When trying to resume, Content-Range HTTP header of response has to be checked
# to match the value of requested Range HTTP header. This is due to a webservers
# that don't support resuming and serve a whole file with no Content-Range