Class: Saber::Tracker::STP

Inherits:
Base
  • Object
show all
Defined in:
lib/saber/tracker/stp.rb

Constant Summary collapse

BASE_URL =
"https://stopthepress.es"
LOGIN_CHECK_PATH =
"/inbox.php"
TAG_MAP =
{
  "nonfiction" => "non.fiction"
}

Constants inherited from Base

Base::DELEGATE_METHODS, Base::POPULATE_TYPES

Instance Attribute Summary

Attributes inherited from Base

#agent, #name

Instance Method Summary collapse

Methods inherited from Base

can_populate?, inherited, #initialize, #login, #populate, #upload

Constructor Details

This class inherits a constructor from Saber::Tracker::Base

Instance Method Details

#convert_tags(*tags) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/saber/tracker/stp.rb', line 18

def convert_tags(*tags)
  tags.map{|tag|
    tag = tag.downcase.gsub(/&/, "and").gsub(/\s+/, ".").gsub(/'/, "")

    TAG_MAP.fetch(tag, tag)
  }
end

#exists?(o = {}) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
# File 'lib/saber/tracker/stp.rb', line 11

def exists?(o={})
  url = "/torrents.php?cataloguenumber=#{o[:isbn]}"
  page = agent.get(url)

  not page.at("//*[@id='content']/div[2]/h2[contains(text(), 'Your search did not match anything.')]")
end