Ruby API wrapper for shuffler.fm v1 API
Add this line to your application's Gemfile:
gem 'shuffler_fm'
And then execute:
$ bundle
Or install it yourself as:
$ gem install shuffler_fm
require 'shuffler_fm'
# Get and API key from http://shuffler.fm/developers
api = ShufflerFM.api('YOUR-KEY')
=> #<ShufflerFM::API:0x000000027fa2b8 @key="YOUR-KEY">
# list tracks
tracks = api.tracks
=> [#<Hashie::Rash blog=#<Hashie::Rash about=\"\" channel_url=\"http://api.shuffler.fm/v1/channels/blog:963?api-key=YOUR-KEY\" genres=[\"indie\", \"folk\", \"singer-songwriter\"] id=963 images=[#<Hashie::Rash height=240 url=\"http://assets.shuffler.fm/feeds/963/argeheartedboy_large.jpg\" width=240>] permalink=\"largehearted-boy\" profiles=#<Hashie::Rash facebook=nil twitter=nil> ...
# list operations are paginated
tracks = api.tracks(page: 2)
# request a particular track
track = api.track(1134715)
track.blog.title
=> "Cover Freak"
track.post.url
=> "http://coverfreak.com/2012/09/23/satisfaction/"
track.metadata.title
=> "Satisfaction"
track.metadata.artist.name
=> "Bjork & PJ Harvey"
api.search_artists('radiohead').map(&:name)
=> ["Radiohead", "Radiohead at Lollapalooza 2008", "REM & Radiohead", "Radiohead 6. Permanent Daylight live", "Radiohead @ Optimus Alive'12", "I Can't Take The Hurt (Johnny Cash vs Tegan and Sarah and Radiohead)"]
activity = []
api.genre_channels('punk', 'rock', page: 1, per_page: 10).each do |act|
activity << "#{act.verb.capitalize} on #{act.actor.title} refering music track #{act.object.metadata.title}"
end
activity
=> ["Post on The KEXP Blog refering music track Sunshine/Pretty Girls (Live on KEXP)",
"Post on PropertyOfZack refering music track Always Summer (Live Video)",
"Post on Nialler9 Music Blog refering music track Honningbarna (2012)",
"Post on This Is Fake DIY refering music track Coffin Song", ...
and more ...
ShufflerFM.configure do |config|
config.connection_timeout = 1 #seconds
config.read_timeout = 5 #seconds
config.proxy = { uri: 'http://192.168.1.1:8080', user: 'user1', password: 'passwd'}
end
#or
api = ShufflerFM.api("your-api-key", connection_timeout: 1, read_timeout: 5, proxy: 'http://192.168.1.1:8080')
- Fork it
- Create your topic branch (
git checkout -b my-topic-branch
) - Add/change specs for your unimplemented feature or bug fix
- Make sure specs fail by running
bundle exec rake spec
. If not return to step 3 - Hack it
- Make sure specs pass (
bundle exec rake spec
). If not return to step 5 - Edit the documentation so it is coherent with your feature or fix. Run
bundle exec rake yard
to review - Commit changes (
git commit -am 'Add some feature/fix'
) and push to the branch (git push origin my-topic-branch
) - Submit a pull request for your branch.
This API wrapper design is strongly influenced by the Ocktokit gem
Copyright (c) 2012 Miguel Guinada LICENSE for details.