summaryrefslogtreecommitdiff
path: root/lstwitch.rb
diff options
context:
space:
mode:
authorJoe Rayhawk <jrayhawk@omgwallhack.org>2016-09-15 17:25:55 -0700
committerJoe Rayhawk <jrayhawk@omgwallhack.org>2016-09-15 17:25:55 -0700
commit6b2c16ec62b8addf5da24a87feb9e32be06228c3 (patch)
tree4591b8a50176de508f0e268137147519f884feb1 /lstwitch.rb
parentaed3d1114c4b62e0c55a68fe92022b2a66798681 (diff)
downloadtwitchtools-6b2c16ec62b8addf5da24a87feb9e32be06228c3.tar.gz
twitchtools-6b2c16ec62b8addf5da24a87feb9e32be06228c3.zip
lstwitch.rb: add client_id
Diffstat (limited to 'lstwitch.rb')
-rwxr-xr-xlstwitch.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lstwitch.rb b/lstwitch.rb
index cf8af46..8c7b4a2 100755
--- a/lstwitch.rb
+++ b/lstwitch.rb
@@ -12,6 +12,12 @@ unless ARGV.empty?
end
end
+confdir = Dir.home + '/.config/twitch/'
+ENV['APPDATA'] && confdir = ENV['APPDATA'] + "\\twitch\\"
+ENV['XDG_CONFIG_HOME'] && confdir = ENV['XDG_CONFIG_HOME'] + '/twitch/'
+
+client_id = IO.read( confdir + 'client_id' ).chomp
+
http = Net::HTTP.new('api.twitch.tv', 443)
http.use_ssl = true
#http.verify_mode = OpenSSL::SSL::VERIFY_NONE
@@ -27,7 +33,7 @@ end
while offset < total
- response = JSON.parse(http.request(Net::HTTP::Get.new("/kraken/streams/?limit=100&offset=#{offset}#{game}")).body)
+ response = JSON.parse(http.request(Net::HTTP::Get.new("/kraken/streams/?limit=100&offset=#{offset}#{game}&client_id=#{client_id}")).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.sub(/http:\/\/.+?\./,''), stream['channel']['game'].to_s, stream['viewers'].to_i, stream['channel']['followers'].to_i, stream['channel']['status'].to_s.gsub(/\n/,'') )