Class: Saber::Tracker::BB

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

Overview

DOESN’T WORK for mechanize does not support javascript.

Constant Summary collapse

BASE_URL =
"https://baconbits.org"
LOGIN_CHECK_PATH =
"/inbox.php"
FIELDS =
{ 
  "Musics" => {
    "file_input" => :file_upload,
    "type" => :select_list,
    "artist" => :text,
    "title" => :text,
    "remaster" => :check_box,
    "year" => :text,
    "scene" => :checkbox,
    "format" => :select_list,
    "bitrate" => :select_list,
    "media" => :select_list,
    "tags" => :text,
    "image" => :text,
    "album_desc" => :text,
    "release_desc" => :text,
  },

  "Applications" => {
    "file_input" => :file_upload,
    "type" => :select_list,
    "title" => :text,
    "tags" => :text,
    "desc" => :text,
    "image" => :text,
    "scene" => :checkbox,
  },

  "E-Books" => {
    "file_input" => :file_upload,
    "type" => :select_list,
    "title" => :text,
    "tags" => :text,
    "isbn" => :text,
    "desc" => :text,
    "image" => :text,
    "scene" => :checkbox,
  },

  "Audiobooks" => {
    "file_input" => :file_upload,
    "type" => :select_list,
    "title" => :text,
    "year" => :text,
    "format" => :select_list,
    "bitrate" => :select_list,
    "tags" => :text,
    "image" => :text,
    "album_desc" => :text,
    "release_desc" => :text,
  },

  "E-Learning Videos" => {
    "type" => :select_list,
    "title" => :text,
    "tags" => :text,
    "isbn" => :text,
    "desc" => :text,
    "image" => :text,
    "scene" => :checkbox,
  },

  "Magazines" => {
    "file_input" => :file_upload,
    "type" => :select_list,
    "title" => :text,
    "tags" => :text,
    "desc" => :text,
    "image" => :text,
    "scene" => :checkbox,
  },

  "Comics" => {
    "file_input" => :file_upload,
    "type" => :select_list,
    "title" => :text,
    "tags" => :text,
    "isbn" => :text,
    "desc" => :text,
    "image" => :text,
    "scene" => :checkbox,
  },

  "Anime" => {
    "file_input" => :file_upload,
    "type" => :select_list,
    "title" => :text,
    "tags" => :text,
    "desc" => :text,
    "image" => :text,
    "scene" => :checkbox,
  },

  "Movies" => {
    "file_input" => :file_upload,
    "type" => :select_list,
    "title" => :text,
    "source" => :select_list,
    "videoformat" => :select_list,
    "audioformat" => :select_list,
    "container" => :select_list,
    "resolution" => :select_list,
    "remaster_title" => :text,
    "year" => :text,
    "tags" => :text,
    "desc" => :text,
    "release_info" => :text,
    "screenshot1" => :text,
    "screenshot2" => :text,
    "image" => :text,
    "scene" => :checkbox,
  },

  "TV" => {
    "file_input" => :file_upload,
    "type" => :select_list,
    "title" => :text,
    "tags" => :text,
    "desc" => :text,
    "image" => :text,
    "scene" => :checkbox,
  },

  "Games - PC" => {
    "file_input" => :file_upload,
    "type" => :select_list,
    "title" => :text,
    "tags" => :text,
    "desc" => :text,
    "image" => :text,
    "scene" => :checkbox,
  },

  "Games - Console" => {
    "file_input" => :file_upload,
    "type" => :select_list,
    "title" => :text,
    "tags" => :text,
    "desc" => :text,
    "image" => :text,
    "scene" => :checkbox,
  },

  "Documentaries" => {
    "file_input" => :file_upload,
    "type" => :select_list,
    "title" => :text,
    "source" => :select_list,
    "videoformat" => :select_list,
    "audioformat" => :select_list,
    "container" => :select_list,
    "resolution" => :select_list,
    "remaster_title" => :text,
    "year" => :text,
    "tags" => :text,
    "desc" => :text,
    "release_info" => :text,
    "screenshot1" => :text,
    "screenshot2" => :text,
    "image" => :text,
    "scene" => :checkbox,
  },

  "Misc" => {
    "file_input" => :file_upload,
    "type" => :select_list,
    "title" => :text,
    "tags" => :text,
    "desc" => :text,
    "image" => :text,
    "scene" => :checkbox,
  },
}

Constants inherited from Base

Saber::Tracker::Base::DELEGATE_METHODS, Saber::Tracker::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

#do_upload(file, info) ⇒ Boolean

Upload one torrent file to the site.

Parameters:

  • file (String)

    a filename

  • info (Optimism)

    comes from <file>.yml data file.

Returns:

  • (Boolean)

    result-code



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/saber/tracker/bb.rb', line 188

def do_upload(file, info)
  info["file_input"] = "#{file}.torrent"

  agent.get("/upload.php") {|p|
    ret = p.form_with(action: "") {|f|
      FIELDS[info.type].each {|k,t|
        f.set(t, k, info[k])
      }
    }.submit

    if ret.uri.path == "/upload.php"
      msg = ReverseMarkdown.parse(ret.at("//*[@id='content']/div[2]/p[2]"))
      Saber.ui.error "ERROR: #{msg.to_s.strip}\n"
      return false
    else
      return true
    end
  }
end