From f08402d795819ccdb25560ac571f2cc72ff07b61 Mon Sep 17 00:00:00 2001 From: rlaphoenix <17136956+rlaphoenix@users.noreply.github.com> Date: Sat, 11 May 2024 22:59:19 +0100 Subject: [PATCH] refactor: Warn falling back to requests as aria2c doesn't support Range --- devine/core/manifests/dash.py | 1 + devine/core/manifests/hls.py | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/devine/core/manifests/dash.py b/devine/core/manifests/dash.py index e37d00a..6111436 100644 --- a/devine/core/manifests/dash.py +++ b/devine/core/manifests/dash.py @@ -472,6 +472,7 @@ class DASH: 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 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( urls=[ diff --git a/devine/core/manifests/hls.py b/devine/core/manifests/hls.py index de006e9..4af583d 100644 --- a/devine/core/manifests/hls.py +++ b/devine/core/manifests/hls.py @@ -254,6 +254,12 @@ class HLS: progress(total=total_segments) 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]] = [] segment_durations: list[int] = [] @@ -266,9 +272,6 @@ class HLS: segment_durations.append(int(segment.duration)) 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) range_offset = byte_range.split("-")[0] else: