refactor: Warn falling back to requests as aria2c doesn't support Range

This commit is contained in:
rlaphoenix 2024-05-11 22:59:19 +01:00
parent 5ef95e942a
commit f08402d795
2 changed files with 7 additions and 3 deletions

View File

@ -472,6 +472,7 @@ class DASH:
if downloader.__name__ == "aria2c" and any(bytes_range is not None for url, bytes_range in segments): if downloader.__name__ == "aria2c" and any(bytes_range is not None for url, bytes_range in segments):
# aria2(c) is shit and doesn't support the Range header, fallback to the requests downloader # aria2(c) is shit and doesn't support the Range header, fallback to the requests downloader
downloader = requests_downloader downloader = requests_downloader
log.warning("Falling back to the requests downloader as aria2(c) doesn't support the Range header")
for status_update in downloader( for status_update in downloader(
urls=[ urls=[

View File

@ -254,6 +254,12 @@ class HLS:
progress(total=total_segments) progress(total=total_segments)
downloader = track.downloader downloader = track.downloader
if (
downloader.__name__ == "aria2c" and
any(x.byterange for x in master.segments if x not in unwanted_segments)
):
downloader = requests_downloader
log.warning("Falling back to the requests downloader as aria2(c) doesn't support the Range header")
urls: list[dict[str, Any]] = [] urls: list[dict[str, Any]] = []
segment_durations: list[int] = [] segment_durations: list[int] = []
@ -266,9 +272,6 @@ class HLS:
segment_durations.append(int(segment.duration)) segment_durations.append(int(segment.duration))
if segment.byterange: if segment.byterange:
if downloader.__name__ == "aria2c":
# aria2(c) is shit and doesn't support the Range header, fallback to the requests downloader
downloader = requests_downloader
byte_range = HLS.calculate_byte_range(segment.byterange, range_offset) byte_range = HLS.calculate_byte_range(segment.byterange, range_offset)
range_offset = byte_range.split("-")[0] range_offset = byte_range.split("-")[0]
else: else: