Skip to content

Instantly share code, notes, and snippets.

@raidzero
Created March 5, 2014 23:28
Show Gist options
  • Save raidzero/9378962 to your computer and use it in GitHub Desktop.
Save raidzero/9378962 to your computer and use it in GitHub Desktop.
pull lyrics from audacious playing track from lyrics.wikia.com
#!/bin/sh
# the regexes may need some work as song names and stuff get weirder :)
if [ -z "`ps -ef | grep audacious | grep -v grep`" ]; then
return # dont do anything if audacious isnt running
fi
clear
METADATA=`qdbus org.mpris.audacious /Player org.freedesktop.MediaPlayer.GetMetadata` # use dbus to read track data
# seds: trim leading space, spaces to underscores, capitalize first letter of each word in string (\x27 = ')
ARTIST=`echo "$METADATA" | grep "^artist:" | cut -d ':' -f2- | sed 's/^ *//' | sed 's/ /_/g' | sed 's/\([a-z]\)\([a-zA-Z0-9\x27)(]*\)/\u\1\2/g'`
SONG=`echo "$METADATA" | grep "^title:" | cut -d ':' -f2- | sed 's/^ *//' | sed 's/ /_/g' | sed 's/\([a-z]\)\([a-zA-Z0-9\x27)(]*\)/\u\1\2/g'`
echo "$ARTIST:$SONG: http://lyrics.wikia.com/$ARTIST:$SONG?action=edit"
# print lyrics
curl --silent "http://lyrics.wikia.com/$ARTIST:$SONG?action=edit" | awk '/lyrics>/,/\/lyrics>/' | sed '1d;$d'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment