use magic by default if available to get mimetype
This commit is contained in:
parent
79572a93ca
commit
81f3ff9f5b
|
@ -750,12 +750,13 @@ class GeminiItem():
|
||||||
path = self.path
|
path = self.path
|
||||||
else:
|
else:
|
||||||
path = self._cache_path
|
path = self._cache_path
|
||||||
mime,encoding = mimetypes.guess_type(path,strict=False)
|
if _HAS_MAGIC:
|
||||||
|
mime = magic.from_file(path,mime=True)
|
||||||
|
else:
|
||||||
|
mime,encoding = mimetypes.guess_type(path,strict=False)
|
||||||
#gmi Mimetype is not recognized yet
|
#gmi Mimetype is not recognized yet
|
||||||
if not mime and path.endswith(".gmi"):
|
if not mime and path.endswith(".gmi"):
|
||||||
mime = "text/gemini"
|
mime = "text/gemini"
|
||||||
elif not mime and _HAS_MAGIC :
|
|
||||||
mime = magic.from_file(path,mime=True)
|
|
||||||
elif not _HAS_MAGIC :
|
elif not _HAS_MAGIC :
|
||||||
print("Cannot guess the mime type of the file. Install Python-magic")
|
print("Cannot guess the mime type of the file. Install Python-magic")
|
||||||
if mime.startswith("text") and mime not in _FORMAT_RENDERERS:
|
if mime.startswith("text") and mime not in _FORMAT_RENDERERS:
|
||||||
|
|
Loading…
Reference in New Issue