Skip to content

Commit

Permalink
fix subtitle download
Browse files Browse the repository at this point in the history
  • Loading branch information
csyezheng committed Dec 12, 2023
1 parent 77fbd6f commit a7b3de1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions edx_helper/edx_dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit a7b3de1

Please sign in to comment.