Skip to content

Commit 132362e

Browse files
author
claudiofullscreen
authored
Merge pull request #22 from kangkyu/endscreen-title
Update endscreen text by YouTube change
2 parents edd127e + 56cbcd1 commit 132362e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/yt/annotations/end_screen.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,22 @@ class EndScreen < Base
77
# @param [Hash] json the Hash representation of the XML data returned by
88
# YouTube for each end screen of a video.
99
def initialize(json = {})
10-
@text = json['title']['runs'][0]['text']
10+
@text = text_in json
1111
@starts_at = json['startMs'].to_i / 1000.0
1212
@ends_at = ends_at_in json
1313
@link = to_link json
1414
end
1515

1616
private
1717

18+
def text_in(json)
19+
if json['title']['runs'].nil?
20+
json['title']['simpleText']
21+
else
22+
json['title']['runs'][0]['text']
23+
end
24+
end
25+
1826
def ends_at_in(json)
1927
json['endMs'].to_i / 1000.0
2028
end

0 commit comments

Comments
 (0)