Sha256: 60d49327e2b4ab5c817fea6b6df53de1f92aeee35770107870e5ad0fc358681e
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
require 'yt/annotations/base' module Yt module Annotations # An end screen annotation shows in the last 5 to seconds of the video. class EndScreen < Base # @param [Hash] data the Hash representation of the XML data returned by # YouTube for each end screen of a video. def initialize(json = {}) @text = json['title'] @starts_at = json['startMs'] / 1000.0 @ends_at = ends_at_in json @link = to_link json end private def ends_at_in(json) (json['startMs'] + json['durationMs']) / 1000.0 end def to_link(json) { url: json['targetUrl'], new_window: new_window(json['type']), type: link_type(json) } end def link_type(json) case json['type'] when 'WEBSITE' then :website when 'PLAYLIST' then :playlist when 'VIDEO' then :video when 'CHANNEL' then (json['isSubscribe'] ? :subscribe : :channel) end end def new_window(type) %w(WEBSITE CHANNEL).include? type end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yt-annotations-1.4.0 | lib/yt/annotations/end_screen.rb |