class Yt::VideoAudit::YoutubeAssociation

Count how many videos have video description includes a link to its own channel.

Public Instance Methods

description() click to toggle source
# File lib/yt/video_audit/youtube_association.rb, line 12
def description
  'The number of videos where the description has a link to its own channel'
end
title() click to toggle source
# File lib/yt/video_audit/youtube_association.rb, line 8
def title
  'YouTube Association'
end

Private Instance Methods

channel_id(url) click to toggle source
# File lib/yt/video_audit/youtube_association.rb, line 27
def channel_id(url)
  url.id
rescue Yt::NoItemsError
end
valid?(video) click to toggle source
# File lib/yt/video_audit/youtube_association.rb, line 18
def valid?(video)
  video.description.split(' ').any? do |word|
    if Yt::URL::CHANNEL_PATTERNS.any?{|pattern| word.match pattern}
      url = Yt::URL.new word
      url.kind == :channel && channel_id(url) == video.channel_id
    end
  end
end