From 666d072ba6825774404779eb57b631c59248ed3a Mon Sep 17 00:00:00 2001 From: MarkusJoe Date: Wed, 14 Sep 2022 12:44:31 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E6=B7=BB=E5=8A=A0=E4=BA=86=E5=88=A4?= =?UTF-8?q?=E6=96=ADHTTP300?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/t_download.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils/t_download.py b/src/utils/t_download.py index 361d34f..cf09716 100644 --- a/src/utils/t_download.py +++ b/src/utils/t_download.py @@ -40,7 +40,10 @@ class ThreadedDownload(threading.Thread): def download(url: str, threads: int = 4) -> None: filename = url.split('/')[-1] open('./src/db/data.sqlite', 'wb').close() # create an empty file - filesize = int(requests.head(url).headers['Content-Length']) + head = requests.head(url) + if head.status_code == 301: + head = requests.head(head.headers['Location']) + filesize = int(head.headers['Content-Length']) offset = filesize // threads start = 0 for i in range(threads):