'Downloads a given url in chunks and writes to the provided stream (can be any io stream).
Displays the progress bar for the download.'

@staticmethod
def download_url_with_progress(url, stream, disable_progress):

    resp = requests.get(url, timeout=2, stream=True)
    resp.raw.decode_content = True
    progress = tqdm(unit='B', unit_scale=True, total=int(resp.headers.get('Content-Length', 0)), disable=disable_progress)
    for chunk in resp.iter_content(chunk_size=1024):
        if chunk:
            progress.update(len(chunk))
            stream.write(chunk)
    progress.close()
