Rewrote main.py
This commit is contained in:
23
rss-feed-notif/rss-feed.py
Normal file
23
rss-feed-notif/rss-feed.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from typing import List
|
||||
import feedparser
|
||||
import tomllib
|
||||
import json
|
||||
with open("config.toml","rb") as file:
|
||||
config = tomllib.load(file)
|
||||
print(config)
|
||||
|
||||
previous_msgs = set()
|
||||
|
||||
def read_rss_feeds(client):
|
||||
for feed_name,feed_link in config["rss-feeds"].items():
|
||||
feed = feedparser.parse(feed_link)
|
||||
for feed_post in feed.entries:
|
||||
if feed_post.title in previous_msgs:
|
||||
continue
|
||||
else:
|
||||
previous_msgs.add(feed_post.title)
|
||||
notif_json = {"title":feed_post.title,"body":feed_post.description,"topic":"overlordian-news-192","link":feed_post.link}
|
||||
client.publish("notification-pusher",json.dumps(notif_json),0)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user