4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/gmusic/parser.rb', line 4
def parse url
songs = []
doc = Hpricot(open(url))
(doc/'#song_list > tbody > tr').each do |tr|
begin
song = {}
id = tr.attributes["id"].gsub(/row/, '')
next if id.include?('snippetRow')
song.merge!({ :id => id })
song.merge!({ :title => (tr/'td.Title > a > b').first.inner_html })
song.merge!({ :artist => (tr/'td.Artist > a').first.inner_html })
song.merge!({ :album => (tr/'td.Album > a').first.inner_html })
songs << song
rescue
end
end
songs
end
|