local-bin/common/whatmusic

19 lines
432 B
Text
Raw Normal View History

#!/bin/sh
2023-03-11 22:14:15 +02:00
if [[ ! $1 ]]; then
user="siinamonster"
else
user="$1"
fi
2023-03-11 22:14:15 +02:00
api_url="https://api.listenbrainz.org/1/user/$user/playing-now"
2023-03-11 22:14:15 +02:00
data=$(curl -s $api_url | jq -r '.payload.listens[0].track_metadata')
artist=$(echo "$data" | jq '.artist_name' | tr -d '"')
track=$(echo "$data" | jq '.track_name' | tr -d '"')
if [[ "$artist" != "null" ]]; then
echo "$artist" - "$track"
else
echo "Not listening to anything right now."
fi