Fixed minor bugs
This commit is contained in:
parent
1b956f4d84
commit
fdbd3cd86a
@ -1,6 +1,8 @@
|
|||||||
import requests
|
import requests
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
from colorama import Fore
|
from colorama import Fore
|
||||||
|
from time import sleep
|
||||||
|
from os import remove
|
||||||
|
|
||||||
def tqdm_request(url,dir_to,file,desc):
|
def tqdm_request(url,dir_to,file,desc):
|
||||||
'''
|
'''
|
||||||
@ -12,9 +14,8 @@ def tqdm_request(url,dir_to,file,desc):
|
|||||||
try:
|
try:
|
||||||
local_file = open(dir_to + file, 'ab')
|
local_file = open(dir_to + file, 'ab')
|
||||||
pos = local_file.tell()
|
pos = local_file.tell()
|
||||||
resume_header = {'Range': f'bytes={pos}-'}
|
res = requests.get(url,stream=True,timeout=100,headers={'Accept-Encoding': None,'Range': f'bytes={pos}-'})
|
||||||
res = requests.get(url,stream=True,timeout=100,headers=resume_header)
|
total_size = int(res.headers.get('content-length'))
|
||||||
total_size = int(res.headers.get('content-length', 0))
|
|
||||||
pbar = tqdm(desc = desc,total=total_size,unit='B',unit_scale=True,bar_format = bar_format,position=0,initial=pos)
|
pbar = tqdm(desc = desc,total=total_size,unit='B',unit_scale=True,bar_format = bar_format,position=0,initial=pos)
|
||||||
for chunk in res.iter_content(block_size):
|
for chunk in res.iter_content(block_size):
|
||||||
pbar.update(len(chunk))
|
pbar.update(len(chunk))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user