handle non retrievable pictures (403)

This commit is contained in:
cquest 2023-07-02 10:56:24 +02:00
parent d022f43aa3
commit 1acd039871

View File

@ -167,7 +167,8 @@ if source[:4] == 'http':
if 'links' in t:
for l in t.links:
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'})
if media.status_code == 200:
media_posted = mastodon_api.media_post(
media.content, mime_type=media.headers.get('content-type'))
toot_media.append(media_posted['id'])