Ruby script for loading the free Last.Fm web radio service from the command line, tweeting recently listened tracks, and generating a Markdown formatted radio station blog post for a Jekyll site.
- Load & auto-resume free Last.fm web radio from the command line
- Tweet tracks and free MP3 downloads to Twitter timeline
- Generate a Markdown formatted radio station blog post for Jekyll
- Jekyll web site (Github Pages)
- Ruby 1.9.2 or higher
- selenium-webdriver gem
- twurl gem
- xml-simple gem
- googl gem
- Firefox and a profile called ‘lastfm’
- Set up a ‘lastfm’ profile with the Firefox Profile Manager.
- Create a Last.fm API key and add it to the _config.yml for your Jekyll site along with your Last.fm username. (You may use my key for testing purposes.)
- 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.’ Stack Overflow has a walk-through.
- Place _radioblog.rb in the root directory of your Jekyll site.
- Push the radio station post to your site with git after the station has ended.
This software is tailored for my personal use and may require modification beyond what is described here.
I’ve installed the SCM Music Player on DR3WH0.NET, and I added some code to write free download tracks to _config.yml for automatic playlist updates. You may want to remove these lines in the free_download function if you have no use for that feature. If want to use the SCM playlist feature on your site, see SCM Music Player for GitHub Pages for installation instructions.
The track tweets are not really necessary, although it takes a bit of doing to remove them. I may create NoTweet branch if there’s any interest. To stop the tweets, skip step 3 of the Install Instructions and remove the following functions: format_hash & get_tags. Then remove the lines of code here, here, here, here, here, here, here, here, here, here, and here. Whew! Almost done. Finally, remove the variables
hashtags, tweet, tcolen, here and
@hashtags, tweet, tcolen, here and the variable
Let me know if there’s anything I missed or if there’s a way to rubify the code to make it more modular.