improves mimetype guessing, previously file.sub.something would not have an extension

This commit is contained in:
msramalho
2025-02-11 15:02:49 +00:00
parent 5478ed3860
commit e507fc81d2
2 changed files with 2 additions and 3 deletions

View File

@@ -80,8 +80,8 @@ class Extractor(BaseModule):
d.raise_for_status()
# get mimetype from the response headers
if not Path(to_filename).suffix:
content_type = d.headers.get('Content-Type')
if not mimetypes.guess_type(to_filename)[0]:
content_type = d.headers.get('Content-Type') or self._guess_file_type(url)
extension = mimetypes.guess_extension(content_type)
if extension:
to_filename += extension