diff --git a/bilix/download/base_downloader_part.py b/bilix/download/base_downloader_part.py index a9c98a50..c8458de7 100644 --- a/bilix/download/base_downloader_part.py +++ b/bilix/download/base_downloader_part.py @@ -7,7 +7,7 @@ import uuid import random import os -import cgi +from email.message import Message from pymp4.parser import Box from bilix.download.base_downloader import BaseDownloader from bilix.download.utils import path_check, merge_files @@ -48,8 +48,9 @@ async def _pre_req(self, urls: List[str]) -> Tuple[int, str]: total = int(res.headers['Content-Range'].split('/')[-1]) # get filename if content_disposition := res.headers.get('Content-Disposition', None): - key, pdict = cgi.parse_header(content_disposition) - filename = pdict.get('filename', '') + m = Message() + m['content-type'] = content_disposition + filename = m.get_param('filename', '') else: filename = '' # change origin url to redirected position to avoid twice redirect