tg_rss_bot/rss.py
mitsuha_s 94c1447093
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
refactor a bit in rss.py
2022-06-12 17:13:58 +00:00

21 lines
590 B
Python

from feedparser import FeedParserDict, parse
class FeedItem:
def __init__(self, item: FeedParserDict) -> None:
self.url = item.get('link', '')
self.title = item.get('title', '')
self.description = item.get('summary', '')
self.date = item.get('published', '')
class Feed:
def __init__(self, url: str, feed: FeedParserDict) -> None:
self.url = url
self.items = []
for item in feed:
self.items.append(FeedItem(item))
class RssReader:
def get_feed(self, url: str) -> Feed:
return Feed(url, parse(url))