Sha256: 42f074f803862e4f3993e3ad5d1a6c3987946d38ebecffe2d91c674dc0aad443

Contents?: true

Size: 769 Bytes

Versions: 3

Compression:

Stored size: 769 Bytes

Contents

require 'yt/video_audit/base'

module Yt
  module VideoAudit
    # Count how many videos have video description includes
    # a link to its own channel.
    class YoutubeAssociation < Base
      def title
        'YouTube Association'
      end

      def description
        'The number of videos where the description has a link to its own channel'
      end

    private

      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

      def channel_id(url)
        url.id
      rescue Yt::NoItemsError
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yt-audit-0.6.0 lib/yt/video_audit/youtube_association.rb
yt-audit-0.5.5 lib/yt/video_audit/youtube_association.rb
yt-audit-0.5.4 lib/yt/video_audit/youtube_association.rb