From a7b3de1fd8c55d90b0bca582d4722e53acf2036d Mon Sep 17 00:00:00 2001 From: YeZheng Date: Tue, 12 Dec 2023 17:39:14 +0800 Subject: [PATCH] fix subtitle download --- edx_helper/edx_dl.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/edx_helper/edx_dl.py b/edx_helper/edx_dl.py index f45019f..617709b 100644 --- a/edx_helper/edx_dl.py +++ b/edx_helper/edx_dl.py @@ -854,17 +854,18 @@ def download_subtitle_without_name(url, target_dir, filename, headers): """ Downloads the subtitle from the url """ - response = requests.get(url, headers) + # response = requests.get(url, headers) + response = requests.get(url) if not filename: resp_headers = response.headers['Content-Disposition'] m = re.compile(r'filename="(.*)"').search(resp_headers) if m: filename = m.group(1) else: - logging.warning('Not setting file name for: %s', url) + logging.error('Not setting file name for: %s', url) return file_path = os.path.join(target_dir, filename) - with open(file_path, 'wb', encoding='utf-8') as f: + with open(file_path, 'wb') as f: f.write(response.content)