Created
June 11, 2011 18:54
-
-
Save sfate/1020842 to your computer and use it in GitHub Desktop.
Mocp onnextsong script
This file contains hidden or 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 | |
# 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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
add next to ~/.moc/config
and enjoy =_)