lib/yt/annotations/end_screen.rb in yt-annotations-1.4.2 vs lib/yt/annotations/end_screen.rb in yt-annotations-2.0.0

- old
+ new

@@ -14,15 +14,11 @@ end private def text_in(json) - if json['title']['runs'].nil? - json['title']['simpleText'] - else - json['title']['runs'][0]['text'] - end + json['title']['simpleText'] end def ends_at_in(json) json['endMs'].to_i / 1000.0 end @@ -30,16 +26,24 @@ def to_link(json) target_url = case json['style'] when 'WEBSITE' json['endpoint']['urlEndpoint']['url'] when 'PLAYLIST' - "https://www.youtube.com/watch?v=" + - json['endpoint']['watchEndpoint']['videoId'] + - "&list=" + - json['endpoint']['watchEndpoint']['playlistId'] + if json['endpoint']['watchEndpoint'] + "https://www.youtube.com/watch?v=" + + json['endpoint']['watchEndpoint']['videoId'] + + "&list=" + + json['endpoint']['watchEndpoint']['playlistId'] + else + "https://www.youtube.com" + json['endpoint']['urlEndpoint']['url'] + end when 'VIDEO' - "https://www.youtube.com/watch?v=" + - json['endpoint']['watchEndpoint']['videoId'] + if json['endpoint']['watchEndpoint'] + "https://www.youtube.com/watch?v=" + + json['endpoint']['watchEndpoint']['videoId'] + else + "https://www.youtube.com" + json['endpoint']['urlEndpoint']['url'] + end when 'CHANNEL' if json['isSubscribe'] "https://www.youtube.com/channel/" + json['hovercardButton']['subscribeButtonRenderer']['channelId'] else