Sha256: f039a92ff77f4443302287a2c5200ed388783b50bb5466b84a342c24562c6c9b
Contents?: true
Size: 1.81 KB
Versions: 5
Compression:
Stored size: 1.81 KB
Contents
module Saber module Tracker # DON'T WORK for mechanize does not support javascript. class What < Base @@BASE_URL = "https://what.cd" @@LOGIN_CHECK_PATH = "/inbox.php" FIELDS = { "E-Books" => { "file_input" => :file_upload, "type" => :select_list, "title" => :text, "tags" => :text, "image" => :text, "desc" => :text } } def do_upload(file, info) info["file_input"] = "#{file}.torrent" path = info["group_id"] ? "/upload.php?group_id=#{info['group_id']}" : "/upload.php" agent.get(path) {|p| ret = p.form_with(action: "") {|f| FIELDS[info.type].each {|k,t| f.set(t, k, info[k]) } }.submit # error if ret.uri.path =~ %r~^/upload.php~ msg = ReverseMarkdown.parse(ret.at("//*[@id='content']/div[2]/p[2]")) Saber.ui.error "ERROR:\n#{msg}" return false else return true end } end protected def do_login_with_username(username) agent.get("/login.php") {|p| ret = p.form_with(action: "login.php" ) {|f| # error unless f Saber.ui.error! p.at("//body").inner_text end f.username = username || ask("Username: ") f.password = ask("Password: "){|q| q.echo = false} f.checkbox(name: "keeplogged").check }.submit # error if ret.uri.path == "/login.php" msg = ret.at("//*[@id='loginform']/span[2]").inner_text Saber.ui.error "Failed. You have #{msg} attempts remaining." return false else return true end } end end end end
Version data entries
5 entries across 5 versions & 1 rubygems