class ShowroomApi::Live
This class provides static methods for live rooms
Public Class Methods
age verification
@param room_id [String] @return [boolean]
@example
::ShowroomLive::Api::Live.age_verification(room_id)
# File lib/showroom_api.rb, line 99 def self.age_verification(room_id) return send_request("age_verification",room_id)[:is_passed] end
get room's comment log
@param room_id [String] @return [Array]
@example
::ShowroomLive::Api::Live.comment_log(room_id)
# File lib/showroom_api.rb, line 154 def self.comment_log(room_id) return send_request("comment_log",room_id)[:comment_log] || [] end
get logged in user's info
@param room_id [String] @return [Hash]
@example
::ShowroomLive::Api::Live.current_user(room_id)
# File lib/showroom_api.rb, line 110 def self.current_user(room_id) return send_request("current_user",room_id) end
get room's survey result
@param room_id [String] @return [Hash]
@example
::ShowroomLive::Api::Live.enquete_result(room_id)
# File lib/showroom_api.rb, line 132 def self.enquete_result(room_id) return send_request("enquete_result",room_id) end
get the stream url of the first room in the list of onlives
@return [String]
@example
::ShowroomLive::Api::Live.first_stream_url
# File lib/showroom_api.rb, line 55 def self.first_stream_url return onlives(1)[0][:lives][0][:streaming_url_list][0][:url] end
get room's available gift
@param room_id [String] @return [Hash]
@example
::ShowroomLive::Api::Live.gift_list(room_id)
# File lib/showroom_api.rb, line 176 def self.gift_list(room_id) return send_request("gift_list",room_id) end
get room's gift log
@param room_id [String] @return [Array]
@example
::ShowroomLive::Api::Live.gift_log(room_id)
# File lib/showroom_api.rb, line 165 def self.gift_log(room_id) return send_request("gift_log",room_id)[:gift_log] || [] end
get the info of the room
@param room_id [String] @return [Hash]
@example
::ShowroomLive::Api::Live.live_info(room_id)
# File lib/showroom_api.rb, line 66 def self.live_info(room_id) return send_request("live_info",room_id) end
get the count of live rooms
@return [Integer]
@example
::ShowroomLive::Api::Live.onlive_num
# File lib/showroom_api.rb, line 208 def self.onlive_num return send_request("onlive_num",nil)[:num] end
get the array of room categories and their available live rooms
@param size [Integer] @return [Array]
@example
::ShowroomLive::Api::Live.onlives
# 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
get the live status of the room
@param room_id [String] @return [Hash]
@example
::ShowroomLive::Api::Live.polling(room_id)
# File lib/showroom_api.rb, line 88 def self.polling(room_id) return send_request("polling",room_id) end
get the id of the first room in the list of onlives
@param size [Integer] @return [Array]
@example
::ShowroomLive::Api::Live.room_ids
# 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
get the list of gifts the room received
@param room_id [String] @return [Array]
@example
::ShowroomLive::Api::Live.stage_gift_list(room_id)
# 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
get the list of users in the room
@param room_id [String] @return [Array]
@example
::ShowroomLive::Api::Live.stage_user_list(room_id)
# 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
get the list of room's streaming URLs
@param room_id [String] @return [Array]
@example
::ShowroomLive::Api::Live.streaming_url(room_id)
# File lib/showroom_api.rb, line 77 def self.streaming_url(room_id) send_request("streaming_url",room_id)[:streaming_url_list] || [] end
get room's ranking summary
@param room_id [String] @return [Array]
@example
::ShowroomLive::Api::Live.summary_ranking(room_id)
# File lib/showroom_api.rb, line 143 def self.summary_ranking(room_id) return send_request("summary_ranking",room_id)[:ranking] || [] end
telop
@param room_id [String] @return [Hash]
@example
::ShowroomLive::Api::Live.telop(room_id)
# File lib/showroom_api.rb, line 121 def self.telop(room_id) return send_request("telop",room_id) end
Private Class Methods
performs http request to showroom
@param cmd [String] @param room_id [String] @return [Hash]
# File lib/showroom_api.rb, line 218 def self.send_request(cmd,room_id=nil) url="https://www.showroom-live.com/api/live/" if room_id.nil? || room_id.to_s.empty? ShowroomApi.showroom_live_get_api_data("#{url}#{cmd}") else ShowroomApi.showroom_live_get_api_data("#{url}#{cmd}?room_id=#{room_id}") end end