-
-
Save richleland/1018977 to your computer and use it in GitHub Desktop.
An example eventcmd script for posting pianobar events to Last.fm with Scrobbular.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# create variables | |
while read L; do | |
k="`echo "$L" | cut -d '=' -f 1`" | |
v="`echo "$L" | cut -d '=' -f 2`" | |
export "$k=$v" | |
done < <(grep -e '^\(title\|artist\|album\|stationName\|pRet\|pRetStr\|wRet\|wRetStr\|songDuration\|songPlayed\|rating\)=' /dev/stdin) # don't overwrite $1... | |
username='<YOUR GOOGLE USERNAME>'; | |
secret='<YOUR SCROBBULAR SECRET>'; | |
case "$1" in | |
songfinish) | |
# scrobble if 75% of the song has been played but only if the song hasn't been banned | |
if [ -n "$songDuration" ] && | |
[ $(echo "scale=4; ($songPlayed/$songDuration*100)>50" | bc) -eq 1 ] && | |
[ "$rating" -ne 2 ]; then | |
curl -X POST --data-urlencode "username=$username" \ | |
--data-urlencode "s=$secret" \ | |
--data-urlencode "track=$title" \ | |
--data-urlencode "artist=$artist" \ | |
--data-urlencode "duration=$((songDuration/1000))" \ | |
--data-urlencode "album=$album" \ | |
http://scrobbular.appspot.com/scrobble | |
fi; | |
;; | |
songstart) | |
curl -X POST --data-urlencode "username=$username" \ | |
--data-urlencode "s=$secret" \ | |
--data-urlencode "track=$title" \ | |
--data-urlencode "artist=$artist" \ | |
--data-urlencode "album=$album" \ | |
http://scrobbular.appspot.com/now_playing | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You also need to
chmod +x
the eventcmd file and add the following to your~/.config/pianobar/config file
:event_command = /Users/rleland/.config/pianobar/eventcmd