summaryrefslogtreecommitdiff
path: root/rss.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 /rss.py
parent121f1890b1618c92d7a8fc6d174881e66ab6b7c1 (diff)
downloadrss-feeds-b335495aadc9f5116a88d0359087ae33c9524aed.tar.gz
rss-feeds-b335495aadc9f5116a88d0359087ae33c9524aed.tar.bz2
rss-feeds-b335495aadc9f5116a88d0359087ae33c9524aed.zip
Fix dataclass usage
Diffstat (limited to 'rss.py')
-rwxr-xr-xrss.py30
1 files changed, 2 insertions, 28 deletions
diff --git a/rss.py b/rss.py
index ccf0cb5..dc16628 100755
--- a/rss.py
+++ b/rss.py
@@ -1,8 +1,9 @@
#!/usr/bin/env python3
-from dataclasses import dataclass
from datetime import datetime
+from rss_types import RSSFeed
+
def _format_date(dt):
"""convert a datetime into an RFC 822 formatted date
@@ -50,39 +51,12 @@ def _format_date(dt):
)
-@dataclass
-class RSSItem:
- title: str
- url: str
- content: str
- date: str
- enclosures: list[str]
- guid: str
-
-
-@dataclass
-class RSSFeed:
- title: str
- url: str
- description: str
- content: list[RSSItem]
-
-
def escape(str):
str = str.replace("&", "&amp;")
return str
def buildRSS(feed_data: RSSFeed):
- """
- feed_data = {
- title, url, description,
- content = [{
- title, url, content, date, [enclosures], guid
- }]
- }
- """
-
feed = f"""<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
<channel>