Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚸 remove old rfc6266-parser package #182

Merged
merged 1 commit into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions pros/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,22 @@ def download_file(url: str, ext: Optional[str] = None, desc: Optional[str] = Non
"""
import requests
from pros.common.ui import progressbar
from rfc6266_parser import parse_requests_response
# from rfc6266_parser import parse_requests_response
import re

response = requests.get(url, stream=True)
if response.status_code == 200:
filename: str = url.rsplit('/', 1)[-1]
if 'Content-Disposition' in response.headers.keys():
try:
disposition = parse_requests_response(response)
if isinstance(ext, str):
filename = disposition.filename_sanitized(ext)
else:
filename = disposition.filename_unsafe
except RuntimeError:
pass
filename = re.findall("filename=(.+)", response.headers['Content-Disposition'])[0]
# try:
# disposition = parse_requests_response(response)
# if isinstance(ext, str):
# filename = disposition.filename_sanitized(ext)
# else:
# filename = disposition.filename_unsafe
# except RuntimeError:
# pass
output_path = os.path.join(get_pros_dir(), 'download', filename)

if os.path.exists(output_path):
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ colorama
pyzmq
cobs
scan-build==2.0.13
rfc6266-parser
sentry-sdk
observable
pypng==0.0.20