Skip to content

Commit 3644e7d

Browse files
Merge pull request #26 from Fullscreen/fix-test
Fix test and remove Featured
2 parents 30cdc17 + f8a76fb commit 3644e7d

File tree

6 files changed

+37
-102
lines changed

6 files changed

+37
-102
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ For more information about changelogs, check
66
[Keep a Changelog](http://keepachangelog.com) and
77
[Vandamme](http://tech-angels.github.io/vandamme).
88

9+
## Unreleased
10+
11+
**How to upgrade**
12+
13+
If your code calls `Yt::Annotation::Featured` object, you should not use it because it is removed.
14+
15+
* [REMOVAL] Remove Yt::Annotation::Featured annotation because YouTube removed it (as of 12-14-2017).
16+
https://developers.google.com/youtube/v3/revision_history?id=november-27-2017
917

1018
## 1.4.2 - 2017.05.24
1119

lib/yt/annotations/end_screen.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ def initialize(json = {})
1616
private
1717

1818
def text_in(json)
19-
if json['title']['runs'].nil?
20-
json['title']['simpleText']
21-
else
22-
json['title']['runs'][0]['text']
23-
end
19+
json['title']['simpleText']
2420
end
2521

2622
def ends_at_in(json)

lib/yt/annotations/featured.rb

Lines changed: 0 additions & 32 deletions
This file was deleted.

lib/yt/annotations/for.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
require 'yt/annotations/branding'
22
require 'yt/annotations/card'
33
require 'yt/annotations/end_screen'
4-
require 'yt/annotations/featured'
54
require 'yt/annotations/label'
65
require 'yt/annotations/note'
76
require 'yt/annotations/speech'
@@ -64,7 +63,6 @@ def annotation_class(data)
6463
when 'title' then Annotations::Title
6564
else case data['type']
6665
when 'card' then Annotations::Card
67-
when 'promotion' then Annotations::Featured
6866
when 'pause' then Annotations::Pause
6967
end
7068
end

lib/yt/annotations/note.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def to_link(url)
3535
when '5' then :subscribe
3636
when '6' then :website
3737
when '8' then :crowdfunding
38-
when '12' then :website
3938
end
4039
{url: url['value'], new_window: new_window, type: type}
4140
end

spec/yt/annotations_spec.rb

Lines changed: 28 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -153,86 +153,52 @@
153153
let(:video_id) { 'NNUlOLaupuw' }
154154

155155
it 'returns all the end screen annotations' do
156-
expect(annotations.size).to be 5 # [0] is Featured
156+
expect(annotations.size).to be 4
157+
158+
expect(annotations[0]).to be_a Yt::Annotations::EndScreen
159+
expect(annotations[0].starts_at).to be 25.312
160+
expect(annotations[0].ends_at).to be 35.005
161+
expect(annotations[0].text).to eq 'PewDiePie'
162+
expect(annotations[0].link).to be_a Hash
163+
expect(annotations[0].link[:url]).to eq 'https://www.youtube.com/channel/UC-lHJZR3Gqxm24_Vd_AJ5Yw'
164+
expect(annotations[0].link[:type]).to be :channel
165+
expect(annotations[0].link[:new_window]).to be true
157166

158167
expect(annotations[1]).to be_a Yt::Annotations::EndScreen
159-
expect(annotations[1].starts_at).to be 25.312
168+
expect(annotations[1].starts_at).to be 25.962
160169
expect(annotations[1].ends_at).to be 35.005
161-
expect(annotations[1].text).to eq 'PewDiePie'
170+
expect(annotations[1].text).to eq 'T-Shirt Shop for Geeks, Gamer, Nerds'
162171
expect(annotations[1].link).to be_a Hash
163-
expect(annotations[1].link[:url]).to eq 'https://www.youtube.com/channel/UC-lHJZR3Gqxm24_Vd_AJ5Yw'
164-
expect(annotations[1].link[:type]).to be :channel
172+
expect(annotations[1].link[:url]).to eq 'https://3dsupply.de/en/'
173+
expect(annotations[1].link[:type]).to be :website
165174
expect(annotations[1].link[:new_window]).to be true
166175

167176
expect(annotations[2]).to be_a Yt::Annotations::EndScreen
168-
expect(annotations[2].starts_at).to be 25.962
169-
expect(annotations[2].ends_at).to be 35.005
170-
expect(annotations[2].text).to eq 'T-Shirt Shop for Geeks, Gamer, Nerds'
177+
expect(annotations[2].starts_at).to be 26.741
178+
expect(annotations[2].ends_at).to be 35.015
179+
expect(annotations[2].text).to eq 'PSY - GANGNAM STYLE(강남스타일) M/V'
171180
expect(annotations[2].link).to be_a Hash
172-
expect(annotations[2].link[:url]).to eq 'https://3dsupply.de/en/'
173-
expect(annotations[2].link[:type]).to be :website
174-
expect(annotations[2].link[:new_window]).to be true
181+
expect(annotations[2].link[:url]).to eq 'https://www.youtube.com/watch?v=9bZkp7q19f0'
182+
expect(annotations[2].link[:type]).to be :video
183+
expect(annotations[2].link[:new_window]).to be false
175184

176185
expect(annotations[3]).to be_a Yt::Annotations::EndScreen
177-
expect(annotations[3].starts_at).to be 26.741
178-
expect(annotations[3].ends_at).to be 35.015
179-
expect(annotations[3].text).to eq 'PSY - GANGNAM STYLE(강남스타일) M/V'
186+
expect(annotations[3].starts_at).to be 27.287
187+
expect(annotations[3].ends_at).to be 35.031
188+
expect(annotations[3].text).to eq 'First public playlist'
180189
expect(annotations[3].link).to be_a Hash
181-
expect(annotations[3].link[:url]).to eq 'https://www.youtube.com/watch?v=9bZkp7q19f0'
182-
expect(annotations[3].link[:type]).to be :video
190+
expect(annotations[3].link[:url]).to include 'list=PL-LeTutc9GRKD3yBDhnRF_yE8UTaQI5Jf'
191+
expect(annotations[3].link[:type]).to be :playlist
183192
expect(annotations[3].link[:new_window]).to be false
184-
185-
expect(annotations[4]).to be_a Yt::Annotations::EndScreen
186-
expect(annotations[4].starts_at).to be 27.287
187-
expect(annotations[4].ends_at).to be 35.031
188-
expect(annotations[4].text).to eq 'First public playlist'
189-
expect(annotations[4].link).to be_a Hash
190-
expect(annotations[4].link[:url]).to include 'list=PL-LeTutc9GRKD3yBDhnRF_yE8UTaQI5Jf'
191-
expect(annotations[4].link[:type]).to be :playlist
192-
expect(annotations[4].link[:new_window]).to be false
193193
end
194194
end
195195

196-
context 'given another video with endscreen' do
196+
context 'given another video with end screen' do
197197
let(:video_id) { 'EuqmXkjhisE' }
198198

199199
it 'returns an end screen annotation with subscribe type' do
200-
expect(annotations[1]).to be_a Yt::Annotations::EndScreen
201-
expect(annotations[1].link[:type]).to be :subscribe
202-
end
203-
end
204-
205-
context 'given a video without cards and with a featured playlist' do
206-
let(:video_id) { 'GFxm7khsS3g' }
207-
208-
it 'also returns the featured playlist' do
209-
expect(annotations.size).to be 1
210-
211-
expect(annotations[0]).to be_a Yt::Annotations::Featured
212-
expect(annotations[0].starts_at).to be 1.0
213-
expect(annotations[0].ends_at).to be 5.0
214-
expect(annotations[0].text).to eq 'Check this playlist: Adorable Kids'
215-
expect(annotations[0].link).to be_a Hash
216-
expect(annotations[0].link[:url]).to include 'list=PLuW4g7xujBWfU26JUTW1DGs3hk4LD5KaL'
217-
expect(annotations[0].link[:type]).to be :playlist
218-
expect(annotations[0].link[:new_window]).to be true
219-
end
220-
end
221-
222-
context 'given a video without cards and with a featured video' do
223-
let(:video_id) { 'PaOOnucHLA4' }
224-
225-
it 'also returns the featured video' do
226-
expect(annotations.size).to be 1
227-
228-
expect(annotations[0]).to be_a Yt::Annotations::Featured
229-
expect(annotations[0].starts_at).to be 0.0
230-
expect(annotations[0].ends_at).to be 3.0
231-
expect(annotations[0].text).to eq 'Check out this video: Me at the zoo'
232-
expect(annotations[0].link).to be_a Hash
233-
expect(annotations[0].link[:url]).to include 'v=jNQXAC9IVRw'
234-
expect(annotations[0].link[:type]).to be :video
235-
expect(annotations[0].link[:new_window]).to be true
200+
expect(annotations[2]).to be_a Yt::Annotations::EndScreen
201+
expect(annotations[2].link[:type]).to be :subscribe
236202
end
237203
end
238204

0 commit comments

Comments
 (0)