Class: SleepRoom::Record::API::StreamingAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/sleeproom/record/api/streaming_api.rb

Instance Method Summary collapse

Constructor Details

#initialize(room_id) ⇒ StreamingAPI

Returns a new instance of StreamingAPI.



7
8
9
10
11
# File 'lib/sleeproom/record/api/streaming_api.rb', line 7

def initialize(room_id)
  @url = STREAMING_API + "?room_id=" + room_id.to_s + "&ignore_low_stream=1"
  @json = nil
  get
end

Instance Method Details

#get(task: Async::Task.current) ⇒ Object



13
14
15
# File 'lib/sleeproom/record/api/streaming_api.rb', line 13

def get(task: Async::Task.current)
  @json = API.get(@url).wait
end

#streaming_urlObject



17
18
19
20
21
22
23
# File 'lib/sleeproom/record/api/streaming_api.rb', line 17

def streaming_url
  if @json["streaming_url_list"].nil?
    raise Error.new("streaming url is null.")
  else
    @json["streaming_url_list"].sort_by{|hash| -hash["quality"]}.first["url"]
  end
end