summaryrefslogtreecommitdiff
path: root/lstwitchvid.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lstwitchvid.rb')
-rwxr-xr-xlstwitchvid.rb26
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 )