summaryrefslogtreecommitdiff
path: root/zdf.py
diff options
context:
space:
mode:
authorAndré Glüpker <git@wgmd.de>2024-05-01 10:20:30 +0200
committerAndré Glüpker <git@wgmd.de>2024-05-01 10:20:30 +0200
commitb335495aadc9f5116a88d0359087ae33c9524aed (patch)
tree674f79b4dea91d17d56bf4a23ef91f5e689df347 /zdf.py
parent121f1890b1618c92d7a8fc6d174881e66ab6b7c1 (diff)
downloadrss-feeds-b335495aadc9f5116a88d0359087ae33c9524aed.tar.gz
rss-feeds-b335495aadc9f5116a88d0359087ae33c9524aed.tar.bz2
rss-feeds-b335495aadc9f5116a88d0359087ae33c9524aed.zip
Fix dataclass usage
Diffstat (limited to 'zdf.py')
-rwxr-xr-xzdf.py35
1 files changed, 20 insertions, 15 deletions
diff --git a/zdf.py b/zdf.py
index 3c6d903..0d5adc1 100755
--- a/zdf.py
+++ b/zdf.py
@@ -1,8 +1,12 @@
+#!/usr/bin/env python3
+
import logging
from datetime import datetime
from urllib.request import Request, urlopen
from xml.dom.minidom import parseString
+from rss_types import RSSFeed, RSSItem
+
def getText(dom, element):
textNode = dom.getElementsByTagName(element)[0].firstChild
@@ -31,7 +35,7 @@ def zdf(feed):
title = getText(xml, "title")
description = getText(xml, "description")
- content = []
+ rss_items = []
for show in xml.getElementsByTagName("item"):
s_url = getText(show, "link")
if not s_url:
@@ -61,22 +65,23 @@ def zdf(feed):
s_desc = getText(show, "description")
s_guid = getText(show, "guid")
- content.append(
- {
- "title": s_title,
- "url": s_url,
- "content": s_desc,
- "date": s_date,
- "guid": s_guid,
- }
+ rss_items.append(
+ RSSItem(
+ title=s_title,
+ url=s_url,
+ content=s_desc,
+ date=s_date,
+ guid=s_guid,
+ enclosures=[],
+ )
)
- return {
- "title": title,
- "url": url,
- "description": description,
- "content": content,
- }
+ return RSSFeed(
+ title=title,
+ url=url,
+ description=description,
+ content=rss_items,
+ )
except Exception as exc:
logging.error("Working with zdf failed.", exc_info=exc)
return None