video_chat_get 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe6d8d4965ef4236416987dd4eb0e0c953a29d8a5e0dbc723c2d70a063046668
4
- data.tar.gz: 5ebe81abde7347cde06f88be947865a665cb69e6e5422b8663ebb3f379194c52
3
+ metadata.gz: 518a37dc694766450b8b7492ade79c354e260c9b2970fb49ad3dec3d4c060563
4
+ data.tar.gz: aa53b6f56bfc39853e8233e52ea6239a66c56c6c1a76e2585f04c099f60838ab
5
5
  SHA512:
6
- metadata.gz: 2d0ba1f3b315a8006361207336e6a9c9a766660d3635c21d3a43044b006b50d113c84c5bf591378a72f3f423a1e77db9c3b4bd262845fbfe51fcaa1fcd65c626
7
- data.tar.gz: 7bb4fcebe188bc33c89e45d979bca5f0a3cd886a40d2d44ae53d28061f307aafbafc9d99eade6f4911dc51f8e777a3dd2d6bea257cca3ab9002e642c29ce5816
6
+ metadata.gz: 9a2eaa81eeac2250b299a62d66181f366ea5d08a581d95cfaa7ecd39157761bf45a40537559749f68a575b304dee645e5cf8b6ccc41afba1475a2a3f3711cfd9
7
+ data.tar.gz: 04e540629458d2bf3a64f388588384ea4df8db2a1a37eec28218cff65b73dd116f03e055df5e6c952b603ffa0fe0879a9b62e5b454537b7abc8ab035d316d5f8
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- video_chat_get (0.1.2)
4
+ video_chat_get (0.1.3)
5
5
  httpclient (~> 2.8.3)
6
6
  json (~> 2.3.0)
7
7
  nokogiri (~> 1.10.9)
@@ -66,6 +66,4 @@ class Mildom_analyze
66
66
  public :chat_scrape
67
67
  private :videoid_get!, :chat_nextpage_get
68
68
 
69
- end
70
-
71
-
69
+ end
@@ -8,7 +8,7 @@ require 'nokogiri'
8
8
 
9
9
  class Youtubelive_analyze<Video_analyze
10
10
 
11
- attr_reader :video_id
11
+ attr_reader :video_id, :videoinfo, :videoinfo_request_status
12
12
 
13
13
  def initialize(url)
14
14
  @CHAT_REQUEST_URL="https://www.youtube.com/live_chat_replay?continuation="
@@ -16,61 +16,26 @@ class Youtubelive_analyze
16
16
 
17
17
  @video_url=url
18
18
  @video_id=videoid_get!(@video_url)
19
+ @videoinfo_polymer,@videoinfo_request_status=videoinfo_get(@video_url)
20
+ @videoinfo=videoinfo_extraction()
19
21
  @chatlog_filepath="./"+@video_id+".txt"
20
22
  end
21
23
 
22
24
 
23
- def videoid_get!(url)
25
+ def videoid_get!(url=@video_url)
24
26
  videoid=url.split("=")[1].split("&")[0]
25
27
  return videoid
26
28
  end
27
29
 
28
-
29
- def videoinfo_get()
30
- end
31
-
32
-
33
- """
34
- chat url get from iframe
35
- 202077end
36
- """
37
- def chat_url_get_iframe_extraction(url=@video_url)
38
-
39
- next_url=""
40
- body_status=""
41
- iframe_count=0
42
- opt={}
43
-
44
- while next_url.empty?
45
- sleep(1)
46
- iframe_count+=1
47
- first_respons, body_status=request_html_parse(url,opt)
48
- first_respons.search('iframe').each do |info|
49
- puts info
50
- if info["src"].include?("live_chat_replay") then
51
- next_url=info["src"]
52
- end
53
- end
54
- progressbar(iframe_count,"iframe_count_inf")
55
- end
56
30
 
57
- puts "iframe search finished!! iframe acquisition count #{iframe_count} "
58
- return next_url,body_status
59
- end
60
-
61
-
62
- """
63
- chat url get from htmljs
64
- 202077start
65
- """
66
- def chat_url_get_js_extraction(url=@video_url)
31
+ def videoinfo_get(url=@video_url)
67
32
 
68
33
  opt={}
69
34
  next_url_polymer=""
70
35
  next_url=""
71
36
 
72
- chat_respons,chat_status=request_html_parse(url,opt)
73
- chat_respons.search('script').each do |script|
37
+ videoinfo_respons,videoinfo_status=request_html_parse(url,opt)
38
+ videoinfo_respons.search('script').each do |script|
74
39
  script=script.to_s
75
40
  if script.include?("window[\"ytInitialData\"]") then
76
41
  next_url_polymer=script.split("=",2)[1].split("\n",2)[0]
@@ -78,20 +43,35 @@ class Youtubelive_analyze
78
43
  next_url_polymer=JSON.parse(next_url_polymer)
79
44
  end
80
45
  end
81
-
82
- next_url=next_url_polymer["contents"]["twoColumnWatchNextResults"]["conversationBar"]["liveChatRenderer"]["continuations"][0]["reloadContinuationData"]["continuation"]
83
- next_url=@CHAT_REQUEST_URL+next_url
84
- return next_url,chat_status
46
+
47
+ return next_url_polymer,videoinfo_status
85
48
  end
86
49
 
87
50
 
51
+
52
+ def videoinfo_extraction()
53
+ videoinfo={}
54
+ common_hash=@videoinfo_polymer["contents"]["twoColumnWatchNextResults"]["results"]["results"]["contents"]
55
+
56
+ videoinfo["ch"]=common_hash[1]["videoSecondaryInfoRenderer"]["owner"]["videoOwnerRenderer"]["title"]["runs"][0]["text"]
57
+ videoinfo["title"]=common_hash[0]["videoPrimaryInfoRenderer"]["title"]["runs"][0]["text"]
58
+ videoinfo["starttime"]=common_hash[0]["videoPrimaryInfoRenderer"]["dateText"]["simpleText"]
59
+ videoinfo["videocount"]=common_hash[0]["videoPrimaryInfoRenderer"]["viewCount"]["videoViewCountRenderer"]["viewCount"]["simpleText"]
60
+ videoinfo["good"]=common_hash[0]["videoPrimaryInfoRenderer"]["videoActions"]["menuRenderer"]["topLevelButtons"][0]["toggleButtonRenderer"]["defaultText"]["simpleText"]
61
+ videoinfo["bad"]=common_hash[0]["videoPrimaryInfoRenderer"]["videoActions"]["menuRenderer"]["topLevelButtons"][1]["toggleButtonRenderer"]["defaultText"]["simpleText"]
62
+
63
+ return videoinfo
64
+ end
65
+
66
+
88
67
  def chat_scrape(log_flag=true,log_path=@chatlog_filepath)
89
68
 
90
69
  chat_body={}
91
70
  chat_list=[]
92
71
  chat_count=0
93
72
  opt={'User-Agent' => @USER_AGENT}
94
- next_url,status=chat_url_get_js_extraction(@video_url)
73
+ next_url=@videoinfo_polymer["contents"]["twoColumnWatchNextResults"]["conversationBar"]["liveChatRenderer"]["continuations"][0]["reloadContinuationData"]["continuation"]
74
+ next_url=@CHAT_REQUEST_URL+next_url
95
75
 
96
76
  while true do
97
77
 
@@ -123,7 +103,8 @@ class Youtubelive_analyze
123
103
  return chat_list
124
104
  end
125
105
 
126
- public :chat_scrape, :chat_url_get_iframe_extraction, :chat_url_get_js_extraction
127
- private :videoid_get!, :videoinfo_get
128
106
 
129
- end
107
+ public :chat_scrape
108
+ private :videoid_get!, :videoinfo_get, :videoinfo_extraction
109
+
110
+ end
@@ -1,3 +1,3 @@
1
1
  module VideoChatGet
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: video_chat_get
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - tf0101
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-11 00:00:00.000000000 Z
11
+ date: 2020-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler