class TorrentFinder::Adapters::DmhyAdapter
Public Class Methods
name()
click to toggle source
name of the adapter
# File lib/torrent-finder/adapters/dmhy_adapter.rb, line 10 def self.name "dmhy" end
Public Instance Methods
list(page=0)
click to toggle source
list recently available torrent
# File lib/torrent-finder/adapters/dmhy_adapter.rb, line 15 def list(page=0) url = page == 0 ? "http://share.dmhy.org/" : "http://share.dmhy.org/topics/list/page/#{(page+1).to_s}" response = HTTParty.get(url) parse_html(response.body) end
search(terms)
click to toggle source
search and return available torrent
# File lib/torrent-finder/adapters/dmhy_adapter.rb, line 22 def search(terms) response = HTTParty.get("http://share.dmhy.org/topics/list", :query => {"keyword" => terms}) parse_html(response.body) end
Protected Instance Methods
parse_html(html)
click to toggle source
# File lib/torrent-finder/adapters/dmhy_adapter.rb, line 28 def parse_html(html) doc = Nokogiri::HTML(html) rows = doc.search("#topic_list tr") rows.collect do |row| title = row.search('td.title').first if title title.search(".tag").remove name = title.search('./a').first.text.strip end link = row.search('a.arrow-magnet').first["href"] rescue nil Torrent.new(name, link) end.select {|row| row.name && row.url && row.url != "" } end