summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2019-04-24 23:10:57 -0400
committerAndrew Cady <d@jerkface.net>2019-04-24 23:10:57 -0400
commit6b4a6ffbce738d56a7c91328342cbb51c1c50cfc (patch)
tree5cebb5a25dfee962460bf9adcf2a101e477b59fc
parente3bc2356f2cdc91862ed703b41497f56da19fa02 (diff)
update musopen to new web API
-rwxr-xr-x[-rw-r--r--]dot/local/bin/musopen24
1 files changed, 14 insertions, 10 deletions
diff --git a/dot/local/bin/musopen b/dot/local/bin/musopen
index 9f3f253..3ed9962 100644..100755
--- a/dot/local/bin/musopen
+++ b/dot/local/bin/musopen
@@ -1,16 +1,20 @@
1#!/bin/sh 1#!/bin/sh
2 2
3CAPTURE= 3URL=https://radio.musopen.org/v1/pieces/get_current/streamvbr0
4JSON=$(curl -s https://musopen.org/radio/next/) 4JSON=$(curl -s "$URL")
5URL_FMT='https://live.musopen.org/music/vbr0/%s'
5 6
6for v in url piece piece_url; do 7j() {
7 eval $v='$(printf %s "$JSON" | jq -r .'$v')' 8 printf %s "$JSON" | jq -r "$@"
8done 9}
9 10
10printf '%s (%s)\n' "$piece" "$piece_url" 11filename=$(j .filename)
11filename=${piece_url%/}.mp3 12composer=$(j .composer.full_name)
12filename=${filename##*/} 13title=$(j .title)
13 14
14[ "$CAPTURE" ] || filename= 15STREAM_URL=$(printf "$URL_FMT" "$filename")
15 16
16exec mpv "$url" ${filename+ --stream-capture="$filename"} 17CAPTURE_NAME=
18[ "$CAPTURE" ] && CAPTURE_NAME="$composer - $title.${filename##*.}"
19
20exec mpv "$STREAM_URL" ${CAPTURE_NAME+ --stream-capture="$CAPTURE_NAME"}