|
@@ -33,24 +33,23 @@ for post in data:
|
|
|
out = post['created'] +"\n\n"+post['heading']+"\n\n"
|
|
|
|
|
|
# CHECK MEDIA LINK
|
|
|
- media_id = False
|
|
|
- if post['linked_file']:
|
|
|
- # MEDIA LINK URL
|
|
|
- linkurl = "https://italy.indymedia.org/uploads/"
|
|
|
- # IMAGES ONLY
|
|
|
- try:
|
|
|
+ try:
|
|
|
+ media_id = False
|
|
|
+ if post['linked_file']:
|
|
|
+ # MEDIA LINK URL
|
|
|
+ linkurl = "https://italy.indymedia.org/uploads/"
|
|
|
+ # IMAGES ONLY
|
|
|
if post['linked_file'].lower().find('jpg') >= 0 or \
|
|
|
- post['linked_file'].lower().find('jpeg') >= 0 or \
|
|
|
- post['linked_file'].lower().find('gif') >= 0:
|
|
|
- response = requests.get("https://italy.indymedia.org/uploads/" + post['linked_file'])
|
|
|
- with open('./tmp', 'wb') as f:
|
|
|
- f.write(response.content)
|
|
|
- media_id = mastodon.media_post('./tmp')
|
|
|
- except Exception:
|
|
|
- traceback.print_exc()
|
|
|
-
|
|
|
-
|
|
|
- media_ids = [media_id] if media_id else []
|
|
|
- out += 'LEGGI IL POST: '+url
|
|
|
- print(out)
|
|
|
- mastodon.status_post(out, media_ids=media_ids)
|
|
|
+ post['linked_file'].lower().find('jpeg') >= 0 or \
|
|
|
+ post['linked_file'].lower().find('gif') >= 0:
|
|
|
+ response = requests.get("https://italy.indymedia.org/uploads/" + post['linked_file'])
|
|
|
+ with open('./tmp', 'wb') as f:
|
|
|
+ f.write(response.content)
|
|
|
+ media_id = mastodon.media_post('./tmp')
|
|
|
+
|
|
|
+ media_ids = [media_id] if media_id else []
|
|
|
+ out += 'LEGGI IL POST: '+url
|
|
|
+ print(out)
|
|
|
+ mastodon.status_post(out, media_ids=media_ids)
|
|
|
+ except Exception:
|
|
|
+ traceback.print_exc()
|