Sha256: 55e35ffe9ef978088bbb02d8265a1632e52e4bb4adbf469d404c2d59018a8be1

Contents?: true

Size: 710 Bytes

Versions: 2

Compression:

Stored size: 710 Bytes

Contents

require 'httparty'

class Sabnzbd
    
  include HTTParty
  base_uri 'localhost:8080'

  def self.add_url(url, apikey, category = nil, job_options = nil, script = nil)
    options          = { :apikey => apikey }
    options[:name]   = url
    options[:cat]    = category if !category.blank?
    options[:pp]     = job_options if !job_options.blank?
    options[:script] = script if !script.blank?
    verify api_call(:addurl, options)
  rescue
    $stdout.print "connection problem! sabnzbd launched?"
    false
  end

private
  
  def self.verify(text)
    text.strip == "ok"
  end

  def self.api_call(mode, opts = {})
    opts.merge!(:mode => mode.to_s)
    get("/sabnzbd/api", :query => opts)
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
autotvnzb-0.1.1 lib/sabnzbd.rb
autotvnzb-0.1.0 lib/sabnzbd.rb