From f010cec1e5bd74f219dc21d121db09f2856efca1 Mon Sep 17 00:00:00 2001 From: Alex Brooke Date: Thu, 18 Nov 2021 18:11:05 -0500 Subject: [PATCH] remove rfc6266-parser --- pros/common/utils.py | 20 +++++++++++--------- requirements.txt | 1 - 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pros/common/utils.py b/pros/common/utils.py index f825267c..96ebb12a 100644 --- a/pros/common/utils.py +++ b/pros/common/utils.py @@ -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): diff --git a/requirements.txt b/requirements.txt index 4cfe25c9..1e6fe13f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,6 @@ colorama pyzmq cobs scan-build==2.0.13 -rfc6266-parser sentry-sdk observable pypng==0.0.20