From e61c72b597e3005782573efeae6bfcd34812dcf9 Mon Sep 17 00:00:00 2001 From: yoshiko2 Date: Sat, 28 May 2022 16:10:22 +0800 Subject: [PATCH 1/2] Remove shit code --- ADC_function.py | 13 ++++--------- core.py | 14 +++----------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/ADC_function.py b/ADC_function.py index 25c7fd2..2219219 100644 --- a/ADC_function.py +++ b/ADC_function.py @@ -470,15 +470,12 @@ def download_file_with_filename(url: str, filename: str, path: str) -> None: except: print(f"[-]Fatal error! Can not make folder '{path}'") os._exit(0) - proxies = configProxy.proxies() - headers = { - 'User-Agent': G_USER_AGENT} - r = requests.get(url, headers=headers, timeout=configProxy.timeout, proxies=proxies) + r = get_html(url=url, return_type='content') if r == '': print('[-]Movie Download Data not found!') return with open(os.path.join(path, filename), "wb") as code: - code.write(r.content) + code.write(r) return else: if not os.path.exists(path): @@ -487,14 +484,12 @@ def download_file_with_filename(url: str, filename: str, path: str) -> None: except: print(f"[-]Fatal error! Can not make folder '{path}'") os._exit(0) - headers = { - 'User-Agent': G_USER_AGENT} - r = requests.get(url, timeout=configProxy.timeout, headers=headers) + r = get_html(url=url, return_type='content') if r == '': print('[-]Movie Download Data not found!') return with open(os.path.join(path, filename), "wb") as code: - code.write(r.content) + code.write(r) return except requests.exceptions.RequestException: i += 1 diff --git a/core.py b/core.py index d50e495..3b71b63 100644 --- a/core.py +++ b/core.py @@ -118,7 +118,7 @@ def create_folder(json_data): # 创建文件夹 # path = examle:photo , video.in the Project Folder! def download_file_with_filename(url, filename, path, filepath, json_headers=None): conf = config.getInstance() - configProxy = conf.proxy() + configProxy = conf.proxy('switch') for i in range(configProxy.retry): try: @@ -128,20 +128,12 @@ def download_file_with_filename(url, filename, path, filepath, json_headers=None except: print(f"[-]Fatal error! Can not make folder '{path}'") os._exit(0) - headers = {'User-Agent': G_USER_AGENT} - if not json_headers == None: - if 'headers' in json_headers: - headers.update(json_headers) - if configProxy: - proxies = configProxy.proxies() - r = requests.get(url, headers=headers, timeout=configProxy.timeout, proxies=proxies) - else: - r = requests.get(url, headers=headers, timeout=configProxy.timeout) + r = get_html(url=url,return_type='content',json_headers=json_headers) if r == '': print('[-]Movie Download Data not found!') return with open(os.path.join(path, filename), "wb") as code: - code.write(r.content) + code.write(r) return except requests.exceptions.ProxyError: i += 1 From 99cc99bb513790342d426d6ca432c41bddf38947 Mon Sep 17 00:00:00 2001 From: yoshiko2 Date: Sat, 28 May 2022 16:12:09 +0800 Subject: [PATCH 2/2] Remove shit code #2 --- core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core.py b/core.py index 3b71b63..18b59e2 100644 --- a/core.py +++ b/core.py @@ -118,7 +118,7 @@ def create_folder(json_data): # 创建文件夹 # path = examle:photo , video.in the Project Folder! def download_file_with_filename(url, filename, path, filepath, json_headers=None): conf = config.getInstance() - configProxy = conf.proxy('switch') + configProxy = conf.proxy() for i in range(configProxy.retry): try: