require 'site_list/video_analyze' require 'requests/request' require 'progressbars/progressbar' require 'file_operats/file_operat_chatdata' require 'json' require 'nokogiri' class Youtubelive_analyze @USER_AGENT} continue_url=@videoinfo_polymer["contents"]["twoColumnWatchNextResults"]["conversationBar"]["liveChatRenderer"]["continuations"][0]["reloadContinuationData"]["continuation"] next_url=@CHAT_REQUEST_URL+continue_url while true do begin chat_respons,chat_status=request_html_parse(next_url,opt) chat_respons.search('script').each do |script| script=script.to_s if script.include?("window[\"ytInitialData\"]") then chat_body=script.split("=",2)[1].chomp("").strip.chomp(";") chat_body=JSON.parse(chat_body) continue_url = chat_body["continuationContents"]["liveChatContinuation"]["continuations"][0]["liveChatReplayContinuationData"]["continuation"] next_url=@CHAT_REQUEST_URL+continue_url chat_body["continuationContents"]["liveChatContinuation"]["actions"][1..-1].each do |chat| chat_count+=1 chat_list.push chat end progressbar(chat_count,"chat_count_inf") end end rescue break end end file_write(chat_list,log_flag,log_path) return chat_list end public :chat_scrape private :videoid_get, :videoinfo_get, :videoinfo_extraction end