Last active 2 weeks ago

Revision f0cf85e386752aa66733cefbe064af453046de5c

rsstofedi.py Raw
1import feedparser,re,time,requests
2from mastodon import Mastodon
3
4posts = []
5
6with open(LOGFILE,"r") as log:
7 last = log.read()
8rss = feedparser.parse(RSS)
9guids = []
10for entry in rss.entries:
11 if entry.guid == last:
12 break
13 else:
14 thestring = "[LINK TEXT](" + entry.link + ") " + entry.summary + " #TAG"
15 posts.append(thestring)
16 guids.append(entry.guid)
17
18# repeat the above for each rss feed
19
20mastodon = Mastodon(access_token="TOKEN",api_base_url="https://kes.praze.net",
21feature_set="pleroma",version_check_mode="none")
22
23if len(posts) > 0:
24 try:
25 posts = posts[::-1]
26 except:
27 pass
28 for post in posts:
29 mastodon.status_post(post,content_type="text/markdown")
30 time.sleep(10)
31
32# repeat the below for each rss feed
33
34if len(guids) > 0:
35 with open(LOGFILE,"w") as log:
36 log.write(guids[0])