mirror of
https://github.com/ihabunek/twitch-dl
synced 2024-08-30 18:32:25 +00:00
Improve downloading logic
Follow redirects to avoid saving an intermediate response, and raise an error on invalid status to avoid saving an error response.
This commit is contained in:
parent
141ecb7f29
commit
f9e60082ba
@ -12,7 +12,8 @@ RETRY_COUNT = 5
|
||||
def _download(url: str, path: str):
|
||||
tmp_path = path + ".tmp"
|
||||
size = 0
|
||||
with httpx.stream("GET", url, timeout=CONNECT_TIMEOUT) as response:
|
||||
with httpx.stream("GET", url, timeout=CONNECT_TIMEOUT, follow_redirects=True) as response:
|
||||
response.raise_for_status()
|
||||
with open(tmp_path, "wb") as target:
|
||||
for chunk in response.iter_bytes(chunk_size=CHUNK_SIZE):
|
||||
target.write(chunk)
|
||||
|
Loading…
Reference in New Issue
Block a user