class Whowatch_analyze

Attributes

chat_body[R]
video_id[R]
videoandchat_info_request_status[R]
videoinfo[R]

Public Class Methods

new(url) click to toggle source
# File lib/site_list/whowatch_analyze.rb, line 15
def initialize(url)
    @VIDEOINFO_REQEST_URL="https://api.whowatch.tv/lives/"
    
    @video_url=url
    @video_id=videoid_get()
    @videoinfo,@chat_body,@videoandchat_info_request_status=videoinfo_get(@VIDEOINFO_REQEST_URL+@video_id)
    @chatlog_filepath="./"+@video_id+".txt"

end

Public Instance Methods

chat_scrape(log_flag=true,log_path=@chatlog_filepath) click to toggle source
# File lib/site_list/whowatch_analyze.rb, line 38
def chat_scrape(log_flag=true,log_path=@chatlog_filepath)

    chat_list=[]
    count=0
    
    @chat_body[0..-1].each do |chat|
        chat_list.push chat
        count+=1
        progressbar(count,@videoinfo["live"]["comment_count"])
    end
    
    file_write(chat_list,log_flag,log_path)
    return chat_list
 end

Private Instance Methods

videoid_get() click to toggle source
# File lib/site_list/whowatch_analyze.rb, line 26
def videoid_get()
    return @video_url.split("/")[4]
end
videoinfo_get(url) click to toggle source
# File lib/site_list/whowatch_analyze.rb, line 31
def videoinfo_get(url)
    body,status=request_json_parse(url)
    chat_body=body.delete("comments")
    return body,chat_body,status
end