Ruby script for tuning in to the free Last.fm radio service and automatically tweeting recent tracks. Provides uninterrupted listening and tweets download links for free tracks.
Building on LastFM AutoResume, I wrote another Ruby script to automatically post recent tracks to Twitter. Many thanks to statianzo for his code that helped me puzzle out the Last.fm API and XML-Simple.
You can see it in action on my Twitter feed: https://twitter.com/DR3WH0
- Load Last.fm web radio from the command line
- Auto-resume free Last.fm radio
- Tweet each track after it’s played, including: time, track name, artist, link to Last.fm track page, and top 3 track tags
- Tweet Last.fm free MP3 downloads link when a downloadable track is played
- Ruby 1.9.2 or higher
- selenium-webdriver gem
- twurl gem
- xml-simple gem
- googl gem
- Firefox and a profile called ‘lastfm’
- See this post for instructions on setting up a Firefox ‘lastfm’ profile with the Profile Manager. Your new profile will need to stay logged in to Last.fm for the tweets to work.
- Create a Last.fm API key and add it to ‘lastfm-autotweet.yaml’ along with your Last.fm username.
- Authenticate Twurl with a Twitter API Key. You will need to set up a Twitter Dev Application for your account and enable it to ‘Read & Write.’ There’s a good write up on how to do that at Stack Overflow.
- Run ‘lastfm-autotweet.rb’, enter a station name, and enjoy uninterrupted, free Last.fm listening with each track posted to your Twitter feed.