Class: ShowroomApi::Live

Inherits:
Object
  • Object
show all
Defined in:
lib/showroom_api.rb

Overview

This class provides static methods for live rooms

Class Method Summary collapse

Class Method Details

.age_verification(room_id) ⇒ boolean

age verification

Examples:

::ShowroomLive::Api::Live.age_verification(room_id)

Parameters:

  • room_id (String)

Returns:

  • (boolean)


99
100
101
# File 'lib/showroom_api.rb', line 99

def self.age_verification(room_id)
  return send_request("age_verification",room_id)[:is_passed]
end

.comment_log(room_id) ⇒ Array

get room’s comment log

Examples:

::ShowroomLive::Api::Live.comment_log(room_id)

Parameters:

  • room_id (String)

Returns:

  • (Array)


154
155
156
# File 'lib/showroom_api.rb', line 154

def self.comment_log(room_id)
  return send_request("comment_log",room_id)[:comment_log] || []
end

.current_user(room_id) ⇒ Hash

get logged in user’s info

Examples:

::ShowroomLive::Api::Live.current_user(room_id)

Parameters:

  • room_id (String)

Returns:

  • (Hash)


110
111
112
# File 'lib/showroom_api.rb', line 110

def self.current_user(room_id)
  return send_request("current_user",room_id)
end

.enquete_result(room_id) ⇒ Hash

get room’s survey result

Examples:

::ShowroomLive::Api::Live.enquete_result(room_id)

Parameters:

  • room_id (String)

Returns:

  • (Hash)


132
133
134
# File 'lib/showroom_api.rb', line 132

def self.enquete_result(room_id)
  return send_request("enquete_result",room_id)
end

.first_stream_urlString

get the stream url of the first room in the list of onlives

Examples:

::ShowroomLive::Api::Live.first_stream_url

Returns:

  • (String)


55
56
57
# File 'lib/showroom_api.rb', line 55

def self.first_stream_url
  return onlives(1)[0][:lives][0][:streaming_url_list][0][:url]
end

.gift_list(room_id) ⇒ Hash

get room’s available gift

Examples:

::ShowroomLive::Api::Live.gift_list(room_id)

Parameters:

  • room_id (String)

Returns:

  • (Hash)


176
177
178
# File 'lib/showroom_api.rb', line 176

def self.gift_list(room_id)
  return send_request("gift_list",room_id)
end

.gift_log(room_id) ⇒ Array

get room’s gift log

Examples:

::ShowroomLive::Api::Live.gift_log(room_id)

Parameters:

  • room_id (String)

Returns:

  • (Array)


165
166
167
# File 'lib/showroom_api.rb', line 165

def self.gift_log(room_id)
  return send_request("gift_log",room_id)[:gift_log] || []
end

.live_info(room_id) ⇒ Hash

get the info of the room

Examples:

::ShowroomLive::Api::Live.live_info(room_id)

Parameters:

  • room_id (String)

Returns:

  • (Hash)


66
67
68
# File 'lib/showroom_api.rb', line 66

def self.live_info(room_id)
  return send_request("live_info",room_id)
end

.onlive_numInteger

get the count of live rooms

Examples:

::ShowroomLive::Api::Live.onlive_num

Returns:

  • (Integer)


208
209
210
# File 'lib/showroom_api.rb', line 208

def self.onlive_num
  return send_request("onlive_num",nil)[:num]
end

.onlives(size = nil) ⇒ Array

get the array of room categories and their available live rooms

Examples:

::ShowroomLive::Api::Live.onlives

Parameters:

  • size (Integer) (defaults to: nil)

Returns:

  • (Array)


20
21
22
23
24
25
26
27
# File 'lib/showroom_api.rb', line 20

def self.onlives(size=nil)
  data=send_request("onlives",nil)[:onlives]
  cnt=ShowroomApi.to_integer(size)
  if !cnt.nil? && cnt > 0
    return data[0..(cnt-1)]  
  end
  return data
end

.polling(room_id) ⇒ Hash

get the live status of the room

Examples:

::ShowroomLive::Api::Live.polling(room_id)

Parameters:

  • room_id (String)

Returns:

  • (Hash)


88
89
90
# File 'lib/showroom_api.rb', line 88

def self.polling(room_id)
  return send_request("polling",room_id)
end

.room_ids(size) ⇒ Array

get the id of the first room in the list of onlives

Examples:

::ShowroomLive::Api::Live.room_ids

Parameters:

  • size (Integer)

Returns:

  • (Array)


36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/showroom_api.rb', line 36

def self.room_ids(size)
  arr=[]
  cnt=ShowroomApi.to_integer(size)
  return [] if cnt.nil? || cnt <= 0
  rooms=onlives(1)
  rooms[0][:lives].each_with_index do |room,i|
    break if i>=cnt 
    arr<<room[:room_id]
  end
  #$stderr.puts arr
  return arr
end

.stage_gift_list(room_id) ⇒ Array

get the list of gifts the room received

Examples:

::ShowroomLive::Api::Live.stage_gift_list(room_id)

Parameters:

  • room_id (String)

Returns:

  • (Array)


187
188
189
# File 'lib/showroom_api.rb', line 187

def self.stage_gift_list(room_id)
  return send_request("stage_gift_list",room_id)[:stage_gift_list] || []
end

.stage_user_list(room_id) ⇒ Array

get the list of users in the room

Examples:

::ShowroomLive::Api::Live.stage_user_list(room_id)

Parameters:

  • room_id (String)

Returns:

  • (Array)


198
199
200
# File 'lib/showroom_api.rb', line 198

def self.stage_user_list(room_id)
  return send_request("stage_user_list",room_id)[:stage_user_list] || []
end

.streaming_url(room_id) ⇒ Array

get the list of room’s streaming URLs

Examples:

::ShowroomLive::Api::Live.streaming_url(room_id)

Parameters:

  • room_id (String)

Returns:

  • (Array)


77
78
79
# File 'lib/showroom_api.rb', line 77

def self.streaming_url(room_id)
  send_request("streaming_url",room_id)[:streaming_url_list] || []
end

.summary_ranking(room_id) ⇒ Array

get room’s ranking summary

Examples:

::ShowroomLive::Api::Live.summary_ranking(room_id)

Parameters:

  • room_id (String)

Returns:

  • (Array)


143
144
145
# File 'lib/showroom_api.rb', line 143

def self.summary_ranking(room_id)
  return send_request("summary_ranking",room_id)[:ranking] || []
end

.telop(room_id) ⇒ Hash

telop

Examples:

::ShowroomLive::Api::Live.telop(room_id)

Parameters:

  • room_id (String)

Returns:

  • (Hash)


121
122
123
# File 'lib/showroom_api.rb', line 121

def self.telop(room_id)
  return send_request("telop",room_id)
end