1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-10-04 19:44:33 -04:00

[downloader/fragment] Fix bugs around resuming with Range (#2901)

Authored by: Lesmiscore
This commit is contained in:
Lesmiscore (Naoya Ozaki)
2022-02-28 13:10:54 +09:00
committed by GitHub
parent 195c22840c
commit 93c8410d33
3 changed files with 41 additions and 19 deletions

View File

@@ -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