grab what current song is playing

This commit is contained in:
Siina Mashek 2023-03-11 22:14:15 +02:00
parent a6ebcf95f0
commit 2e56222e29

View File

@ -1,10 +1,15 @@
#!/bin/sh
api_url="https://api.listenbrainz.org/1/user/$1/playing-now"
if [[ ! $1 ]]; then
user="siinamonster"
else
user="$1"
fi
if [[ ! $1 ]]; then 1="siinamonster"; fi
api_url="https://api.listenbrainz.org/1/user/$user/playing-now"
read artist track < <(echo $(curl -s $api_url | \
jq -r '.payload.listens[0].track_metadata | .artist_name, .track_name'))
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"