From 52418884284b5bf0919c48cf4b02c3bd23dc9e97 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sat, 2 Sep 2023 00:38:23 +0300 Subject: Do stuff --- app/FeedSourcePlugin.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'app/FeedSourcePlugin.py') diff --git a/app/FeedSourcePlugin.py b/app/FeedSourcePlugin.py index af686b9..5453f80 100644 --- a/app/FeedSourcePlugin.py +++ b/app/FeedSourcePlugin.py @@ -12,17 +12,19 @@ class Plugin(PluginInterface): print(f"[FeedSourcePlugin#{self.id}] initialized") - def validate_input_n(self, n: int) -> bool: - return n == 0 - - def process(self, inputs: list[list[Item]]) -> list[Item]: + def process(self, items: list[Item]) -> list[Item]: print(f"[FeedSourcePlugin#{self.id}] process called") feed: Any = feedparser.parse(self.feed_url) # type: ignore - items: list[Item] = [] + result_items: list[Item] = [] + if "bozo" in feed and feed["bozo"] == 1: + raise Exception( + f"[FeedSourcePlugin#{self.id}] malformed XML in feed {self.feed_url}" + ) + for d in feed.entries: - items.append( + result_items.append( Item(title=d["title"], link=d["link"], description=d["description"]) ) print(f"[FeedSourcePlugin#{self.id}] process returns items, n={len(items)}") - return items + return result_items -- cgit v1.3