Sha256: fb44809ed6deb00ea3000c5333ed9b15dd512bdc0f39690eb44cda393ea90b51

Contents?: true

Size: 764 Bytes

Versions: 4

Compression:

Stored size: 764 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 with 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

4 entries across 4 versions & 1 rubygems

Version Path
yt-audit-0.5.3 lib/yt/video_audit/youtube_association.rb
yt-audit-0.5.2 lib/yt/video_audit/youtube_association.rb
yt-audit-0.5.1 lib/yt/video_audit/youtube_association.rb
yt-audit-0.5.0 lib/yt/video_audit/youtube_association.rb