commit 2b742bd2cdbefafe29ebd35ba0c1e4b22c593916
parent 5da941e03d21b9b249ece538bffff522e140d2c3
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Fri, 28 Feb 2020 11:14:25 +0100
Add general tsvplumb script and use it for radio
Diffstat:
4 files changed, 35 insertions(+), 55 deletions(-)
diff --git a/.local/bin/plumb b/.local/bin/plumb
@@ -90,8 +90,10 @@ handle_target() {
t="$(printf '%s' "$t" | sed 's/.*scholar_url?url\=//;s/&hl\=.*//')";;
esac
- if regeximatch "$t" '\.(mp4|mkv|webm|avi|ogg|ogv|gifv)$'; then
+ if regeximatch "$t" '\.(mp4|mkv|webm|avi|ogv|gifv)$'; then
detach mpv "$(fetch "$t")"
+ elif regeximatch "$t" '\.(mp3|ogg)$'; then
+ mpv "$(fetch "$t")"
elif regeximatch "$t" '\.(png|jpg|jpeg|tif|bmp|gif)$'; then
sxiv "$(fetch "$t")"
elif regeximatch "$t" '\.(pdf|ps|epub|djvu)$'; then
diff --git a/.local/bin/radio b/.local/bin/radio
@@ -1,55 +1,2 @@
#!/bin/sh
-# requirements: dmenu, fzy, mpv
-
-n="bitreich
-2f30 blue
-2f30 red
-DR P1
-DR P2
-DR P3
-DR P4 Østjylland
-DR P5 Østjylland
-DR P6 Beat
-DR P8 Jazz
-WBGO"
-
-lines=10
-prompt="station: "
-if [ -z "$TERM" ]; then
- t="$(printf '%s' "$n" | dmenu -i -l "$lines" -p "$prompt")"
-else
- t="$(printf '%s' "$n" | fzy -l "$lines" -p "$prompt")"
-fi
-if [ -z "$t" ]; then
- exit 1
-fi
-
-case "$t" in
- bitreich)
- u="http://bitreich.org:3232/live";;
- "2f30 blue")
- u="https://radio.2f30.org:8443/blue.mp3";;
- "2f30 red")
- u="https://radio.2f30.org:8443/red.mp3";;
- "DR P1")
- u="http://live-icy.gss.dr.dk/A/A03H.mp3.m3u";;
- "DR P2")
- u="http://live-icy.gss.dr.dk/A/A04H.mp3.m3u";;
- "DR P3")
- u="http://live-icy.gss.dr.dk/A/A05H.mp3.m3u";;
- "DR P4 Østjylland")
- u="http://live-icy.gss.dr.dk/A/A14H.mp3.m3u";;
- "DR P5 Østjylland")
- u="http://live-icy.gss.dr.dk/A/A24H.mp3.m3u";;
- "DR P6 Beat")
- u="http://live-icy.gss.dr.dk/A/A29H.mp3.m3u";;
- "DR P8 Jazz")
- u="http://live-icy.gss.dr.dk/A/A22H.mp3.m3u";;
- "WBGO")
- u="http://wbgo.streamguys.net/wbgo128";;
- *)
- printf 'unknown station %s\n' "$t"
- exit 2;;
-esac
-
-mpv "$u"
+tsvplumb "$HOME"/.local/share/radio-stations.txt
diff --git a/.local/bin/tsvplumb b/.local/bin/tsvplumb
@@ -0,0 +1,20 @@
+#!/bin/sh
+# requirements: dmenu, fzy
+
+if [ "$#" -lt 1 ]; then
+ tsv="$(cat)"
+else
+ tsv="$(cat "$1")"
+fi
+
+lines=10
+if [ -z "$TERM" ]; then
+ t="$(printf '%s' "$tsv" | dmenu -i -l "$lines")"
+else
+ t="$(printf '%s' "$tsv" | fzy -l "$lines")"
+fi
+if [ -z "$t" ]; then
+ exit 1
+fi
+
+plumb "$(printf '%s' "$t" | cut -f2)"
diff --git a/.local/share/radio-stations.txt b/.local/share/radio-stations.txt
@@ -0,0 +1,11 @@
+bitreich http://bitreich.org:3232/live
+2f30 blue https://radio.2f30.org:8443/blue.mp3
+2f30 red https://radio.2f30.org:8443/red.mp3
+DR P1 http://live-icy.gss.dr.dk/A/A03H.mp3.m3u
+DR P2 http://live-icy.gss.dr.dk/A/A04H.mp3.m3u
+DR P3 http://live-icy.gss.dr.dk/A/A05H.mp3.m3u
+DR P4 Østjylland http://live-icy.gss.dr.dk/A/A14H.mp3.m3u
+DR P5 Østjylland http://live-icy.gss.dr.dk/A/A24H.mp3.m3u
+DR P6 Beat http://live-icy.gss.dr.dk/A/A29H.mp3.m3u
+DR P8 Jazz http://live-icy.gss.dr.dk/A/A22H.mp3.m3u
+WBGO http://wbgo.streamguys.net/wbgo128