Module: Yt::Audit

Defined in:
lib/yt/audit.rb,
lib/yt/audit/version.rb

Constant Summary collapse

VERSION =
"0.1.3"

Class Method Summary collapse

Class Method Details

.has_brand_anchoring?(video_id, brand) ⇒ Boolean

Audit brand anchoring of a video

Parameters:

  • video_id (String)

    the video to audit.

  • brand (String)

    name of the video to audit.

Returns:

  • (Boolean)

    if the video title includes brand name.



19
20
21
22
# File 'lib/yt/audit.rb', line 19

def self.has_brand_anchoring?(video_id, brand)
  video_title = Yt::Video.new(id: video_id).title
  !!video_title[/#{brand}/i]
end

.has_info_cards?(video_id) ⇒ Boolean

Audit any info card of a video

Parameters:

  • video_id (String)

    the video to audit.

Returns:

  • (Boolean)

    if the video has any info card.



9
10
11
12
13
# File 'lib/yt/audit.rb', line 9

def self.has_info_cards?(video_id)
  Yt::Annotations.for(video_id).any? do |annotation|
    annotation.is_a? Yt::Annotations::Card
  end
end

Audit youtube association of a video

Parameters:

  • video_id (String)

    the video to audit.

Returns:

  • (Boolean)

    if the video description has link to its own channel.



36
37
38
39
40
41
# File 'lib/yt/audit.rb', line 36

def self.has_link_to_own_channel?(video_id)
  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

.has_subscribe_annotations?(video_id) ⇒ Boolean

Audit any subscribe annotation of a video

Parameters:

  • video_id (String)

    the video to audit.

Returns:

  • (Boolean)

    if the video has any link to subscribe in the annotations.



27
28
29
30
31
# File 'lib/yt/audit.rb', line 27

def self.has_subscribe_annotations?(video_id)
  Yt::Annotations.for(video_id).any? do |annotation|
    annotation.link && annotation.link[:type] == :subscribe
  end
end