Skip to content

Instantly share code, notes, and snippets.

@sfate
Created June 11, 2011 18:54
Show Gist options
  • Save sfate/1020842 to your computer and use it in GitHub Desktop.
Save sfate/1020842 to your computer and use it in GitHub Desktop.
Mocp onnextsong script
#!/bin/bash
# by Sfate
# $1 artist
# $2 album
# $3 filename
# $4 title
# $5 track
# $6 file duration in XX:YY form
# $7 file duration, number of seconds
#get album cover from last.fm
api_key='b25b959554ed76058ac220b7b2e0a026'
artist="`echo "$1" | sed -e 's/ /+/g'`"
album="`echo "$2" | sed -e 's/ /+/g'`"
cover="/var/spool/lastfm/cover.gif"
album_url="http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=$api_key&artist=$artist&album=$album"
cover_url=`wget -qO- $album_url | cat | sed -n -e 's/<image size=\"large\">//p' | sed -n -e 's/<\/image>//p'`
wget -q --output-document=$cover $cover_url
#display osd-notify about track with cover ^_^
if [ ! -f $cover ]
then
cover_url="http://cdn.last.fm/depth/catalogue/noimage/cover_med.gif"
wget -q --output-document=$cover $cover_url
fi
/usr/bin/notify-send "$1 - $4 [$6]" "$2" -i $cover
#submit track to last.fm
/usr/lib/lastfmsubmitd/lastfmsubmit --artist "$1" --title "$4" --length "$6" --album "$2"
@sfate
Copy link
Author

sfate commented Jun 11, 2011

add next to ~/.moc/config

OnSongChange = "/path/to/script/onsongchange.sh %a %r %f %t %n %d %D"

and enjoy =_)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment