web: Download-Links (Jottacloud) pro Sendung via jottalinks.txt

- neue Datei jottalinks.txt: Format NNN<TAB>URL, #-Kommentare, nur http(s)
- katalog_web.py: parse_jottalinks(), neue Spalte 'Download' mit ⬇-MP3-Button
  in sendungen.html, Zaehler 'mit Download-Link' auf index.html, Footer-Hinweis
- neue_sendungen.py: Hinweis auf jottalinks.txt nach dem Lauf
- README: Anleitung manuelles Eintragen + Warnung (oeffentliche Links ohne
  Passwortschutz bei Jottacloud -> Seite ggf. per .htaccess schuetzen)
- web/ neu generiert (720 Sendungen, Spalte Download, noch 0 Links)
- Skripte + jottalinks.txt als Kopien ins Archiv gelegt

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
root
2026-11-19 19:56:26 +01:00
parent d0a6828cde
commit 039337c058
8 changed files with 106 additions and 21 deletions

View File

@ -3,7 +3,8 @@
katalog_web.py - statische Webseiten aus den Katalogdateien erzeugen
Liest aus dem Archiv-Verzeichnis (src):
Sendungsliste.txt, Themenkatalog.txt, Namensverzeichnis.txt, abstracts.txt
Sendungsliste.txt, Themenkatalog.txt, Namensverzeichnis.txt, abstracts.txt,
jottalinks.txt (Download-Links, optional)
und schreibt ein statisches Site nach (out, Default: <src>/web):
index.html, sendungen.html, themen.html, namen.html
@ -116,6 +117,25 @@ def parse_abstracts(path):
return result
def parse_jottalinks(path):
"""-> dict nr -> url. Format: 'NNN<TAB>URL'; #-Kommentare ignoriert,
nur http(s)-Links werden uebernommen."""
links = {}
if not os.path.exists(path):
return links
with open(path, encoding="utf-8") as fh:
for line in fh:
line = line.rstrip("\n")
if not line.strip() or line.lstrip().startswith("#"):
continue
parts = line.split("\t")
if len(parts) >= 2 and re.match(r"^\d{3}$", parts[0].strip()):
url = parts[1].strip()
if re.match(r"^https?://", url, re.I):
links[parts[0].strip()] = url
return links
# ---------- HTML ----------
CSS = """
@ -162,6 +182,9 @@ footer { max-width:1100px; margin:2rem auto; padding:1rem; color:var(--muted); f
border-top:1px solid var(--line); }
.tag { display:inline-block; background:var(--card); border:1px solid var(--line);
border-radius:5px; padding:0 .35rem; font-size:.8rem; color:var(--muted); text-decoration:none; }
a.dl { display:inline-block; border:1px solid var(--line); border-radius:6px;
padding:0 .5rem; font-size:.85rem; text-decoration:none; white-space:nowrap; }
a.dl:hover { border-color:var(--accent); background:var(--card); }
"""
JS = """
@ -206,14 +229,15 @@ def page(title, body, active, extra_nav=""):
<span id="count" class="ordner"></span></header>
<main>{body}</main>
<footer>Generiert am {datetime.date.today().strftime('%d.%m.%Y')} aus Sendungsliste.txt,
Themenkatalog.txt, Namensverzeichnis.txt und abstracts.txt · katalog_web.py</footer>
Themenkatalog.txt, Namensverzeichnis.txt, abstracts.txt und jottalinks.txt · katalog_web.py</footer>
<script>{JS}</script></body></html>"""
def build_index(out, rows, sections, persons):
def build_index(out, rows, sections, persons, links):
n_send = len(rows)
n_themen = sum(len(e) for _r, e in sections)
n_mit_abs = len(parse_abstracts(os.path.join(out_src, "abstracts.txt")))
n_link = sum(1 for r in rows if r["nr"] in links)
body = f"""
<h1>Lange Nacht — Aufnahme-Archiv</h1>
<p>Stöbern in {n_send} aufgenommenen „Lange Nacht“-Sendungen (Deutschlandfunk /
@ -221,7 +245,7 @@ Deutschlandfunk Kultur): nach <a href="sendungen.html">Nummer</a>,
<a href="themen.html">Thema</a> oder <a href="namen.html">Person</a>.</p>
<div class="cards">
<a class="card" href="sendungen.html"><h2>Sendungsliste</h2>
<span class="count">{n_send} Sendungen, {n_mit_abs} mit Abstract</span></a>
<span class="count">{n_send} Sendungen, {n_mit_abs} mit Abstract, {n_link} mit Download-Link</span></a>
<a class="card" href="themen.html"><h2>Themenkatalog</h2>
<span class="count">{len(sections)} Rubriken, {n_themen} Einträge</span></a>
<a class="card" href="namen.html"><h2>Namensverzeichnis</h2>
@ -236,7 +260,7 @@ def _datum_key(d):
return (int(m.group(3)), int(m.group(2)), int(m.group(1))) if m else None
def build_sendungen(out, rows, abstracts):
def build_sendungen(out, rows, abstracts, links):
# neueste zuerst, Aufnahmen ohne Datum ganz unten
dated = [r for r in rows if _datum_key(r["datum"])]
undated = [r for r in rows if not _datum_key(r["datum"])]
@ -250,15 +274,18 @@ def build_sendungen(out, rows, abstracts):
det = ""
if abs_text:
det = (f'<details><summary>Abstract</summary><p>{esc(abs_text)}</p></details>')
dl = (f'<a class="dl" href="{esc(links[nr])}" target="_blank" rel="noopener" '
f'title="Download (Jottacloud)">⬇ MP3</a>') if nr in links else ""
trs.append(
f'<tr data-row data-ordner="{esc(r["ordner"])}" id="s{nr}">'
f'<td class="nr">{nr}</td><td class="nr">{esc(r["datum"])}</td>'
f'<td>{esc(r["titel"])}{det}</td>'
f'<td class="ordner">{esc(r["ordner"])}</td></tr>')
f'<td class="ordner">{esc(r["ordner"])}</td>'
f'<td>{dl}</td></tr>')
body = f"""
<h1>Sendungsliste</h1>
<p class="ordner">neueste zuerst; Aufnahmen ohne Datum stehen ganz unten</p>
<table><thead><tr><th>Nr</th><th>Datum</th><th>Titel</th><th>Ordner</th></tr></thead>
<p class="ordner">neueste zuerst; Aufnahmen ohne Datum stehen ganz unten · ⬇ MP3 = Download-Link (Jottacloud)</p>
<table><thead><tr><th>Nr</th><th>Datum</th><th>Titel</th><th>Ordner</th><th>Download</th></tr></thead>
<tbody>{''.join(trs)}</tbody></table>"""
p = page("Sendungen", body, "sendungen")
# Ordner-Filter einbauen
@ -313,16 +340,18 @@ def main(src=None, out=None):
header, sections = parse_themenkatalog(os.path.join(src, "Themenkatalog.txt"))
persons = parse_namensverzeichnis(os.path.join(src, "Namensverzeichnis.txt"))
abstracts = parse_abstracts(os.path.join(src, "abstracts.txt"))
links = parse_jottalinks(os.path.join(src, "jottalinks.txt"))
with open(os.path.join(out, "index.html"), "w", encoding="utf-8") as fh:
fh.write(build_index(out, rows, sections, persons))
fh.write(build_index(out, rows, sections, persons, links))
with open(os.path.join(out, "sendungen.html"), "w", encoding="utf-8") as fh:
fh.write(build_sendungen(out, rows, abstracts))
fh.write(build_sendungen(out, rows, abstracts, links))
with open(os.path.join(out, "themen.html"), "w", encoding="utf-8") as fh:
fh.write(build_themen(out, sections))
with open(os.path.join(out, "namen.html"), "w", encoding="utf-8") as fh:
fh.write(build_namen(out, persons))
print(f"Web-Katalog geschrieben nach {out}: "
f"{len(rows)} Sendungen, {len(sections)} Rubriken, {len(persons)} Personen.")
f"{len(rows)} Sendungen, {len(sections)} Rubriken, {len(persons)} Personen, "
f"{len(links)} Download-Links.")
if __name__ == "__main__":