blob: 478c9acd58872e4664fe0074fc068600ffe169a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/bin/sh
usage()
{
cat <<EOF
Usage: $0 [-h|--help] [-n|--no-save] [-s|--save]
EOF
}
DO_SAVE=y
eval set -- "$(getopt -o 'hsn' --long '-help,-save,-no-save' -n 'musopen' -- "$@")" || exit 1
while true; do
case "$1" in
-h|--help) usage; exit ;;
-s|--save) DO_SAVE=y ;;
-n|--no-save) DO_SAVE= ;;
--) shift; break ;;
*) usage; exit 1 ;;
esac
shift
done
STREAM_URL=https://live.musopen.org:8085/streamvbr0?$(date +%s000)
exec mpv "$STREAM_URL"
exit 1
JSON=$(curl -s "$URL")
URL_FMT='https://live.musopen.org/music/vbr0/%s'
j() {
printf %s "$JSON" | jq -r "$@"
}
filename=$(j .filename)
composer=$(j .composer.full_name)
title=$(j .title)
STREAM_URL=$(printf "$URL_FMT" "$filename")
CAPTURE_NAME="$composer - $title.${filename##*.}"
if [ "$DO_SAVE" -a -e "$CAPTURE_NAME" ]; then
echo "Warning: not saving: file exists: $CAPTURE_NAME" >&2
DO_SAVE=
else
printf '%s: %s - %s\n' "${DO_SAVE+Saving}${DO_SAVE-Playing}" "$composer" "$title" >&2
fi
exec mpv "$STREAM_URL" ${DO_SAVE+ --stream-capture="$CAPTURE_NAME"}
|