Remove shit code
This commit is contained in:
@@ -470,15 +470,12 @@ def download_file_with_filename(url: str, filename: str, path: str) -> None:
|
|||||||
except:
|
except:
|
||||||
print(f"[-]Fatal error! Can not make folder '{path}'")
|
print(f"[-]Fatal error! Can not make folder '{path}'")
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
proxies = configProxy.proxies()
|
r = get_html(url=url, return_type='content')
|
||||||
headers = {
|
|
||||||
'User-Agent': G_USER_AGENT}
|
|
||||||
r = requests.get(url, headers=headers, timeout=configProxy.timeout, proxies=proxies)
|
|
||||||
if r == '':
|
if r == '':
|
||||||
print('[-]Movie Download Data not found!')
|
print('[-]Movie Download Data not found!')
|
||||||
return
|
return
|
||||||
with open(os.path.join(path, filename), "wb") as code:
|
with open(os.path.join(path, filename), "wb") as code:
|
||||||
code.write(r.content)
|
code.write(r)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
@@ -487,14 +484,12 @@ def download_file_with_filename(url: str, filename: str, path: str) -> None:
|
|||||||
except:
|
except:
|
||||||
print(f"[-]Fatal error! Can not make folder '{path}'")
|
print(f"[-]Fatal error! Can not make folder '{path}'")
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
headers = {
|
r = get_html(url=url, return_type='content')
|
||||||
'User-Agent': G_USER_AGENT}
|
|
||||||
r = requests.get(url, timeout=configProxy.timeout, headers=headers)
|
|
||||||
if r == '':
|
if r == '':
|
||||||
print('[-]Movie Download Data not found!')
|
print('[-]Movie Download Data not found!')
|
||||||
return
|
return
|
||||||
with open(os.path.join(path, filename), "wb") as code:
|
with open(os.path.join(path, filename), "wb") as code:
|
||||||
code.write(r.content)
|
code.write(r)
|
||||||
return
|
return
|
||||||
except requests.exceptions.RequestException:
|
except requests.exceptions.RequestException:
|
||||||
i += 1
|
i += 1
|
||||||
|
|||||||
14
core.py
14
core.py
@@ -118,7 +118,7 @@ def create_folder(json_data): # 创建文件夹
|
|||||||
# path = examle:photo , video.in the Project Folder!
|
# path = examle:photo , video.in the Project Folder!
|
||||||
def download_file_with_filename(url, filename, path, filepath, json_headers=None):
|
def download_file_with_filename(url, filename, path, filepath, json_headers=None):
|
||||||
conf = config.getInstance()
|
conf = config.getInstance()
|
||||||
configProxy = conf.proxy()
|
configProxy = conf.proxy('switch')
|
||||||
|
|
||||||
for i in range(configProxy.retry):
|
for i in range(configProxy.retry):
|
||||||
try:
|
try:
|
||||||
@@ -128,20 +128,12 @@ def download_file_with_filename(url, filename, path, filepath, json_headers=None
|
|||||||
except:
|
except:
|
||||||
print(f"[-]Fatal error! Can not make folder '{path}'")
|
print(f"[-]Fatal error! Can not make folder '{path}'")
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
headers = {'User-Agent': G_USER_AGENT}
|
r = get_html(url=url,return_type='content',json_headers=json_headers)
|
||||||
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)
|
|
||||||
if r == '':
|
if r == '':
|
||||||
print('[-]Movie Download Data not found!')
|
print('[-]Movie Download Data not found!')
|
||||||
return
|
return
|
||||||
with open(os.path.join(path, filename), "wb") as code:
|
with open(os.path.join(path, filename), "wb") as code:
|
||||||
code.write(r.content)
|
code.write(r)
|
||||||
return
|
return
|
||||||
except requests.exceptions.ProxyError:
|
except requests.exceptions.ProxyError:
|
||||||
i += 1
|
i += 1
|
||||||
|
|||||||
Reference in New Issue
Block a user