local-bin/common/whatmusic

19 lines
451 B
Plaintext
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
2024-04-22 06:06:10 +03:00
echo "Currently playing: $artist" - "$track"
else
echo "Not listening to anything right now."
fi