deploy: cache and render source name for news items
This commit is contained in:
+4
-3
@@ -870,8 +870,8 @@ if __name__ == "__main__":
|
||||
cache_file = _HOME / "kiosk-home" / "news-data.json"
|
||||
|
||||
feeds = {
|
||||
"World News": "http://feeds.bbci.co.uk/news/world/rss.xml",
|
||||
"National News": "https://feeds.npr.org/1001/rss.xml"
|
||||
"World News": ("http://feeds.bbci.co.uk/news/world/rss.xml", "BBC News"),
|
||||
"National News": ("https://feeds.npr.org/1001/rss.xml", "NPR News")
|
||||
}
|
||||
|
||||
def scrape_article(url):
|
||||
@@ -917,7 +917,7 @@ if __name__ == "__main__":
|
||||
|
||||
while True:
|
||||
payload = {}
|
||||
for category, url in feeds.items():
|
||||
for category, (url, source_name) in feeds.items():
|
||||
try:
|
||||
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
|
||||
xml_raw = urllib.request.urlopen(req, timeout=12).read()
|
||||
@@ -953,6 +953,7 @@ if __name__ == "__main__":
|
||||
"title": t_str,
|
||||
"summary": full_story if full_story else "Click to read the story details.",
|
||||
"image": img_url,
|
||||
"source": source_name,
|
||||
"date": p_str
|
||||
})
|
||||
payload[category] = stories
|
||||
|
||||
Reference in New Issue
Block a user