-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkexp
executable file
·62 lines (47 loc) · 1.48 KB
/
kexp
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
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
stream="mplayer -quiet http://live-aacplus-64.kexp.org/kexp64.aac"
case "$1" in
start)
eval $stream &>/var/tmp/mplayer.log &disown
;;
stop)
eval "pkill mplayer"
exit 0
;;
np)
json="$(curl -s "https://legacy-api.kexp.org/play/?format=json")"
if [ "$(echo $json | grep "502 Bad Gateway")" != "" ] ; then
printf "now playing:\n\n ¯\_(ツ)_/¯\n\n Bad Gateway Error \n\n"
exit 0
fi
playtype="$(echo $json | jq '.results[0].playtype.playtypeid')"
case $playtype in
4)
printf "now playing:\n\n Air Break \n\n";;
1)
artist=$(echo $json | jq -r '.results[0].artist.name')
track=$(echo $json | jq '.results[0].track.name')
album=$(echo $json | jq '.results[0].release.name')
year=$(echo $json | jq '.results[0].releaseevent.year')
comments=$(echo $json | jq -r '.results[0].comments')
comment=$(echo $json | jq -r '.results[0].comments[0].text')
np="now playing:\n\n"
if [[ -n "$track" ]]; then
np="$np $track"
if [[ -n "$artist" ]]; then
np="$np, by $artist on $album ($year)";
if [[ ${#comments[@]} -eq 0 ]]; then
np="$np\n\n $comment\n\n";
else
np="$np\n\n";
fi
fi
else
np="¯\_(ツ)_/¯\n";
fi
printf "$np"
;;
*) printf "now playing:\n\n ¯\_(ツ)_/¯\n $json \n\n";;
esac
;;
esac