mirror of https://github.com/devine-dl/devine.git
Add a 5-attempt retry system to DASH & HLS downloads
This commit is contained in:
parent
111dac9264
commit
055bc927f5
|
@ -455,6 +455,9 @@ class DASH:
|
||||||
|
|
||||||
segment_uri, segment_range = segment
|
segment_uri, segment_range = segment
|
||||||
|
|
||||||
|
attempts = 1
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
if segment_range:
|
if segment_range:
|
||||||
# aria2(c) doesn't support byte ranges, let's use python-requests (likely slower)
|
# aria2(c) doesn't support byte ranges, let's use python-requests (likely slower)
|
||||||
r = session.get(
|
r = session.get(
|
||||||
|
@ -474,6 +477,12 @@ class DASH:
|
||||||
proxy=proxy,
|
proxy=proxy,
|
||||||
segmented=True
|
segmented=True
|
||||||
))
|
))
|
||||||
|
break
|
||||||
|
except Exception as ee:
|
||||||
|
if stop_event.is_set() or attempts == 5:
|
||||||
|
raise ee
|
||||||
|
time.sleep(2)
|
||||||
|
attempts += 1
|
||||||
|
|
||||||
data_size = segment_save_path.stat().st_size
|
data_size = segment_save_path.stat().st_size
|
||||||
|
|
||||||
|
|
|
@ -283,6 +283,9 @@ class HLS:
|
||||||
if not segment.uri.startswith(segment.base_uri):
|
if not segment.uri.startswith(segment.base_uri):
|
||||||
segment.uri = segment.base_uri + segment.uri
|
segment.uri = segment.base_uri + segment.uri
|
||||||
|
|
||||||
|
attempts = 1
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
if segment.byterange:
|
if segment.byterange:
|
||||||
# aria2(c) doesn't support byte ranges, let's use python-requests (likely slower)
|
# aria2(c) doesn't support byte ranges, let's use python-requests (likely slower)
|
||||||
previous_range_offset = range_offset.get()
|
previous_range_offset = range_offset.get()
|
||||||
|
@ -307,6 +310,12 @@ class HLS:
|
||||||
proxy=proxy,
|
proxy=proxy,
|
||||||
segmented=True
|
segmented=True
|
||||||
))
|
))
|
||||||
|
break
|
||||||
|
except Exception as ee:
|
||||||
|
if stop_event.is_set() or attempts == 5:
|
||||||
|
raise ee
|
||||||
|
time.sleep(2)
|
||||||
|
attempts += 1
|
||||||
|
|
||||||
data_size = segment_save_path.stat().st_size
|
data_size = segment_save_path.stat().st_size
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue