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
-
.has_brand_anchoring?(video_id, brand) ⇒ Boolean
Audit brand anchoring of a video.
-
.has_info_cards?(video_id) ⇒ Boolean
Audit any info card of a video.
-
.has_link_to_own_channel?(video_id) ⇒ Boolean
Audit youtube association of a video.
-
.has_subscribe_annotations?(video_id) ⇒ Boolean
Audit any subscribe annotation of a video.
Class Method Details
.has_brand_anchoring?(video_id, brand) ⇒ Boolean
Audit brand anchoring of a video
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
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 |
.has_link_to_own_channel?(video_id) ⇒ Boolean
Audit youtube association of a video
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
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 |