diff options
author | Joe Rayhawk <jrayhawk@omgwallhack.org> | 2018-05-22 18:52:03 -0700 |
---|---|---|
committer | Joe Rayhawk <jrayhawk@omgwallhack.org> | 2018-05-22 18:52:03 -0700 |
commit | 026cfa6d20c186c69125212fd439eb100b445c96 (patch) | |
tree | 34645b197d02cec3147fa7f424a31b02fd4e8178 | |
parent | 8b5c3bb7ce8d9caddf06fb3beeec467bb25801e1 (diff) | |
download | twitchtools-026cfa6d20c186c69125212fd439eb100b445c96.tar.gz twitchtools-026cfa6d20c186c69125212fd439eb100b445c96.zip |
lstwitchvid: add uploads
-rwxr-xr-x | lstwitchvid.rb | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/lstwitchvid.rb b/lstwitchvid.rb index fc269d1..ecef766 100755 --- a/lstwitchvid.rb +++ b/lstwitchvid.rb @@ -4,9 +4,9 @@ require 'json' require 'net/http' -user = String.new +channel = String.new -user = URI.escape(ARGV[0]) +channel = URI.escape(ARGV[0]) broadcasts = String.new @@ -27,14 +27,14 @@ if width < 97 width=97 end -def videos(http, path, width, broadcasts, client_id) +def videos(http, channel, width, broadcast_type, client_id) total = 100 offset = 0 while offset <= total - response = JSON.parse(http.request(Net::HTTP::Get.new("#{path}?limit=100&offset=#{offset}&broadcasts=#{broadcasts}&client_id=#{client_id}")).body) + response = JSON.parse(http.request(Net::HTTP::Get.new("/kraken/channels/#{channel}/videos/?limit=100&offset=#{offset}&broadcast_type=#{broadcast_type}&client_id=#{client_id}")).body) if response['videos'] total = response['_total'] for video in response['videos'] @@ -48,10 +48,22 @@ def videos(http, path, width, broadcasts, client_id) end -print("Highlights:\n\n") +def clips( http, channel, width, client_id ) + #-H 'Accept: application/vnd.twitchtv.v5+json' + #https://api.twitch.tv/kraken/clips/top?client_id=$( cat ~/.config/twitch/client_id )&channel=bungmonkey&period=all&trending=false&limit=100 +end + +print("Clips:\n\n") + + +print("\nUploads:\n\n") + +videos( http, channel, width, 'upload', client_id ) + +print("\nHighlights:\n\n") -videos(http, "/kraken/channels/#{user}/videos/", width, false, client_id) +videos( http, channel, width, 'highlight', client_id ) print("\nBroadcasts:\n\n") -videos(http, "/kraken/channels/#{user}/videos/", width, true, client_id) +videos( http, channel, width, 'archive', client_id ) |