Skip to content

Instantly share code, notes, and snippets.

@tanookiben
Last active August 29, 2015 14:10
Show Gist options
  • Save tanookiben/ebcc94db19ca8efe1504 to your computer and use it in GitHub Desktop.
Save tanookiben/ebcc94db19ca8efe1504 to your computer and use it in GitHub Desktop.
Get current live Twitch followed channels
require 'net/http'
require 'json'
FOLLOW_REQUEST = "https://api.twitch.tv/kraken/users/#{ARGV[0]}/follows/channels?limit=100"
STREAM_REQUEST = "https://api.twitch.tv/kraken/streams/"
followed_channels = JSON.parse(Net::HTTP.get_response(URI.parse(FOLLOW_REQUEST)).body)['follows'].collect { |chan| chan['channel']['name'] }
followed_live_channels = followed_channels.keep_if { |chan| JSON.parse(Net::HTTP.get_response(URI.parse("#{STREAM_REQUEST}#{chan}")).body)['stream'] }
puts followed_live_channels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment