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
14
tootbot.py
14
tootbot.py
|
@ -218,12 +218,22 @@ else:
|
|||
if 'photos' in t:
|
||||
for url in t['photos']:
|
||||
print('photo', url)
|
||||
media = requests.get(url)
|
||||
print("received")
|
||||
try:
|
||||
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.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
|
||||
links = re.findall(r"http[^ \xa0]*", c)
|
||||
|
|
Loading…
Reference in New Issue
Block a user