working podcast feed generation and webfrontend (index and episodes page)
This commit is contained in:
71
genfeed.py
Normal file
71
genfeed.py
Normal file
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import rfeed
|
||||
import datetime
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
|
||||
#wdrzeitzeichen_2015-05-30_Dante Alighieri italienischer Dichter Geburtstag_30051265_wdr5.mp3
|
||||
|
||||
items = []
|
||||
weblist = []
|
||||
for file in os.listdir("files"):
|
||||
|
||||
try:
|
||||
zz, date, name, stichtag, res = file.split("_")
|
||||
except:
|
||||
print(f"expansion failed: ", file)
|
||||
continue
|
||||
del(zz, res)
|
||||
year, month, day = list(map(int, date.split("-")))
|
||||
|
||||
# stichtag
|
||||
sday = stichtag[:2]
|
||||
smonth = stichtag[2:4]
|
||||
if stichtag.find("vchr") < 0:
|
||||
syear = stichtag[4:]
|
||||
vchr = ""
|
||||
else:
|
||||
syear = stichtag[4:-4]
|
||||
vchr = " v.Chr."
|
||||
|
||||
stichtag = f"{int(sday)}.{int(smonth)}.{int(syear)}{vchr}"
|
||||
|
||||
items.append(rfeed.Item(
|
||||
title=f"Zanderzeichen | {stichtag}: {name}",
|
||||
link = "https://dukun.de/xox/ZanderZeichen",
|
||||
description = f"WDR Zeitzeichen vom {day}.{month}.{year}\nStichtag {stichtag} zum Thema: {name}",
|
||||
author = "Hans Conrad Zander",
|
||||
guid = rfeed.Guid(file),
|
||||
enclosure = rfeed.Enclosure(url=f"https://dukun.de/xox/ZanderZeichen/files/{file}", length=os.path.getsize(f"files/{file}"), type="audio/mpeg"),
|
||||
pubDate = datetime.datetime(year, month, day)
|
||||
))
|
||||
|
||||
weblist.append([stichtag, name, f"files/{file}", (day, month, year)])
|
||||
|
||||
feed = rfeed.Feed(
|
||||
title = "ZanderZeichen",
|
||||
link = "https://dukun.de/xox/ZanderZeichen",
|
||||
description = "WDR ZeitZeichen von Hans Conrad Zander",
|
||||
language = "de-DE",
|
||||
lastBuildDate = datetime.datetime.now(),
|
||||
items = items)
|
||||
|
||||
with open("feed.xml", "w") as f:
|
||||
f.write(feed.rss())
|
||||
|
||||
# generate web listener
|
||||
with open("episoden.html", "w") as f:
|
||||
# site header
|
||||
f.write("""<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><link rel="stylesheet" type="text/css" href="style.css">
|
||||
<link rel="icon" type="image/vnd.microsoft.icon" href="favicon.ico"><meta name="robots" content="noindex,nofollow" /></head><body class=body>
|
||||
<div class=head></div><h3> </h3><div class=box><h2>ZanderZeichen: Webplayer</h2><a href=index.html>zurück</a><br><br>""")
|
||||
|
||||
# site entries
|
||||
for entry in weblist:
|
||||
stichtag, name, link, date = entry
|
||||
f.write(f"ZeitZeichen vom {date[0]}.{date[1]}.{date[2]}<br>{stichtag}: {name}<br><audio controls><source src={link}) type=\"audio/mp3\"></audio><br><br>")
|
||||
|
||||
# site footer
|
||||
f.write("""<br><br><a href=index.html>zurück</a></div><div class=foot><a href="https://dukun.de">dukun.de</a></div></body></html>""")
|
||||
Reference in New Issue
Block a user