YPBT 0.1.5 → 0.2.2
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 +4 -4
- data/.travis.yml +0 -2
- data/Rakefile +3 -2
- data/YPBT.gemspec +1 -2
- data/lib/YPBT/author.rb +4 -4
- data/lib/YPBT/comment.rb +9 -11
- data/lib/YPBT/runner.rb +2 -2
- data/lib/YPBT/time_tag.rb +54 -0
- data/lib/YPBT/version.rb +1 -1
- data/lib/YPBT/video.rb +7 -10
- data/lib/YPBT/youtube_api.rb +47 -21
- data/spec/Ytapi_spec.rb +60 -0
- data/spec/comment_spec.rb +30 -0
- data/spec/fixtures/cassettes/youtube_api.yml +6615 -0
- data/spec/spec_helper.rb +2 -2
- data/spec/time_tag_spec.rb +31 -0
- data/spec/video_spec.rb +13 -43
- metadata +23 -2
data/spec/spec_helper.rb
CHANGED
@@ -11,13 +11,13 @@ require './lib/YPBT/comment.rb'
|
|
11
11
|
require './lib/YPBT/video.rb'
|
12
12
|
require './lib/YPBT/author.rb'
|
13
13
|
require './lib/YPBT/youtube_api.rb'
|
14
|
-
|
15
14
|
require_relative '../lib/YPBT'
|
16
15
|
|
17
16
|
FIXTURES_FOLDER = 'spec/fixtures'
|
18
17
|
CASSETTES_FOLDER = "#{FIXTURES_FOLDER}/cassettes"
|
19
18
|
CASSETTE_FILE = 'youtube_api'
|
20
|
-
TEST_VIDEO_ID = '
|
19
|
+
TEST_VIDEO_ID = 'vJOkR0Xz958'
|
20
|
+
TEST_COMMENT_ID = 'z13dwdepqxvdvvmbj04chpaxmuvbwjxhsr40k'
|
21
21
|
RESULT_FILE = "#{FIXTURES_FOLDER}/yt_api_results.yml"
|
22
22
|
YT_RESULT = YAML.load(File.read(RESULT_FILE))
|
23
23
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative 'spec_helper.rb'
|
3
|
+
|
4
|
+
describe 'time_tag specifications' do
|
5
|
+
VCR.configure do |c|
|
6
|
+
c.cassette_library_dir = CASSETTES_FOLDER
|
7
|
+
c.hook_into :webmock
|
8
|
+
|
9
|
+
c.filter_sensitive_data('<API_KEY>') { ENV['YOUTUBE_API_KEY'] }
|
10
|
+
c.filter_sensitive_data('<API_KEY_ESCAPED>') do
|
11
|
+
URI.escape(ENV['YOUTUBE_API_KEY'])
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
before do
|
16
|
+
VCR.insert_cassette CASSETTE_FILE, record: :new_episodes
|
17
|
+
end
|
18
|
+
|
19
|
+
after do
|
20
|
+
VCR.eject_cassette
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'time_tag functions' do
|
24
|
+
it 'should able find time tag from comment text' do
|
25
|
+
comment = YoutubeVideo::Comment.find(comment_id: TEST_COMMENT_ID)
|
26
|
+
tags = YoutubeVideo::Timetag.find(comment: comment)
|
27
|
+
tags.must_be_instance_of Array
|
28
|
+
tags.length.must_be :==, 3
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/spec/video_spec.rb
CHANGED
@@ -27,52 +27,22 @@ describe 'Video specifications' do
|
|
27
27
|
it 'should be able to get a new access token with file credentials' do
|
28
28
|
YoutubeVideo::YtApi.config = { api_key: ENV['YOUTUBE_API_KEY'] }
|
29
29
|
end
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should be able to open a video' do
|
33
|
-
video = YoutubeVideo::Video.find(
|
34
|
-
video_id: TEST_VIDEO_ID
|
35
|
-
)
|
36
|
-
video.title.length.must_be :>, 0
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should get the latest commentThreads from a video' do
|
40
|
-
video = YoutubeVideo::Video.find(
|
41
|
-
video_id: TEST_VIDEO_ID
|
42
|
-
)
|
43
|
-
commentthreads = video.commentthreads
|
44
|
-
commentthreads.count.must_be :>, 10
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'should get information about comment on the commentThreads' do
|
48
|
-
video = YoutubeVideo::Video.find(
|
49
|
-
video_id: TEST_VIDEO_ID
|
50
|
-
)
|
51
30
|
|
52
|
-
video
|
53
|
-
|
54
|
-
|
31
|
+
it 'should be able to open a video' do
|
32
|
+
video = YoutubeVideo::Video.find(
|
33
|
+
video_id: TEST_VIDEO_ID
|
34
|
+
)
|
35
|
+
video.title.length.must_be :>, 0
|
55
36
|
end
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'should find all parts of a full comment' do
|
59
|
-
comment = YT_RESULT['comment'].first
|
60
|
-
retrieved = YoutubeVideo::Comment.find(
|
61
|
-
comment_id: comment['id']
|
62
|
-
)
|
63
|
-
|
64
|
-
retrieved.comment_id.must_equal comment['id']
|
65
|
-
retrieved.published_at.must_equal comment['snippet']['publishedAt']
|
66
|
-
retrieved.updated_at.must_equal comment['snippet']['updateAt']
|
67
|
-
retrieved.text_display.must_equal comment['snippet']['textDisplay']
|
68
37
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
38
|
+
it 'should have comments' do
|
39
|
+
video = YoutubeVideo::Video.find(video_id: TEST_VIDEO_ID)
|
40
|
+
video.comments.length.must_be :>, 1
|
41
|
+
end
|
73
42
|
|
74
|
-
|
75
|
-
|
76
|
-
|
43
|
+
it 'should run the executable file' do
|
44
|
+
output = `YPBT #{TEST_VIDEO_ID}`
|
45
|
+
output.split("\n").length.must_be :>, 5
|
46
|
+
end
|
77
47
|
end
|
78
48
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: YPBT
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yi-Min
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-11-
|
13
|
+
date: 2016-11-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: http
|
@@ -26,6 +26,20 @@ dependencies:
|
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '2.0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: ruby-duration
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 3.2.3
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 3.2.3
|
29
43
|
- !ruby/object:Gem::Dependency
|
30
44
|
name: minitest
|
31
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -177,12 +191,16 @@ files:
|
|
177
191
|
- lib/YPBT/author.rb
|
178
192
|
- lib/YPBT/comment.rb
|
179
193
|
- lib/YPBT/runner.rb
|
194
|
+
- lib/YPBT/time_tag.rb
|
180
195
|
- lib/YPBT/version.rb
|
181
196
|
- lib/YPBT/video.rb
|
182
197
|
- lib/YPBT/youtube_api.rb
|
198
|
+
- spec/Ytapi_spec.rb
|
199
|
+
- spec/comment_spec.rb
|
183
200
|
- spec/fixtures/cassettes/youtube_api.yml
|
184
201
|
- spec/fixtures/yt_api_results.yml
|
185
202
|
- spec/spec_helper.rb
|
203
|
+
- spec/time_tag_spec.rb
|
186
204
|
- spec/video_spec.rb
|
187
205
|
homepage: https://github.com/RubyStarts3/YPBT
|
188
206
|
licenses:
|
@@ -209,7 +227,10 @@ signing_key:
|
|
209
227
|
specification_version: 4
|
210
228
|
summary: Gets comment from public Youtube videos
|
211
229
|
test_files:
|
230
|
+
- spec/Ytapi_spec.rb
|
231
|
+
- spec/comment_spec.rb
|
212
232
|
- spec/fixtures/cassettes/youtube_api.yml
|
213
233
|
- spec/fixtures/yt_api_results.yml
|
214
234
|
- spec/spec_helper.rb
|
235
|
+
- spec/time_tag_spec.rb
|
215
236
|
- spec/video_spec.rb
|