mirror of
https://gitlab.com/jeancf/twoot.git
synced 2024-12-18 08:10:21 +00:00
Added fix for crash when mime_type is NoneType
This commit is contained in:
parent
806b57f763
commit
0eac3065d5
8
twoot.py
8
twoot.py
|
@ -314,9 +314,15 @@ def main(argv):
|
||||||
# Download picture
|
# Download picture
|
||||||
media = requests.get(photo)
|
media = requests.get(photo)
|
||||||
|
|
||||||
|
# Fix to avoid media_post failing because mime_type is NoneType
|
||||||
|
# "Can only concatenate str to str"
|
||||||
|
mime_type = media.headers.get('content-type')
|
||||||
|
if type(mime_type) is None:
|
||||||
|
mime_type = ""
|
||||||
|
|
||||||
# Upload picture to Mastodon instance
|
# Upload picture to Mastodon instance
|
||||||
try:
|
try:
|
||||||
media_posted = mastodon.media_post(media.content, mime_type=media.headers.get('content-type'))
|
media_posted = mastodon.media_post(media.content, mime_type)
|
||||||
media_ids.append(media_posted['id'])
|
media_ids.append(media_posted['id'])
|
||||||
except MastodonAPIError: # Media cannot be uploaded (invalid format, dead link, etc.)
|
except MastodonAPIError: # Media cannot be uploaded (invalid format, dead link, etc.)
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue
Block a user