summaryrefslogtreecommitdiff
path: root/dot/local/bin/musopen
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2019-08-19 15:09:50 -0400
committerAndrew Cady <d@jerkface.net>2019-08-19 15:09:50 -0400
commit4ca7908c5713cf1cdd142efd54b04c08ff8b9c7b (patch)
tree066acf38649549c6bef3c8abd4554dfcb5390917 /dot/local/bin/musopen
parent0d75f1a3e3b64e73b5d3d4bd8618abba5f534a96 (diff)
various changes
Diffstat (limited to 'dot/local/bin/musopen')
-rwxr-xr-xdot/local/bin/musopen34
1 files changed, 31 insertions, 3 deletions
diff --git a/dot/local/bin/musopen b/dot/local/bin/musopen
index 3ed9962..7d007fb 100755
--- a/dot/local/bin/musopen
+++ b/dot/local/bin/musopen
@@ -1,5 +1,26 @@
1#!/bin/sh 1#!/bin/sh
2 2
3usage()
4{
5 cat <<EOF
6Usage: $0 [-h|--help] [-n|--no-save] [-s|--save]
7EOF
8}
9
10DO_SAVE=y
11
12eval set -- "$(getopt -o 'hsn' --long '-help,-save,-no-save' -n 'musopen' -- "$@")" || exit 1
13while true; do
14 case "$1" in
15 -h|--help) usage; exit ;;
16 -s|--save) DO_SAVE=y ;;
17 -n|--no-save) DO_SAVE= ;;
18 --) shift; break ;;
19 *) usage; exit 1 ;;
20 esac
21 shift
22done
23
3URL=https://radio.musopen.org/v1/pieces/get_current/streamvbr0 24URL=https://radio.musopen.org/v1/pieces/get_current/streamvbr0
4JSON=$(curl -s "$URL") 25JSON=$(curl -s "$URL")
5URL_FMT='https://live.musopen.org/music/vbr0/%s' 26URL_FMT='https://live.musopen.org/music/vbr0/%s'
@@ -14,7 +35,14 @@ title=$(j .title)
14 35
15STREAM_URL=$(printf "$URL_FMT" "$filename") 36STREAM_URL=$(printf "$URL_FMT" "$filename")
16 37
17CAPTURE_NAME= 38CAPTURE_NAME="$composer - $title.${filename##*.}"
18[ "$CAPTURE" ] && CAPTURE_NAME="$composer - $title.${filename##*.}" 39
40if [ "$DO_SAVE" -a -e "$CAPTURE_NAME" ]; then
41 echo "Warning: not saving: file exists: $CAPTURE_NAME" >&2
42 DO_SAVE=
43else
44 printf '%s: %s - %s\n' "${DO_SAVE+Saving}${DO_SAVE-Playing}" "$composer" "$title" >&2
45fi
46
19 47
20exec mpv "$STREAM_URL" ${CAPTURE_NAME+ --stream-capture="$CAPTURE_NAME"} 48exec mpv "$STREAM_URL" ${DO_SAVE+ --stream-capture="$CAPTURE_NAME"}