forked from doctorfree/RoonCommandLine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_playlists
executable file
·52 lines (41 loc) · 1.11 KB
/
list_playlists
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/bash
#
# shellcheck disable=SC1090,SC2220
ROON=/usr/local/Roon
ROONAPI=${ROON}/api
ROONETC=${ROON}/etc
ROONCONF=${ROONETC}/pyroonconf
LIST=list_playlists.py
PLAYLIST=
EXPLAYLIST=
[ -d ${ROONAPI} ] || exit 1
cd ${ROONAPI} || exit 1
[ -f $LIST ] || exit 2
[ "$1" ] && PLAYLIST="$1"
[ "$2" ] && EXPLAYLIST="$2"
# Use a Python virtual environment
[ -f ${ROON}/venv/bin/activate ] && source ${ROON}/venv/bin/activate
[[ ":$PATH:" == *":/usr/local/Roon/venv/bin:"* ]] || {
export PATH=/usr/local/Roon/venv/bin:${PATH}
}
# Get the zone if it is set
if [ -f ${ROONCONF} ]
then
. ${ROONCONF}
else
DEFZONE=$(grep ^DefaultZone ${ROONETC}/roon_api.ini | awk -F '=' ' { print $2 } ')
${ROON}/bin/set_zone "${DEFZONE}"
. ${ROONCONF}
fi
# If no playlist search term is provided then list all
[ "${PLAYLIST}" ] || PLAYLIST="__all__"
# Construct the exclusion args if passed
EXARGS=
[ "${EXPLAYLIST}" ] && EXARGS="-x ${EXPLAYLIST}"
have_python3=$(type -p python3)
if [ "${have_python3}" ]
then
python3 $LIST -p "$PLAYLIST" -z "$ROON_ZONE" $EXARGS
else
python $LIST -p "$PLAYLIST" -z "$ROON_ZONE" $EXARGS
fi