From 756434779509b63ed07e2eb927bd2ca6e30398c0 Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Wed, 23 Feb 2022 21:36:34 -0600 Subject: Initial commit --- config.py | 12 +++++ main.py | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ on_this_day.py | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test.py | 3 ++ 4 files changed, 308 insertions(+) create mode 100644 config.py create mode 100644 main.py create mode 100644 on_this_day.py create mode 100644 test.py diff --git a/config.py b/config.py new file mode 100644 index 0000000..8fd06d4 --- /dev/null +++ b/config.py @@ -0,0 +1,12 @@ +config = { + "host": "http://daily.marks.kitchen", + "thoreau": {"journal1": "/home/mark/email-scripts/journal1.txt"}, + "news": { + "urls": "https://chroniclingamerica.loc.gov/lccn/sn96076642/%%s/ed-1/seq-1/,https://chroniclingamerica.loc.gov/lccn/sn85040451/%%s/ed-1/seq-1/", + "names": "Belding Banner,Vernon County Censor", + }, + "db": "/home/mark/rss.db", +} + + +# https://www.gutenberg.org/files/57393/57393-0.txt diff --git a/main.py b/main.py new file mode 100644 index 0000000..f30ed58 --- /dev/null +++ b/main.py @@ -0,0 +1,144 @@ +import on_this_day +import sys +import sqlite3 + +from datetime import datetime +from config import config +from http.server import HTTPServer, BaseHTTPRequestHandler + +def format_datetime(date): + return str(date) + +def generate_item(item): + return f""" + <![CDATA[{item["title"]}]]> + + {config["host"]}/{item["guid"]} + {item["guid"]} + {item["createdAt"]} + """ + +def generate_feed(items): + return f""" + On This Day + Daily posts of stuff for today + {format_datetime(datetime.now())} + {"".join(generate_item(item) for item in items)} + """ + +def generate_ul(items): + return f"""