Module: OpenDMM::Maker::Moodyz::Parser

Defined in:
lib/opendmm/makers/moodyz.rb

Class Method Summary collapse

Class Method Details

.parse(content) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/opendmm/makers/moodyz.rb', line 23

def self.parse(content)
  page_uri = content.request.last_uri
  html = Nokogiri::HTML(content)
  specs = Utils.hash_by_split(html.xpath('//*[@id="nabi_information"]/ul/li[1]/dl/dd').map(&:text)).merge(
          Utils.hash_by_split(html.xpath('//*[@id="nabi_information"]/ul/li').map(&:text)[1..-1]))
  return {
    actresses:       html.xpath('//*[@id="works"]/dl/dt').map(&:text),
    code:            specs['品番'],
    cover_image:     html.at_xpath('//*[@id="works"]/span/a/p/img')['src'].gsub(/pm.jpg$/, 'pl.jpg'),
    description:     html.xpath('//*[@id="works"]/dl/dd').text,
    directors:       specs['▪監督'].split,
    genres:          specs['▪ジャンル'].split('/'),
    label:           specs['▪レーベル'],
    movie_length:    specs['収録時間'],
    page:            page_uri.to_s,
    release_date:    specs['発売日'],
    sample_images:   html.xpath('//*[@id="sample-pic"]/li/a/img').map { |img| img['src'].gsub(/js(?=-\d+\.jpg$)/, 'jp') },
    series:          specs['▪シリーズ'],
    thumbnail_image: html.at_xpath('//*[@id="works"]/span/a/p/img')['src'],
    title:           html.xpath('//*[@id="main"]/ul[2]/h3/dl/dd/h2').text,
  }
end