mirror of
https://github.com/cquest/tootbot.git
synced 2024-11-27 14:01:07 +00:00
get pics from nitter and fallback to twitter
This commit is contained in:
parent
d54ca76d7e
commit
b2185b6434
14
tootbot.py
14
tootbot.py
|
@ -218,12 +218,22 @@ else:
|
||||||
if 'photos' in t:
|
if 'photos' in t:
|
||||||
for url in t['photos']:
|
for url in t['photos']:
|
||||||
print('photo', url)
|
print('photo', url)
|
||||||
media = requests.get(url)
|
try:
|
||||||
print("received")
|
media = requests.get(url.replace(
|
||||||
|
'https://pbs.twimg.com/', 'https://nitter.net/pic/orig/'))
|
||||||
|
print("received nitter", media.headers.get('content-type'))
|
||||||
media_posted = mastodon_api.media_post(
|
media_posted = mastodon_api.media_post(
|
||||||
media.content, mime_type=media.headers.get('content-type'))
|
media.content, mime_type=media.headers.get('content-type'))
|
||||||
print("posted")
|
print("posted")
|
||||||
toot_media.append(media_posted['id'])
|
toot_media.append(media_posted['id'])
|
||||||
|
except:
|
||||||
|
media = requests.get(url)
|
||||||
|
print("received twitter", media.headers.get('content-type'))
|
||||||
|
media_posted = mastodon_api.media_post(
|
||||||
|
media.content, mime_type=media.headers.get('content-type'))
|
||||||
|
print("posted")
|
||||||
|
toot_media.append(media_posted['id'])
|
||||||
|
|
||||||
|
|
||||||
# replace short links by original URL
|
# replace short links by original URL
|
||||||
links = re.findall(r"http[^ \xa0]*", c)
|
links = re.findall(r"http[^ \xa0]*", c)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user