Class: IRS::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/metadata.rb

Class Method Summary collapse

Class Method Details

.find_album(song, artist) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/metadata.rb', line 25

def find_album(song, artist)
  tracks = RSpotify::Track.search(song + " " + artist)
  tracks.each do |track|
    if track.name.include?(song)
      if track.artists[0].name.include?(artist)
        return track.album
      end
    end
  end
  return
end

.parse_genre(genres) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/metadata.rb', line 9

def parse_genre(genres)
  if genres != []
    genres.reverse!
    genres.map!{|g| g.tr(" - ", " ").tr("-", " ")}


    single = genres.sort_by{|g| g.split.size}[0]

    return IRS::Utils.capitalize_all(single) if !(single.split.size > 1)

    genres.map!{|g| g if g.split("-").size <= 1}.compact

    return IRS::Utils.capitalize_all(genres[0])
  end
end