Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/glacials/splits-io. a speedrunning data store and analysis engine splits.io
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758require 'net/http'
class Twitch class Error < StandardError; end class NotFound < Error; end
module User def self.login_from_url(twitch_url) %r{^https?://(?:www\.)?twitch\.tv/([^/]+)(?:.*)$}.match(twitch_url)[1].downcase end
class << self def get(id) route(id).get(Twitch.headers) end
def route(id) Twitch.route["/users/#{id}"] end end end
module Follows def self.followed_ids(id) Rails.cache.fetch([:twitch, :follows, id]) do JSON.parse( self.get(id) )['follows'].map do |follow| follow['channel']['_id'] end end end
class << self def get(id) route(id).get(Twitch.headers) end
def route(id) User.route(id)['/follows/channels?limit=100'] end end end
class << self def route RestClient::Resource.new('https://api.twitch.tv/kraken') end
def headers { 'Accept' => 'application/vnd.twitchtv.v5+json', 'Client-ID' => ENV['TWITCH_CLIENT_ID'] } end endend