Class: MetallumCli::Artist

Inherits:
Object
  • Object
show all
Defined in:
lib/metallum-cli/helpers/artist.rb

Class Method Summary collapse

Class Method Details

.show_artist_bands(res, param) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/metallum-cli/helpers/artist.rb', line 29

def self.show_artist_bands(res, param)
  bands = []
  album = []
  album_keys = {0 => "Year", 1 => "Name", 2 => "Role"}
  a = 0
  res.css("div#artist_tab_#{param} div.ui-tabs-panel-content div.member_in_band").each do |band|
    bands.push band.css("h3.member_in_band_name").inner_text
    band.css('table tr td').each_with_index do |item, index|
      i = (index + 3) % 3
      album.push "#{album_keys[i]}: #{item.content.strip.split.join " "}"
      if i == 2
        bands.push album
        album = []
        a += 1
      end
    end
  end
  puts "\n\n////Bands\\\\\\\\"
  bands.each do |band|
    puts band
    puts "\n"
  end
end

.show_artist_page(html, band) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/metallum-cli/helpers/artist.rb', line 4

def self.show_artist_page(html, band)
  # File.write 'out.html', html
  page = Nokogiri::HTML(html)
  artist_values = {}
  biography = []
  artist_keys = {0 => "Location", 1 => "Age", 2 => "Place of origin", 3 => "Gender"}
  page.css('div#member_info dl dd').each_with_index do |item, index|
    artist_values[artist_keys[index]] = item.content.strip.split.join " "
  end
  page.css('div.band_comment').css(".title_comment").remove
  page.css('div.band_comment').each do |item|
    biography.push item.content.strip.split.join " "
  end
  puts "\n\n////#{page.css('h1.band_member_name').first.content}\\\\\\\\"
  artist_values.each do |k, v|
    puts "#{k}: #{v}"
  end
  biography.each do |bio|
    puts bio
  end
  if band
    show_artist_bands page, band
  end
end