It’s not often that I get to write a gem – since I’m fairly convinced that pretty much everything that needs to be on the Internet has already been made and subsequently forgotten about. It was with great excitement, therefore, that I noticed the Atlas-API had only a solitary client library and even that it was in Java.
The Atlas API provides all sorts interesting data about audio and video on the Internet – with BBC, Hulu and even Youtube feeds available the life of a audio-visual application developer couldn’t be made much easier.
To get started with Atlas and Ruby I implore you to install Ratlas
> gem install ratlas
Ratlas is a thin wrapper around the functions listed in the atlas api documentation. It provides 4 classes: search, discover, schedule and content which expose a find method that you can treat a little like you would the ActiveRecord find method. The arguments for the conditions hash are identical to the api docs – but we use underscored symbols rather than camelCased strings.
Ratlas::Discover.find(:all).where(:genre=> "drama", :media_type => 'video')
It also supports method chaining so you can define a search:
mysearch = Ratlas::Schedule.find(:all).where(:from => Time.now.to_i, :to=> Time.now.to_i + 3600)
and fiddle with it later on.
mysearch.and(:channel => 'bbcone')
Then when you’re feeling up to it calling #each or #to_a will execute your query and give you a nice Mash to play with.