Skip to content

Commit

Permalink
[downloader/http] Retry download when urlopen times out (ytdl-org#26603
Browse files Browse the repository at this point in the history
…) (refs ytdl-org#10935)
  • Loading branch information
salty-horse authored Sep 17, 2020
1 parent e8c5d40 commit 86b7c00
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion youtube_dl/downloader/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ def establish_connection():
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
Expand Down

0 comments on commit 86b7c00

Please sign in to comment.