last.fm proxie | A php proxy server
Last.fm proxie is a prototype open source proxy server. It tunes into a specified last.fm station and provides a continuous audio stream for use with your favorite media player.
I developed last.fm proxie out of a need to stream my favorite stations to my home theater through my home network. I wrote the whole thing from scratch! It was fun. Please see below for details.
Update 17/01/10: Scrobbling support as of version 0.2. Check out the download link below!
Update 04/01/10: I’ve successfully implemented scrobbling as well, so that tracks listened through the proxy appear in your profile. Will be rolling out in a few days. Stay tuned for updates. In the meantime you can also join the last.fm proxie group.
Setting up the proxy
Last.fm proxie basics
Last.fm proxie is a proxy server intended for use with last.fm. It tunes into an entered station and provides a continuous stream of audio to your favorite media device.
Authentication Notes
I didn’t write the script to sell it or provide it as a service. So if you want to use it you will have to get your own API key and plug it into the setup file to get it to work. You will need to authenticate the application once (see below for details).
Please note that all keys, session keys, and everything to do with authentication is stored locally on your computer in the same folder you extracted the other php files. If you have security concerns with that data, please take necessary precautions.
Setup Proxie
- Open setup.php and insert your last.fm API key and secret. You can apply and get those from the last.fm API account page. Insert your last.fm username as well (needed for scrobbling).
- Timelimit is the amount of time in seconds to keep streaming. Leave this as is for now.
- Make sure php and apache are running and run auth.php in your browser. You should see a welcome screen and instructions to get the application authorized (step1) and then acquire a session key (step2). Please make sure to complete step 1 first, otherwise step 2 will fail. Step 1 will launch a new window to last.fm. Part of the second step is the creation of a .htaccess file. This forwards requests for lastfm.mp3 to lastfm.php. Depending on the media player you’re using you might need this. Note that if you have a .htaccess file in the same folder it will be overwritten. Extract all files in a new folder and not in the root to avoid problems.
- Once you have finished the previous steps you’ll be forwarded to selectstation.php which you will need to run once to save a default station. Once the station is saved it will be used as the default for streaming. At any time you can visit this page to change the last.fm station you want to tune to. By pressing submit, the script essentially writes a small file called currentstation.php in the same folder that stores the default station.
- Once submitted, you should be all set. You can now request http://localhost/<add path here>/lastfm.mp3 with your favorite media player and music should come out of your speakers.
Notes:
- You should request the URL and not try to open the file
. - On macs you’ll probably need to add you username to localhost.
- The path in step 5 should point to the location of lastfm.php. Remember we’re using the .htaccess to forward requests for lastfm.mp3 to lastfm.php. ie Don’t get confused if you don’t find an mp3 file in the folder. Of course you can always request lastfm.php and that should work with some players (works with winamp).
Bugs
Life isn’t perfect. If you find a repeatable bug, drop me a line at alefbetac [at] ninjalabz [dot] com or leave a comment below and I’ll try to fix it . Feedback is welcome.
Compatibility
Tested on WampServer Version 2.0 for Windows. Works with winamp 5.5x, windows media player 11.x and TVersity media server to route to other devices in home network through DLNA (neat!). To get it to work with Tversity just add the full URL to lastfm.mp3 to the internet radio section in your library.
Downloads
Version 0.2 17/01/2010 – Automatic scrobble support
Prototype version 0.1 03/01/2010
If you found this script useful please feel free to donate using the button below. Thanks!
