diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2023-09-02 00:38:23 +0300 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2023-09-10 19:01:00 +0300 |
| commit | 52418884284b5bf0919c48cf4b02c3bd23dc9e97 (patch) | |
| tree | 932b30bce805c5602c7cf49c1a8ffef05d8f6a18 /app/FeedSourcePlugin.py | |
| parent | 398799de0c1826c3544eb6eec681fa48096932a0 (diff) | |
Do stuff
Diffstat (limited to 'app/FeedSourcePlugin.py')
| -rw-r--r-- | app/FeedSourcePlugin.py | 16 |
1 files changed, 9 insertions, 7 deletions
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 |
