Archived
update: 添加了判断HTTP300
This commit is contained in:
1 file changed
+4
-1
@@ -40,7 +40,10 @@ class ThreadedDownload(threading.Thread):
|
|||||||
def download(url: str, threads: int = 4) -> None:
|
def download(url: str, threads: int = 4) -> None:
|
||||||
filename = url.split('/')[-1]
|
filename = url.split('/')[-1]
|
||||||
open('./src/db/data.sqlite', 'wb').close() # create an empty file
|
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
|
offset = filesize // threads
|
||||||
start = 0
|
start = 0
|
||||||
for i in range(threads):
|
for i in range(threads):
|
||||||
|
|||||||
Reference in New Issue
Block a user