Technology
 

Hack:LastFMProxy

From Music Player Daemon Community Wiki

LastFMProxy helps playing last.fm streams in MPD.

[edit] Guide

1. Install Python, install and configure MPD, install mpc(optional)

2. Download lastfmproxy

3. Unpack it to /usr/local/bin/lastfmproxy

4. edit /usr/local/bin/lastfmproxy/config.py username and password are enought

5. make file /etc/init.d/lastfmproxy:

#!/bin/sh
PATH=/usr/local/bin:/usr/bin
case "$1" in
 start)
       if ! pgrep -f "lastfmproxy/main.py" > /dev/null; then
               /usr/local/bin/lastfmproxy/main.py 1,2>/dev/null &
               echo "LastFM proxy started"
       else
               echo "LastFMProxy already running" >&2
               exit 1
       fi
       ;;
 stop)
       if pkill -f "lastfmproxy/main.py"; then
               echo "LastFMProxy stopped"
       else
               echo "No LastFMProxy running" >&2
               exit 1
       fi
       ;;
 restart)
       $0 stop
       $0 start
       ;;
 *)
       N=$0
       echo "Usage: $N {start|stop|restart}" >&2
       exit 1
       ;;
esac
exit 0

6. add lastfmproxy to runlevels 2-5 (for example with help of sysv-rc-conf)

7. run lastfmproxy:

/etc/init.d/lastfmproxy start

8. You can now find interesting page with your browser "http://localhost:1881/"

9. If you have mpc installed then find file m3u-handler.sh and use it to add radio streams to mpd

/path_to_file/m3u-handler.sh "url"

You may need to make it executable:

chmod +x /path_to_file/m3u-handler.sh

Or you can just use

mpc add "url"
mpc play

10. Some usefull urls for proxy:

http://localhost:1881/user/username/recommended.mp3

http://localhost:1881/user/username/personal.mp3

http://localhost:1881/globaltags/tag.mp3

Only one stream can be played at time

11. Usefull info: Read /usr/local/bin/lastfmproxy/README.txt because you can find there how to change your firefox settings for changing station on proxy while choosing them on last.fm site