From db8c06364fcc0da611d5b928203094b9320a6301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Tue, 8 Feb 2022 19:21:03 +0100 Subject: [PATCH] feat: wikipedia radio --- lib/streams.nix | 24 +++++--- systems/makanek/configuration.nix | 2 +- .../makanek/{radio/default.nix => radio.nix} | 61 +++++++++++++------ systems/makanek/radio/station-list.nix | 43 ------------- 4 files changed, 58 insertions(+), 72 deletions(-) rename systems/makanek/{radio/default.nix => radio.nix} (64%) delete mode 100644 systems/makanek/radio/station-list.nix diff --git a/lib/streams.nix b/lib/streams.nix index cf4aa24..be37c88 100644 --- a/lib/streams.nix +++ b/lib/streams.nix @@ -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"; diff --git a/systems/makanek/configuration.nix b/systems/makanek/configuration.nix index f3a7084..bcc07c6 100644 --- a/systems/makanek/configuration.nix +++ b/systems/makanek/configuration.nix @@ -14,7 +14,7 @@ in ./moodle-dl-borsfaye.nix ./names.nix ./nextcloud.nix - ./radio + ./radio.nix ./retiolum-map.nix ./tarot.nix ./urlwatch.nix diff --git a/systems/makanek/radio/default.nix b/systems/makanek/radio.nix similarity index 64% rename from systems/makanek/radio/default.nix rename to systems/makanek/radio.nix index b4e4896..4b0dfca 100644 --- a/systems/makanek/radio/default.nix +++ b/systems/makanek/radio.nix @@ -21,7 +21,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,47 +36,70 @@ 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 /tmp/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}") ) ''; @@ -87,7 +110,7 @@ in { listen.port = 6457; extraConf = '' - ${icecastPassword} + ${icecastPassword} ''; }; diff --git a/systems/makanek/radio/station-list.nix b/systems/makanek/radio/station-list.nix deleted file mode 100644 index f55b9ce..0000000 --- a/systems/makanek/radio/station-list.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ pkgs, lib, stations }: -let - theStations = lib.mapAttrsToList (name: value: value // {name = name;}) stations; -in -pkgs.writeText "index.html" '' - - - - radio.kierán - - - - - - -
-
Welcome to
-

radio.kierán

- -
- ${lib.concatMapStringsSep "\n" (station: '' -
-
- ${station.name} - (status, link) - -

${station.description}

-
-
-
'') theStations - } -
-
- - -''