Station parsers for radiofy.se.
Each station consists of a class which encapsulates the logic used to parse the data for a given station URL. Each class has to define three things.
- A unique name, preferably in lowercase without whitespace
- A URL for which the current playing song can be accessed
- A method called
processthat given some raw data returns a hash on the form{ artist: "...", song: "..." }or nil. The data can be accessed using thedatavariable. The type ofdatadepends on what format class you inherit from. If you for example inherit fromFormat::JSONthedatawill consists of a plain ruby hash created by passing the data given byurltoJSON.parse. Take a look at the current formatslib/formatsand classeslib/stationsfor examples.
A station is defined in lib/stations
module Station
class MyStation < Format::JSON
config do
id "unique-id"
url "http://example.com/current-song.json"
end
def process
{ artist: data[:artist], song: data[:title] }
end
end
endBefore you can get started you need to install the dependencies.
This can be done using bundle install after cloning the project.
Take a look at the contributing section for more information.
To verify that it acts as expected you can invoke it using the following command
EXPAND=1 STATION=unique-id bundle exec rake
Set STATION to whatever id you chose before.
- Fork it ( https://github.com/radiofy/station/fork )
- Create your station branch (
git checkout -b my-station) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-station) - Create a new pull request here on Github.
We'll merge the pull request as soon as we can.
Send us an email at radiofy.se/contact.