Jtv
This gem allows you to quickly add Justin.TV integration to your Ruby applications. Jtv is a useful tool for providing a list of livestreams, as well as embedding Justin.TV streams and clips.
Installation
Add this line to your application's Gemfile:
gem 'jtv'
And then execute:
$ bundle
Or install it yourself as:
$ gem install jtv
Justin.TV API Keys
If you want access to higher rate limits for your application, then you need to sign up for a Justin.TV developer account.
Once you have your API Keys, you'll need to set them up as environment variables for them to work with this gem. A great article on environment variables can be found at Heroku.
ENV['JTV_CONSUMER_KEY']
ENV['JTV_CONSUMER_SECRET']
Usage
The Jtv gem offers various classes depending on the type of information you're looking for.
JtvChannel
The JtvChannel class provides access to stream information for a specific channel. You'll need to pass the channel handle when you initialize your object.
channel = JtvChannel.new( 'channel' )
You'll then have access to the following information.
channel.viewers
# Number of current viewers on the stream, requires a second API call
channel.image_huge
# 320x240 Image URL
channel.screen_cap_huge
# 320x240 Screen Capture URL
channel.id
# The channel handle
channel.
#Code required to embed the Justin.TV Player, response looks like:
<object type="application/x-shockwave-flash" height="295" width="353" id="jtv_player_flash" data="http://www.justin.tv/widgets/jtv_player.swf?channel=apidemo" bgcolor="#000000"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.justin.tv/widgets/jtv_player.swf" /><param name="flashvars" value="channel=apidemo&auto_play=false&start_volume=25" /></object>
channel.title
channel.url
channel.about
channel.description
JtvClip
The JtvClip class provides access to specific clip information. To create a clip object, simply pass the clip id when you initialize the object.
clip = JtvClip.new( 1278312 )
The following method calls are available through the Clip class.
clip.description
clip.title
clip.id
clip.
clip.
clip.image_huge
clip.length
clip.created_on
Contributing
Contributions and feedback are more than welcome and highly encouraged.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Added some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
TODO
- Add JtvCategory, which will return an array of objects from a category.
- Add support for POST API calls.