Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for u in uuids:
- url = "https://site.com/%s" % u
- r = requests.get(url, stream=True, verify=False, allow_redirects=True,auth=(user,password))
- d = r.headers['content-disposition']
- fname = re.findall("filename=\"(.+)\"", d)[0]
- if Path(fname).is_file():
- resume_byte_pos = Path(fname).stat().st_size
- resume_header = {'Range': 'bytes=%d-' % resume_byte_pos}
- r.headers.update(resume_header)
- total_size = int(r.headers.get('content-length', 0));
- wrote = 0
- with open(fname, 'ab') as f:
- for data in tqdm_notebook(r.iter_content(block_size), total=math.ceil(total_size//block_size) , unit='KB', unit_scale=True):
- wrote = wrote + len(data)
- f.write(data)
- if total_size != 0 and wrote != total_size:
- print("ERROR, something went wrong")
- else:
- resume_header = {'Range': 'bytes=0'}
- r.headers.update(resume_header)
- total_size = int(r.headers.get('content-length', 0));
- wrote = 0
- with open(fname, 'wb') as f:
- for data in tqdm_notebook(r.iter_content(block_size), total=math.ceil(total_size//block_size) , unit='KB', unit_scale=True):
- wrote = wrote + len(data)
- f.write(data)
- if total_size != 0 and wrote != total_size:
- print("ERROR, something went wrong")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement