Class: Karaoke::Song::Genius
- Inherits:
-
Base
- Object
- Base
- Karaoke::Song::Genius
show all
- Defined in:
- lib/karaoke/song/genius.rb
Instance Attribute Summary
Attributes inherited from Base
#lyrics_url
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Class Method Details
.matches?(lyrics_url) ⇒ Boolean
6
7
8
|
# File 'lib/karaoke/song/genius.rb', line 6
def self.matches?(lyrics_url)
URI.parse(lyrics_url).host.end_with?("genius.com") end
|
Instance Method Details
#artist ⇒ Object
10
11
12
|
# File 'lib/karaoke/song/genius.rb', line 10
def artist
@artist ||= tracking_data["Primary Artist"] || tracking_data["Primary Arist"]
end
|
#lyrics ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/karaoke/song/genius.rb', line 18
def lyrics
return @lyrics if defined?(@lyrics)
el = document.css(".lyrics p").first
return @lyrics = nil unless el
el.css("a").each { |a_el| a_el.replace(a_el.inner_html) }
@lyrics = clean_html(el.inner_html)
end
|
#title ⇒ Object
14
15
16
|
# File 'lib/karaoke/song/genius.rb', line 14
def title
@title ||= tracking_data["Title"]
end
|