mirror of
https://gitlab.com/jeancf/twoot.git
synced 2024-11-27 14:01:13 +00:00
Added tolerance for mastodonAPIError when uploading invalid media
This commit is contained in:
parent
5b23c66b6b
commit
1b1faf2d59
9
twoot.py
9
twoot.py
|
@ -27,7 +27,7 @@ from bs4 import BeautifulSoup, element
|
|||
import sqlite3
|
||||
import time
|
||||
import re
|
||||
from mastodon import Mastodon, MastodonError
|
||||
from mastodon import Mastodon, MastodonError, MastodonAPIError
|
||||
|
||||
|
||||
USER_AGENTS = [
|
||||
|
@ -312,8 +312,11 @@ def main(argv):
|
|||
media = requests.get(photo)
|
||||
|
||||
# Upload picture to Mastodon instance
|
||||
media_posted = mastodon.media_post(media.content, mime_type=media.headers.get('content-type'))
|
||||
media_ids.append(media_posted['id'])
|
||||
try:
|
||||
media_posted = mastodon.media_post(media.content, mime_type=media.headers.get('content-type'))
|
||||
media_ids.append(media_posted['id'])
|
||||
except MastodonAPIError: # Media cannot be uploaded (invalid format, dead link, etc.)
|
||||
pass
|
||||
|
||||
# Post toot
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue
Block a user