DR3WH0.png DR3WH0

Time Travel & Other Anomalies

LastFm AutoTweet

    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


Command Line

ruby lastfm-autotweet.rb


  1. 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.
  2. Create a Last.fm API key and add it to ‘lastfm-autotweet.yaml’ along with your Last.fm username.
  3. 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.
  4. Run ‘lastfm-autotweet.rb’, enter a station name, and enjoy uninterrupted, free Last.fm listening with each track posted to your Twitter feed.

Monday, August 19, 2013 Creative Commons License
This post is licensed under a Creative Commons Attribution 3.0 Unported License.