Merge pull request #208 from limburgher/master
Try/catch magic for #207.
This commit is contained in:
commit
4e76f6e322
S'han modificat 1 arxius amb 2 adicions i 2 eliminacions
|
@ -3672,8 +3672,8 @@ class MastodonMalformedEventError(MastodonError):
|
||||||
|
|
||||||
def guess_type(media_file):
|
def guess_type(media_file):
|
||||||
mime_type = None
|
mime_type = None
|
||||||
if magic:
|
try:
|
||||||
mime_type = magic.from_file(media_file, mime=True)
|
mime_type = magic.from_file(media_file, mime=True)
|
||||||
else:
|
except AttributeError:
|
||||||
mime_type = mimetypes.guess_type(media_file)[0]
|
mime_type = mimetypes.guess_type(media_file)[0]
|
||||||
return mime_type
|
return mime_type
|
||||||
|
|
Loading…
Referencia en una nova incidència