Module: GMusic::DownloadInfoParser

Defined in:
lib/gmusic/parser.rb

Class Method Summary collapse

Class Method Details

.parse(url) ⇒ Object


40
41
42
43
44
45
46
47
48
49
50
# File 'lib/gmusic/parser.rb', line 40

def parse url
  result = {}
  doc = Hpricot(open(url))
  begin
    result.merge!({ :size => (doc/'tr.meta-data-tr > td.td-size').first.inner_html })
    result.merge!({ :format => (doc/'tr.meta-data-tr > td.td-format').first.inner_html })
    result.merge!({ :url => (doc/'div.download > a').first.attributes['href'] })
  rescue
    nil
  end
end