Last active 2 weeks ago

tre revised this gist 2 weeks ago. Go to revision

No changes

tre revised this gist 2 weeks ago. Go to revision

1 file changed, 36 insertions

rsstofedi.py(file created)

@@ -0,0 +1,36 @@
1 + import feedparser,re,time,requests
2 + from mastodon import Mastodon
3 +
4 + posts = []
5 +
6 + with open(LOGFILE,"r") as log:
7 + last = log.read()
8 + rss = feedparser.parse(RSS)
9 + guids = []
10 + for 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 +
20 + mastodon = Mastodon(access_token="TOKEN",api_base_url="https://kes.praze.net",
21 + feature_set="pleroma",version_check_mode="none")
22 +
23 + if 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 +
34 + if len(guids) > 0:
35 + with open(LOGFILE,"w") as log:
36 + log.write(guids[0])
Newer Older