fix methods in rss.py
This commit is contained in:
parent
799ecd239a
commit
629db4c25d
17
rss.py
17
rss.py
|
@ -2,10 +2,11 @@ import feedparser
|
||||||
|
|
||||||
|
|
||||||
class FeedItem():
|
class FeedItem():
|
||||||
def __init__(self, url: str, title: str, description: str) -> None:
|
def __init__(self, url: str, title: str, description: str, date: str) -> None:
|
||||||
self.url = url
|
self.url = url
|
||||||
self.title = title
|
self.title = title
|
||||||
self.description = description
|
self.description = description
|
||||||
|
self.date = date
|
||||||
|
|
||||||
class Feed():
|
class Feed():
|
||||||
def __init__(self, url: str, items: list[FeedItem]) -> None:
|
def __init__(self, url: str, items: list[FeedItem]) -> None:
|
||||||
|
@ -18,14 +19,12 @@ class RssReader():
|
||||||
items = self.__get_items(f.entries)
|
items = self.__get_items(f.entries)
|
||||||
return Feed(url, items)
|
return Feed(url, items)
|
||||||
|
|
||||||
def __convert_to_feed_item(self, item: dict) -> FeedItem:
|
def __convert_to_feed_item(self, item: feedparser.util.FeedParserDict) -> FeedItem:
|
||||||
if 'title' in item:
|
title = item.get('title', '')
|
||||||
title = item['title']
|
url = item.get('link', '')
|
||||||
if 'link' in item:
|
description = item.get('summary', '')
|
||||||
url = item['link']
|
date = item.get('published', '')
|
||||||
if 'summary' in item:
|
return FeedItem(url, title, description, date)
|
||||||
description = item['summary']
|
|
||||||
return FeedItem(url, title, description)
|
|
||||||
|
|
||||||
def __get_items(self, items: list) -> list:
|
def __get_items(self, items: list) -> list:
|
||||||
list_items = []
|
list_items = []
|
||||||
|
|
Loading…
Reference in a new issue