aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/utils.py
diff options
context:
space:
mode:
authorLesmiscore (Naoya Ozaki) <nao20010128@gmail.com>2022-02-28 13:10:54 +0900
committerGitHub <noreply@github.com>2022-02-28 13:10:54 +0900
commit93c8410d333c9a61488448c29aabb6fa831e2991 (patch)
tree8a7c7481b0c49989d55b861c22894e759910128e /yt_dlp/utils.py
parent195c22840c594c8f9229cb47ffec2a8984c53a0c (diff)
downloadhypervideo-pre-93c8410d333c9a61488448c29aabb6fa831e2991.tar.lz
hypervideo-pre-93c8410d333c9a61488448c29aabb6fa831e2991.tar.xz
hypervideo-pre-93c8410d333c9a61488448c29aabb6fa831e2991.zip
[downloader/fragment] Fix bugs around resuming with Range (#2901)
Authored by: Lesmiscore
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r--yt_dlp/utils.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py
index 6ec8da11b..cc08bd130 100644
--- a/yt_dlp/utils.py
+++ b/yt_dlp/utils.py
@@ -5252,6 +5252,16 @@ def join_nonempty(*values, delim='-', from_dict=None):
return delim.join(map(str, filter(None, values)))
+def parse_http_range(range):
+ """ Parse value of "Range" or "Content-Range" HTTP header into tuple. """
+ if not range:
+ return None, None, None
+ crg = re.search(r'bytes[ =](\d+)-(\d+)?(?:/(\d+))?', range)
+ if not crg:
+ return None, None, None
+ return int(crg.group(1)), int_or_none(crg.group(2)), int_or_none(crg.group(3))
+
+
class Config:
own_args = None
filename = None