commit 84f9798fa2a6c7597ffd44c9ea4e21a07d9ba865
parent 85987e819a85fa20b3aa6366dae7a27df624ee8a
Author: Claudio Alessi <smoppy@gmail.com>
Date: Thu, 25 May 2017 21:13:05 +0200
Prevent error with empty/non-existing playlists.
Diffstat:
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/iwpick b/src/iwpick
@@ -23,7 +23,6 @@ connect() {
fi
sdhcp -d $iface >/dev/null &
-
while [ -z "$gw" ]; do
pkt="$(tcpdump -vlni $iface -c 1 -Q in udp 2>&1)"
addr="$(echo "$pkt" |grep "Your-IP" |tr -d [:space:] |cut -b8-)"
diff --git a/src/moin b/src/moin
@@ -18,6 +18,7 @@ ytplrand() {
maxres=50
data="$(ytapi "$apikey" "playlists" "id=$listid")"
nitems="$(echo "$data" |grep itemCount |cut -d: -f2)"
+ [ -z "$nitems" ] && return
choose="$(shuf -i 1-"$nitems" -n1)"
page="$(echo "1 + ($choose - 1) / $maxres" |bc)"
item="$(echo "$choose - (($page-1) * $maxres)" |bc)"
@@ -39,11 +40,11 @@ main() {
echo "Usage: "$(basename "$0")" <API key> <playlist ID>"
exit 1
fi
-
pgrep -a "$PLAYER" >/dev/null && exit 1
rv=1
while [ $rv -ne 0 ]; do
songid="$(ytplrand "$apikey" "$listid")"
+ [ -z "$songid" ] && echo "$(basename "$0"): no song ID found" && break
"$PLAYER" $PLAYER_OPTS "$VIDURI/$songid"
#rv=$?
rv=0