Class: Isohunt
- Inherits:
-
Object
- Object
- Isohunt
- Defined in:
- lib/isohunt-es/isohunt.rb
Instance Method Summary collapse
-
#initialize ⇒ Isohunt
constructor
A new instance of Isohunt.
- #search(query) ⇒ Object
Constructor Details
#initialize ⇒ Isohunt
Returns a new instance of Isohunt.
2 3 |
# File 'lib/isohunt-es/isohunt.rb', line 2 def initialize end |
Instance Method Details
#search(query) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/isohunt-es/isohunt.rb', line 5 def search(query) items = JSON.parse(open("http://isohunt.com/js/json.php?ihq=#{CGI.escape(query.capitalize)}&rows=20&sort=seeds").read) pattern = query.split(" ").map { |e| /#{Regexp.escape(e)}/i } results = [] items["items"]["list"].each do |item| title = item["title"].gsub(/<\/?[^>]*>/, "") next unless pattern.find {|p| title.match(p).nil? }.nil? results << {:title => title, :url => item["enclosure_url"], :size => item["size"], :seeds => item["Seeds"], :leechers => item["leechers"], :votes => item["votes"]} end results end |