Class: Nanny::Torcache
- Inherits:
-
Object
- Object
- Nanny::Torcache
- Defined in:
- lib/nanny/torcache.rb
Defined Under Namespace
Classes: HashNotFound
Constant Summary collapse
- TORCACHE_URL =
Addressable::Template.new("http://torcache.net/torrent/{hash}.torrent")
- TORRAGE_URL =
Addressable::Template.new("http://torrage.com/torrent/{hash}.torrent")
Class Method Summary collapse
Class Method Details
.url_for(hash) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/nanny/torcache.rb', line 10 def self.url_for(hash) [ TORCACHE_URL, TORRAGE_URL ].each do |template| begin url = template.(hash: hash.upcase).to_s HTTPClient.headers(url) return url rescue HTTPClient::Exception end end raise Torcache::HashNotFound end |