yt 0.32.2 → 0.32.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/lib/yt.rb +1 -1
- data/lib/yt/collections/reports.rb +2 -1
- data/lib/yt/collections/subscriptions.rb +1 -1
- data/lib/yt/models/account.rb +1 -1
- data/lib/yt/models/file_detail.rb +1 -0
- data/lib/yt/models/url.rb +99 -0
- data/lib/yt/models/video.rb +4 -0
- data/lib/yt/request.rb +4 -4
- data/lib/yt/version.rb +1 -1
- data/spec/models/url_spec.rb +78 -0
- data/spec/requests/as_account/account_spec.rb +13 -2
- data/spec/requests/as_account/channel_spec.rb +13 -10
- data/spec/requests/as_account/playlist_item_spec.rb +2 -3
- data/spec/requests/as_account/playlist_spec.rb +4 -4
- data/spec/requests/as_account/video_spec.rb +12 -2029
- data/spec/requests/as_server_app/url_spec.rb +94 -0
- metadata +8 -3
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'yt/models/url'
|
|
3
|
+
|
|
4
|
+
describe Yt::URL, :server_app do
|
|
5
|
+
subject(:url) { Yt::URL.new text }
|
|
6
|
+
|
|
7
|
+
context 'given an existing YouTube channel URL' do
|
|
8
|
+
let(:text) { "youtube.com/channel/UCxO1tY8h1AhOz0T4ENwmpow" }
|
|
9
|
+
|
|
10
|
+
it {expect(url.resource).to be_a Yt::Channel }
|
|
11
|
+
it {expect(url.resource.title).to be }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context 'given an existing YouTube video URL' do
|
|
15
|
+
let(:text) { "youtube.com/watch?v=gknzFj_0vvY" }
|
|
16
|
+
|
|
17
|
+
it {expect(url.resource).to be_a Yt::Video }
|
|
18
|
+
it {expect(url.resource.title).to be }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context 'given an unknown YouTube video URL' do
|
|
22
|
+
let(:text) { "youtu.be/invalid-id-" }
|
|
23
|
+
|
|
24
|
+
it {expect(url.resource).to be_a Yt::Video }
|
|
25
|
+
it {expect{url.resource.title}.to raise_error Yt::Errors::NoItems }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context 'given an existing YouTube playlist URL' do
|
|
29
|
+
let(:text) { "youtube.com/playlist?list=PL-LeTutc9GRKD3yBDhnRF_yE8UTaQI5Jf" }
|
|
30
|
+
|
|
31
|
+
it {expect(url.resource).to be_a Yt::Playlist }
|
|
32
|
+
it {expect(url.resource.title).to be }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
context 'given an unknown YouTube playlist URL' do
|
|
36
|
+
let(:text) { "https://www.youtube.com/playlist?list=invalid-id-" }
|
|
37
|
+
|
|
38
|
+
it {expect(url.resource).to be_a Yt::Playlist }
|
|
39
|
+
it {expect{url.resource.title}.to raise_error Yt::Errors::NoItems }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
context 'given an unknown text' do
|
|
43
|
+
let(:text) { 'not-really-anything---' }
|
|
44
|
+
|
|
45
|
+
it {expect{url.resource}.to raise_error Yt::Errors::NoItems }
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
context 'given a YouTube channel URL in the name form' do
|
|
49
|
+
let(:text) { "http://www.youtube.com/#{name}" }
|
|
50
|
+
|
|
51
|
+
describe 'works when the name matches the custom URL' do
|
|
52
|
+
let(:name) { 'nbcsports' }
|
|
53
|
+
it {expect(url.id).to eq 'UCqZQlzSHbVJrwrn5XvzrzcA' }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
describe 'works when the name matches the username' do
|
|
57
|
+
let(:name) { '2012NBCOlympics' }
|
|
58
|
+
it {expect(url.id).to eq 'UCqZQlzSHbVJrwrn5XvzrzcA' }
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
describe 'fails with unknown channels' do
|
|
62
|
+
let(:name) { 'not-an-actual-channel' }
|
|
63
|
+
it {expect{url.id}.to raise_error Yt::Errors::NoItems }
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
context 'given a YouTube channel URL in the custom form' do
|
|
68
|
+
let(:text) { "https://youtube.com/c/#{name}" }
|
|
69
|
+
|
|
70
|
+
describe 'works with existing channels' do
|
|
71
|
+
let(:name) { 'ogeeku' }
|
|
72
|
+
it {expect(url.id).to eq 'UC4nG_NxJniKoB-n6TLT2yaw' }
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
describe 'fails with unknown channels' do
|
|
76
|
+
let(:name) { 'not-an-actual-channel' }
|
|
77
|
+
it {expect{url.id}.to raise_error Yt::Errors::NoItems }
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
context 'given a YouTube channel URL in the username form' do
|
|
82
|
+
let(:text) { "youtube.com/user/#{name}" }
|
|
83
|
+
|
|
84
|
+
describe 'works with existing channels' do
|
|
85
|
+
let(:name) { 'ogeeku' }
|
|
86
|
+
it {expect(url.id).to eq 'UC4lU5YG9QDgs0X2jdnt7cdQ' }
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
describe 'fails with unknown channels' do
|
|
90
|
+
let(:name) { 'not-an-actual-channel' }
|
|
91
|
+
it {expect{url.id}.to raise_error Yt::Errors::NoItems }
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: yt
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.32.
|
|
4
|
+
version: 0.32.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Claudio Baccigalupo
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2019-03-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -236,6 +236,7 @@ files:
|
|
|
236
236
|
- lib/yt/models/status.rb
|
|
237
237
|
- lib/yt/models/subscription.rb
|
|
238
238
|
- lib/yt/models/timestamp.rb
|
|
239
|
+
- lib/yt/models/url.rb
|
|
239
240
|
- lib/yt/models/user_info.rb
|
|
240
241
|
- lib/yt/models/video.rb
|
|
241
242
|
- lib/yt/models/video_category.rb
|
|
@@ -286,6 +287,7 @@ files:
|
|
|
286
287
|
- spec/models/statistics_set_spec.rb
|
|
287
288
|
- spec/models/status_spec.rb
|
|
288
289
|
- spec/models/subscription_spec.rb
|
|
290
|
+
- spec/models/url_spec.rb
|
|
289
291
|
- spec/models/video_category_spec.rb
|
|
290
292
|
- spec/models/video_spec.rb
|
|
291
293
|
- spec/requests/as_account/account_spec.rb
|
|
@@ -315,6 +317,7 @@ files:
|
|
|
315
317
|
- spec/requests/as_server_app/comment_threads_spec.rb
|
|
316
318
|
- spec/requests/as_server_app/playlist_item_spec.rb
|
|
317
319
|
- spec/requests/as_server_app/playlist_spec.rb
|
|
320
|
+
- spec/requests/as_server_app/url_spec.rb
|
|
318
321
|
- spec/requests/as_server_app/video_spec.rb
|
|
319
322
|
- spec/requests/as_server_app/videos_spec.rb
|
|
320
323
|
- spec/requests/unauthenticated/video_spec.rb
|
|
@@ -342,7 +345,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
342
345
|
version: '0'
|
|
343
346
|
requirements: []
|
|
344
347
|
rubyforge_project:
|
|
345
|
-
rubygems_version: 2.7.6
|
|
348
|
+
rubygems_version: 2.7.6.2
|
|
346
349
|
signing_key:
|
|
347
350
|
specification_version: 4
|
|
348
351
|
summary: Yt makes it easy to interact with Youtube V3 API by providing a modular,
|
|
@@ -392,6 +395,7 @@ test_files:
|
|
|
392
395
|
- spec/models/statistics_set_spec.rb
|
|
393
396
|
- spec/models/status_spec.rb
|
|
394
397
|
- spec/models/subscription_spec.rb
|
|
398
|
+
- spec/models/url_spec.rb
|
|
395
399
|
- spec/models/video_category_spec.rb
|
|
396
400
|
- spec/models/video_spec.rb
|
|
397
401
|
- spec/requests/as_account/account_spec.rb
|
|
@@ -421,6 +425,7 @@ test_files:
|
|
|
421
425
|
- spec/requests/as_server_app/comment_threads_spec.rb
|
|
422
426
|
- spec/requests/as_server_app/playlist_item_spec.rb
|
|
423
427
|
- spec/requests/as_server_app/playlist_spec.rb
|
|
428
|
+
- spec/requests/as_server_app/url_spec.rb
|
|
424
429
|
- spec/requests/as_server_app/video_spec.rb
|
|
425
430
|
- spec/requests/as_server_app/videos_spec.rb
|
|
426
431
|
- spec/requests/unauthenticated/video_spec.rb
|