mirror of
https://github.com/cquest/tootbot.git
synced 2024-11-23 20:11:06 +00:00
handle non retrievable pictures (403)
This commit is contained in:
parent
d022f43aa3
commit
1acd039871
|
@ -167,10 +167,11 @@ if source[:4] == 'http':
|
||||||
if 'links' in t:
|
if 'links' in t:
|
||||||
for l in t.links:
|
for l in t.links:
|
||||||
if l.type in ('image/gif', 'image/jpg', 'image/png', 'image/webp'):
|
if l.type in ('image/gif', 'image/jpg', 'image/png', 'image/webp'):
|
||||||
media = requests.get(l.url)
|
media = requests.get(l.url, headers = {'User-agent': 'Mozilla/5.0'})
|
||||||
media_posted = mastodon_api.media_post(
|
if media.status_code == 200:
|
||||||
media.content, mime_type=media.headers.get('content-type'))
|
media_posted = mastodon_api.media_post(
|
||||||
toot_media.append(media_posted['id'])
|
media.content, mime_type=media.headers.get('content-type'))
|
||||||
|
toot_media.append(media_posted['id'])
|
||||||
|
|
||||||
# replace short links by original URL
|
# replace short links by original URL
|
||||||
m = re.search(r"http[^ \xa0]*", c)
|
m = re.search(r"http[^ \xa0]*", c)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user