#!/usr/bin/ruby require 'json' require 'net/http' game = String.new unless ARGV.empty? game = "&game=#{URI.escape(ARGV[0])}" if ARGV[0] == 'APB' or ARGV[0] == 'apb' game = "&game=APB%20Reloaded" end end http = Net::HTTP.new('api.twitch.tv', 443) http.use_ssl = true #http.verify_mode = OpenSSL::SSL::VERIFY_NONE offset = 0 total = 1 width = `stty size`.split[1].to_i if width < 97 width=97 end while offset < total response = JSON.parse(http.request(Net::HTTP::Get.new("/kraken/streams/?offset=#{offset}#{game}")).body) total = response["_total"] for stream in response['streams'] printf( "%-45s %-36s %6i %6i %-.#{width-46-37-7-7}s\n", stream['channel']['url'].to_s, stream['channel']['game'].to_s, stream['viewers'], stream['channel']['followers'], stream['channel']['status'].to_s.gsub(/\n/,'') ) end offset += 100 end