-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathstreamradio
More file actions
executable file
·65 lines (59 loc) · 1.47 KB
/
streamradio
File metadata and controls
executable file
·65 lines (59 loc) · 1.47 KB
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
63
64
65
#!/bin/sh
# written by Shotaro Fujimoto (https://github.com/ssh0)
#=#=#=
# ```
# streamradio - remote control script with streamradio
#
# SYNOPSYS
# streamradio start <URL>
# streamradio pause
# streamradio list [stations|current]
# streamradio quit
# streamradio [-h|--help]
# ```
#=#=
cachefile="$HOME/.cache/streamradio/station"
if [ ! -e ${cachefile} ]; then
touch "${cachefile}"
fi
fifofile="$HOME/.cache/streamradio/fifo"
stationfile="$HOME/.pyradio/stations.csv"
defaultstation="http://streaming.radionomy.com/J-PopProjectRadio"
station="$(head -n 1 "${cachefile}")"
f="$0"
usage() {
sed -n '/^#=#=#=/,/^#=#=/p' $f | sed -e '1d;$d' | cut -b3- | grep -v "\`\`\`"
exit 1
}
if [ "$1" = "pause" ]; then
echo "pause" >> "${fifofile}"
elif [ "$1" = "quit" ]; then
echo "quit" >> "${fifofile}"
elif [ "$1" = "start" ]; then
if [ ! "$2" = "" ];then
station="$2"
elif [ "${station}" = "" ]; then
station="${defaultstation}"
fi
echo "${station}" > "${cachefile}"
echo "load ${station}" >> "${fifofile}"
elif [ "$1" = "list" ]; then
if [ "$2" = "stations" ]; then
if hash $PERCOL 2>/dev/null; then
cat ${stationfile} | $PERCOL | awk 'BEGIN {FS=", "; } { print $2; }'
else
cat ${stationfile}
fi
elif [ "$2" = "current" ]; then
cat ${cachefile}
fi
elif [ "$1" = "-h" -o "$1" = "--help" ]; then
usage
elif [ "$1" = "-H" ]; then
usage_all "$0"
exit 0
else
echo "Unknown command: $1"
usage
fi
exit 0