lib/client.rb in hail_hydra-0.1.0 vs lib/client.rb in hail_hydra-0.2.0
- old
+ new
@@ -23,25 +23,33 @@
def parse_search_results(html_text)
nodes = Nokogiri::HTML(html_text)
cells = []
table = nodes.search('table')
- #require 'pry'
- #binding.pry
+
table.search('tr').each do |tr|
cells.push(tr.search('th, td'))
end
+
torrents = []
+ descriptions = nodes.css('font.detDesc')
1.upto cells.length-1 do |i|
torrent = HailHydra::Torrent.new()
torrent.name = cells[i][1].children[1].children[1].children[0].content
torrent.url = @domain + cells[i][1].children[1].children[1].attributes["href"].value
torrent.magnet_link = cells[i][1].children[3].attributes["href"].value
torrent.seeders = cells[i][2].children[0].content
torrent.leechers = cells[i][3].children[0].content
+
+ # extracting the uploaded by, at and size is a bit trickier
+ info_line = descriptions[i-1].text.gsub("\u00A0", "---").split(",").map(&:strip)
+ torrent.uploaded_at = info_line[0].split(" ")[1].gsub("---", " ")
+ torrent.size = info_line[1].split(" ")[1].gsub("---", " ")
+ torrent.uploaded_by = info_line[2].split(" ")[2]
+
torrents.push torrent
end
return torrents
end
@@ -64,6 +72,6 @@
'Referer' => @domain,
'Cookie' => cookie
}
end
end
-end
\ No newline at end of file
+end