mirror of
https://github.com/cquest/tootbot.git
synced 2024-11-23 20:11:06 +00:00
get pics from nitter and fallback to twitter
This commit is contained in:
parent
d54ca76d7e
commit
b2185b6434
22
tootbot.py
22
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(
|
||||||
media_posted = mastodon_api.media_post(
|
'https://pbs.twimg.com/', 'https://nitter.net/pic/orig/'))
|
||||||
media.content, mime_type=media.headers.get('content-type'))
|
print("received nitter", media.headers.get('content-type'))
|
||||||
print("posted")
|
media_posted = mastodon_api.media_post(
|
||||||
toot_media.append(media_posted['id'])
|
media.content, mime_type=media.headers.get('content-type'))
|
||||||
|
print("posted")
|
||||||
|
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