1
0
mirror of https://github.com/kmein/niveum synced 2026-03-20 03:51:07 +01:00

2 Commits

Author SHA1 Message Date
87f73a8fc1 fix(radio): clean up files after 1h 2022-02-10 19:28:34 +01:00
db8c06364f feat: wikipedia radio 2022-02-10 19:28:34 +01:00
4 changed files with 74 additions and 72 deletions

View File

@@ -64,6 +64,12 @@ in [
logo = "https://www.lyrikline.org/themes/lyrik/svg/Logo_lyrikline_pure.svg";
desc = "24/7 zufällige Wiedergaben von lyrikline.org.";
}
{
stream = "https://radio.kmein.de/wikipedia.ogg";
station = "Wikipedia";
desc = "Zufällige Wikipedia-Artikel";
logo = "https://de.wikipedia.org/wiki/Wikipedia:Enzyklop%C3%A4die/Logo_von_Wikipedia#/media/Datei:Wikipedia-logo-v2.svg";
}
{
stream = "http://162.244.80.20:6948";
station = "Cool Jazz Florida";
@@ -1167,15 +1173,15 @@ importJSON ./radiorecord.json
station = "Dhol Radio";
desc = " ";
}
{ logo = bhaktiworld-logo; stream = bhaktiworld "2bhanuman"; station = bhaktiworld-name "Hanuman"; }
{ logo = bhaktiworld-logo; stream = bhaktiworld "djbeat"; station = bhaktiworld-name "Mantra Shakti"; }
{ logo = bhaktiworld-logo; stream = bhaktiworld "gurbani"; station = bhaktiworld-name "Sangam"; }
{ logo = bhaktiworld-logo; stream = bhaktiworld "hot"; station = bhaktiworld-name "Shiv"; }
{ logo = bhaktiworld-logo; stream = bhaktiworld "ibadat"; station = bhaktiworld-name "Devi Maa"; }
{ logo = bhaktiworld-logo; stream = bhaktiworld "iskon2b"; station = bhaktiworld-name "Om Sai"; }
{ logo = bhaktiworld-logo; stream = bhaktiworld "millenniumhits"; station = bhaktiworld-name "Krishna"; }
{ logo = bhaktiworld-logo; stream = bhaktiworld "dard"; station = bhaktiworld-name "Shri Ram"; }
{ logo = bhaktiworld-logo; stream = bhaktiworld "bhaktiworldindia"; station = bhaktiworld-name "Ganesh"; }
{ stream = bhaktiworld "2bhanuman"; station = bhaktiworld-name "Hanuman"; }
{ stream = bhaktiworld "djbeat"; station = bhaktiworld-name "Mantra Shakti"; }
{ stream = bhaktiworld "gurbani"; station = bhaktiworld-name "Sangam"; }
{ stream = bhaktiworld "hot"; station = bhaktiworld-name "Shiv"; }
{ stream = bhaktiworld "ibadat"; station = bhaktiworld-name "Devi Maa"; }
{ stream = bhaktiworld "iskon2b"; station = bhaktiworld-name "Om Sai"; }
{ stream = bhaktiworld "millenniumhits"; station = bhaktiworld-name "Krishna"; }
{ stream = bhaktiworld "dard"; station = bhaktiworld-name "Shri Ram"; }
{ stream = bhaktiworld "bhaktiworldindia"; station = bhaktiworld-name "Ganesh"; }
{
station = "Rockabilly Radio";
stream = "http://lin3.ash.fast-serv.com:6026/stream_96";

View File

@@ -14,7 +14,7 @@ in
./moodle-dl-borsfaye.nix
./names.nix
./nextcloud.nix
./radio
./radio.nix
./retiolum-map.nix
./tarot.nix
./urlwatch.nix

View File

@@ -1,5 +1,7 @@
{ lib, pkgs, config, ... }:
let
inherit (import <niveum/lib>) tmpfilesConfig;
liquidsoapDirectory = "/var/cache/liquidsoap";
icecastPassword = "hackme";
lyrikline-poem = pkgs.writers.writeDash "lyrikline.sh" ''
set -efu
@@ -21,7 +23,7 @@ let
author="$(${pkgs.htmlq}/bin/htmlq -f "$html" --text '#gedicht-autor')"
title="$(${pkgs.htmlq}/bin/htmlq -f "$html" --text .gedicht-originaltitel)"
echo "annotate:title=\"$title\",album=\"$poem_url\",artist=\"$author\":$poem_file"
echo "annotate:title=\"$title | $poem_url\",artist=\"$author\":$poem_file"
'';
stavenhagen-poem = pkgs.writers.writeDash "stavenhagen.sh" ''
base=https://www.deutschelyrik.de
@@ -36,50 +38,87 @@ let
${pkgs.curl}/bin/curl -sSL "$base/$poem" > "$html"
printf "annotate:title=\"%s\",album=\"%s\",artist=\"%s\":$base/%s\n" \
printf "annotate:title=\"%s | %s\",artist=\"%s\":$base/%s\n" \
"$(${pkgs.htmlq}/bin/htmlq --text '.ce_text h1' -f "$html")" \
"$base/$poem" \
"$(${pkgs.htmlq}/bin/htmlq --text 'h1 + p em' -f "$html")" \
"$(${pkgs.htmlq}/bin/htmlq 'audio source' --attribute src -f "$html")"
'';
wikipedia-article = pkgs.writers.writeDash "wikipedia.sh" ''
set -efu
opus=$(mktemp ${liquidsoapDirectory}/wikipedia.XXX.opus)
html=$(mktemp)
trap clean EXIT
clean() {
rm "$html"
}
${pkgs.curl}/bin/curl -sSL https://de.wikipedia.org/wiki/Spezial:Zuf%C3%A4llige_Seite > "$html"
${pkgs.htmlq}/bin/htmlq '.mw-parser-output p' --text -f "$html" \
| ${pkgs.gnused}/bin/sed 's/\[[0-9]\+]//g' \
| ${pkgs.espeak}/bin/espeak -v german-mbrola-6 -w /dev/stdout \
| ${pkgs.opusTools}/bin/opusenc --quiet - "$opus"
printf "annotate:title=\"%s\":%s" \
"$(${pkgs.htmlq}/bin/htmlq -f "$html" --text h1)" \
"$opus"
'';
in {
# https://github.com/savonet/liquidsoap/issues/1043#issuecomment-593354427
services.liquidsoap.streams.radio = pkgs.writeText "lyrikline.liq" ''
set("protocol.external.curl","${pkgs.curl}/bin/curl")
def random_lyrikline() =
uri = list.hd(default="", get_process_lines("${lyrikline-poem}"))
request.create(uri, persistent=true)
def random_url(script) =
mksafe(audio_to_stereo(request.dynamic.list(
fun () -> list.map(request.create, get_process_lines(script))
)))
end
def random_stavenhagen() =
uri = list.hd(default="", get_process_lines("${stavenhagen-poem}"))
request.create(uri, persistent=true)
end
lyrikline = mksafe(audio_to_stereo(request.dynamic(random_lyrikline)))
output.icecast(
mount = '/lyrikline.ogg',
port = ${toString config.services.icecast.listen.port},
password = "${icecastPassword}",
description = "lyrikline. listen to the poet (unofficial)",
%vorbis(quality = 1),
lyrikline
%vorbis,
random_url("${lyrikline-poem}")
)
stavenhagen = mksafe(audio_to_stereo(request.dynamic(random_stavenhagen)))
output.icecast(
mount = '/lyrik.ogg',
port = ${toString config.services.icecast.listen.port},
password = "${icecastPassword}",
description = "Lyrik für alle Neue Lust auf Lyrik | www.deutschelyrik.de",
%vorbis(quality = 1),
stavenhagen
%vorbis,
random_url("${stavenhagen-poem}")
)
output.icecast(
mount = '/wikipedia.ogg',
port = ${toString config.services.icecast.listen.port},
password = "${icecastPassword}",
description = "Zufällige Artikel von Wikipedia",
genre = "useless knowledge",
%vorbis,
random_url("${wikipedia-article}")
)
'';
systemd.services.radio.environment.TMPDIR = liquidsoapDirectory;
systemd.tmpfiles.rules = [
(tmpfilesConfig {
type = "d";
path = liquidsoapDirectory;
mode = "0750";
user = "liquidsoap";
group = "liquidsoap";
age = "1h";
})
];
services.icecast = {
enable = true;
hostname = "radio.kmein.de";
@@ -87,7 +126,7 @@ in {
listen.port = 6457;
extraConf = ''
<authentication>
<source-password>${icecastPassword}</source-password>
<source-password>${icecastPassword}</source-password>
</authentication>
'';
};

View File

@@ -1,43 +0,0 @@
{ pkgs, lib, stations }:
let
theStations = lib.mapAttrsToList (name: value: value // {name = name;}) stations;
in
pkgs.writeText "index.html" ''
<!doctype html>
<html>
<head>
<title>radio.kierán</title>
<link
rel="stylesheet"
href="//cdn.rawgit.com/necolas/normalize.css/master/normalize.css"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.2/css/bulma.min.css"
/>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta charset="utf-8" />
</head>
<body>
<main class="section">
<div class="subtitle is-3">Welcome to</div>
<h1 class="title is-1">radio.kierán</h1>
<div class="columns is-multiline">
${lib.concatMapStringsSep "\n" (station: ''
<div class="column">
<div class="box">
<strong class="is-uppercase">${station.name}</strong>
(<a href="/${station.name}/status">status</a>, <a href="/${station.name}/listen.ogg">link</a>)
<p class="has-text-grey">${station.description}</p>
<hr/>
<audio style="width:100%" controls src="/${station.name}/listen.ogg"/>
</div>
</div>'') theStations
}
</div>
</main>
</body>
</html>
''