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

View File

@@ -9,7 +9,6 @@ import base64
from auto_archiver.version import __version__
from auto_archiver.core import Metadata, Media
from auto_archiver.core import Formatter
from auto_archiver.modules.hash_enricher import HashEnricher
from auto_archiver.utils.misc import random_str
from auto_archiver.core.module import get_module