mirror of
https://github.com/cquest/tootbot.git
synced 2025-02-24 19:18:38 +00:00
Compare commits
2 Commits
d022f43aa3
...
bea70c722c
Author | SHA1 | Date | |
---|---|---|---|
|
bea70c722c | ||
|
1acd039871 |
11
tootbot.py
11
tootbot.py
@ -167,10 +167,11 @@ 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_posted = mastodon_api.media_post(
|
||||
media.content, mime_type=media.headers.get('content-type'))
|
||||
toot_media.append(media_posted['id'])
|
||||
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'])
|
||||
|
||||
# replace short links by original URL
|
||||
m = re.search(r"http[^ \xa0]*", c)
|
||||
@ -201,7 +202,7 @@ if source[:4] == 'http':
|
||||
in_reply_to_id=None,
|
||||
media_ids=toot_media,
|
||||
sensitive=False,
|
||||
visibility='public',
|
||||
visibility='unlisted',
|
||||
spoiler_text=None)
|
||||
if "id" in toot:
|
||||
db.execute("INSERT INTO tweets VALUES ( ? , ? , ? , ? , ? )",
|
||||
|
Loading…
x
Reference in New Issue
Block a user