From fdbd3cd86a3d9f2dbe0a56167a7039461a1abcb4 Mon Sep 17 00:00:00 2001
From: Chunxiao Li <lcx366@126.com>
Date: Mon, 7 Jun 2021 12:56:13 +0800
Subject: [PATCH] Fixed minor bugs

---
 pyatmos/utils/try_download.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/pyatmos/utils/try_download.py b/pyatmos/utils/try_download.py
index e134d09..fd1bba1 100644
--- a/pyatmos/utils/try_download.py
+++ b/pyatmos/utils/try_download.py
@@ -1,6 +1,8 @@
 import requests
 from tqdm import tqdm
 from colorama import Fore
+from time import sleep
+from os import remove
 
 def tqdm_request(url,dir_to,file,desc):
     '''
@@ -12,10 +14,9 @@ def tqdm_request(url,dir_to,file,desc):
         try:
             local_file = open(dir_to + file, 'ab')
             pos = local_file.tell()
-            resume_header = {'Range': f'bytes={pos}-'}
-            res = requests.get(url,stream=True,timeout=100,headers=resume_header)
-            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)
+            res = requests.get(url,stream=True,timeout=100,headers={'Accept-Encoding': None,'Range': f'bytes={pos}-'})
+            total_size = int(res.headers.get('content-length'))
+            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):
                 pbar.update(len(chunk))
                 local_file.write(chunk)