Class: Saber::Tracker2::What

Inherits:
Base
  • Object
show all
Defined in:
lib/saber/tracker2/what.rb

Constant Summary collapse

BASE_URL =
"https://what.cd"
TYPES =
{
  "music" => "Musics",
  "application" => "Applications",
  "ebook" => "E-Books",
  "audiobook" => "Audiobooks",
  "elearning-video" => "E-Learning Videos",
  "comedy" => "Comedy",
  "comic" => "Comics"
}
FIELDS =
{ 
  "ebook" => { 
    torrent_file: "//input[@name='file_input']",
    title: "//input[@name='title']",
    tags: "//input[@name='tags']",
    image: "//input[@name='image']",
    description: "//textarea[@name='desc']"
  }
}

Instance Attribute Summary

Attributes inherited from Base

#agent, #name, #options

Instance Method Summary collapse

Methods inherited from Base

inherited, #initialize, #upload

Constructor Details

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

Instance Method Details

#do_upload(file, info) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/saber/tracker2/what.rb', line 26

def do_upload(file, info)
  #path = info["group_id"] ? "/upload.php?group_id=#{info['group_id']}" : "/upload.php"

  agent.goto "#{BASE_URL}/upload.php"
   %r~/upload\.php~

  form = agent.form(action: "")
  form.select(name: "type").select info[:type2]
  form.input(value: "Find Info").wait_while_present unless info[:type] == "music"
  sleep 0.1

  FIELDS[info[:type]].each {|key, selector|
    form.quick_set(selector, info[key])
  }

  form.submit()

  if agent.url =~ %r~/upload\.php~
    return false
  else
    return true
  end
end