Class: TorrentFinder::Adapters::NyaaAdapter

Inherits:
Adapter
  • Object
show all
Defined in:
lib/torrent-finder/adapters/nyaa_adapter.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Adapter

inherited, #name

Class Method Details

.nameObject

name of the adapter



9
10
11
# File 'lib/torrent-finder/adapters/nyaa_adapter.rb', line 9

def self.name
  "nyaa"
end

Instance Method Details

#list(page = 0) ⇒ Object

list recently available torrent



14
15
16
17
18
# File 'lib/torrent-finder/adapters/nyaa_adapter.rb', line 14

def list(page=0)
  url = page == 0 ? "http://www.nyaa.se/" : "http://www.nyaa.se/?offset=#{(page).to_s}"
  response = HTTParty.get(url)
  parse_html(response.body)
end

#search(terms) ⇒ Object

search and return available torrent



21
22
23
24
# File 'lib/torrent-finder/adapters/nyaa_adapter.rb', line 21

def search(terms)
  response = HTTParty.get("http://www.nyaa.se/?page=search&term=", :query => {"term" => terms})
  parse_html(response.body)
end