Add requirement for python-magic, and add wrappers to Mastodon.py
This commit is contained in:
pare
191ad84cef
commit
7e2259e3ee
S'han modificat 3 arxius amb 18 adicions i 2 eliminacions
4
.gitignore
vendido
4
.gitignore
vendido
|
@ -91,4 +91,6 @@ ENV/
|
|||
# Secret files (for credentials used in testing)
|
||||
*.secret
|
||||
pytooter_clientcred.txt
|
||||
pytooter_usercred.txt
|
||||
pytooter_usercred.txtPipfile
|
||||
Pipfile.lock
|
||||
Pipfile
|
||||
|
|
|
@ -31,6 +31,11 @@ try:
|
|||
except ImportError:
|
||||
from urlparse import urlparse
|
||||
|
||||
try:
|
||||
import magic
|
||||
except ImportError:
|
||||
magic = None
|
||||
|
||||
###
|
||||
# Version check functions, including decorator and parser
|
||||
###
|
||||
|
@ -2529,3 +2534,11 @@ class MastodonRatelimitError(MastodonError):
|
|||
class MastodonMalformedEventError(MastodonError):
|
||||
"""Raised when the server-sent event stream is malformed"""
|
||||
pass
|
||||
|
||||
def guess_type(media_file):
|
||||
mime_type = None
|
||||
if magic:
|
||||
mime_type = magic.from_file(media_file, mime=True)
|
||||
else:
|
||||
mime_type = mimetypes.guess_type(media_file)[0]
|
||||
return mime_type
|
||||
|
|
1
setup.py
1
setup.py
|
@ -14,6 +14,7 @@ setup(name='Mastodon.py',
|
|||
'python-dateutil',
|
||||
'six',
|
||||
'pytz',
|
||||
'python-magic',
|
||||
'decorator>=4.0.0',
|
||||
'http_ece>=1.0.5',
|
||||
'cryptography>=1.6.0'
|
||||
|
|
Loading…
Referencia en una nova incidència