lib/yt/audit.rb in yt-audit-0.1.3 vs lib/yt/audit.rb in yt-audit-0.1.4

- old
+ new

@@ -37,7 +37,20 @@ video = Yt::Video.new(id: video_id) video.description.split(' ') .select {|word| Yt::URL.new(word).kind == :channel } .any? {|link| Yt::Channel.new(url: link).id == video.channel_id } end + + # Audit end cards of a video + # @param [String] video_id of the video to audit. + # @return [Boolean] if the video has any annotation, other than info cards, + # with a link in it, at the end of video, stays for more than 5 seconds. + def self.has_end_cards?(video_id) + video_duration = Yt::Video.new(id: video_id).duration + Yt::Annotations.for(video_id).any? do |annotation| + !annotation.is_a?(Yt::Annotations::Card) && annotation.link && + annotation.ends_at.ceil == video_duration && + video_duration - annotation.starts_at > 5 + end + end end end