Last.fm Player for la fonera - The Scripts

Here are the Scripts for the lastfm player implementation on the fonera2.0 I use right now.
Even the fonosfera dev-blog took notice from my project… now its up to me to make it run without much hacking.

Bluetooth does not yet work but I’ll work on it.

Artist/Song info (fminfo) does not yet work very well, let me know if you have an idea about how to synchronize it.

If you have made some advances in getting bluetooth / anyremote to work, please leave a comment.
you need to create a file “.bashfm as well which contains your username and your password like this:

# /media/lastfm/.bashfm
username=my_username
password=my_secret_one

fmstart:
#!/usr/bin/bash
# /media/lastfm/fmstart
# source http://mpd.wikia.com/wiki/Hack:bashfm
# some chages by http://www.vollkornpapier.de
# "fmstart" starts playing last.fm radio. "fmstart"
# should be used before any other bashfm commands are
# given. It obtains the username, password, and
# mediaplayer from the ".bashfm" file. If the password
# present in the file as plain text, it will be md5
# encoded and the plain text version will be removed.
# It then logs in into Last.fm, obtains the audio
# stream URL, and launches the media player. "fmstart"
# takes no command arguments.

username=`cat ~/.bashfm | grep "^username="`
username=`expr "$username" : 'username=\(.*\)'`

password=`cat ~/.bashfm | grep "^password="`
password=`expr "$password" : 'password=\(.*\)'`
password=`echo -n "$password" | sed -e 's/[ ]*$//’`

mediaplayer=`cat ~/.bashfm | grep “^mediaplayer=”`
mediaplayer=`expr “$mediaplayer” : ‘mediaplayer=\(.*\)’`
mediaplayer=`echo -n “$mediaplayer” | tr ‘\’ ‘/’`

if [ ! -z "$password" ]
then
passwordmd5=`echo -n $password | md5sum`
passwordmd5=`expr “$passwordmd5″ : ‘\([0-9A-Fa-f]*\)\.*’`
else
passwordmd5=`cat ~/.bashfm | grep “^passwordmd5=”`
passwordmd5=`expr “$passwordmd5″ : ‘passwordmd5=\(.*\)’`
fi

echo ‘username=’$username > ~/.bashfm
echo ‘password=’ >> ~/.bashfm
echo ‘mediaplayer=’”$mediaplayer” >> ~/.bashfm

echo ‘passwordmd5=’$passwordmd5 >> ~/.bashfm

login_url=’http://ws.audioscrobbler.com/radio/handshake.php?’
login_url=”$login_url”‘version=1.1.1&platform=linux&username=’
login_url=”$login_url”$username’&passwordmd5=’$passwordmd5
login_url=”$login_url”‘&debug=0&partner=’

echo “login_url=$login_url” >> ~/.bashfm

# lynx -source “$login_url” >> ~/.bashfm
wget -O ~/.bashfm “$login_url”
echo >> ~/.bashfm

stream_url=`cat ~/.bashfm | grep “^stream_url=”`
stream_url=`expr “$stream_url” : ’stream_url=\(.*\)’`

# mpc add “$stream_url” &
echo
echo
#echo “$stream_url”
wget -O - “$stream_url” | madplay -

fmart:

#!/usr/bin/bash
# /media/lastfm/fmart
# "fmart" plays the radio station corresponding to a
# certain artist. It takes the artist's name as command
# line argument. Use quotes when the artist's name
# contains spaces.
#
# Example:
# fmart 'jack johnson'

artist=`echo $1 | sed 's/ /%20/g'`

session=`cat ~/.bashfm | grep "^session="`
session=`expr "$session" : 'session=\(.*\)'`

tuning_url='http://ws.audioscrobbler.com/radio/adjust.php?'
tuning_url="$tuning_url"'session='$session'&url=lastfm://artist/'
tuning_url="$tuning_url"$artist'/similarartists&debug=0'

wget -O _station "$tuning_url" > /dev/null

fmtag:

#!/usr/bin/bash
# /media/lastfm/fmtag
# "fmtag" plays the music corresponding to the tag given
# as command argument. The tag needs to be quoted when
# it contains spaces.
#
# Example:
# fmtag 'rock'

tag=`echo $1 | sed 's/ /%20/g'`

session=`cat ~/.bashfm | grep "^session="`
session=`expr "$session" : 'session=\(.*\)'`

tuning_url='http://ws.audioscrobbler.com/radio/adjust.php?'
tuning_url="$tuning_url"'session='$session'&url=lastfm://'
tuning_url="$tuning_url"'globaltags/'$tag'&debug=0'

#lynx -source "$tuning_url" > /dev/null
wget -O _tagfile "$tuning_url"
#mpc stop ; mpc play

fminfo:

#!/usr/bin/bash
# /media/lastfm/fminfo
# "fminfo" returns the name of the artist, name
# of the song and name of the album of the music
# that is currently playing. "fminfo" takes no
# command line arguments.

session=`cat ~/.bashfm | grep "^session="`
session=`expr "$session" : 'session=\(.*\)'`

info_url='http://ws.audioscrobbler.com/radio/np.php?'
info_url="$info_url"'session='$session'&debug=0'

wget -O _fminfo "$info_url"
#wget $info_url -O test

Schlagworte: , , , ,

Kommentieren