0
-### http://v3.newzbin.com
0
-# open a new newzbin connection, and search it with the method provided. Pass it vars to narrow the search
0
-# Download the nzb using the provided get_nzb method
0
-# newz = Newzbin::Connection.new('username', 'password')
0
-# nzbs = newz.search(:q => 'casino royale', :ps_rb_video_format => 131072)
0
-# newz.get_nzb(nzbs.first.id)
0
@@ -21,30 +6,31 @@ require 'xmlsimple'
0
- def initialize(username=nil, password=nil)
0
- @host = 'http://v3.newzbin.com'
0
+ attr_accessor :host, :search_path, :dnzb_path, :username, :password, :nzbSmoke, :nzbSessionID
0
+ def initialize(options={})
0
+ self.host = 'http://v3.newzbin.com'
0
+ self.search_path = '/search/'
0
+ self.dnzb_path = '/dnzb'
0
+ self.username = options[:username]
0
+ self.password = options[:password]
0
+ self.nzbSmoke = options[:nzbSmoke]
0
+ self.nzbSessionID = options[:nzbSessionID]
0
Net::HTTP.start('v3.newzbin.com') do |http|
0
req = Net::HTTP::Get.new(url)
0
- req.add_field 'Cookie', 'NzbSmoke=Px0oEtmhh%24APwIHmiPyBRJTjBcfOw7HPbCiho%3D; NzbSessionID=24c3e702b9caeb9c490e831042864b85'
0
+ req.add_field 'Cookie', "NzbSmoke=#{self.nzbSmoke}; NzbSessionID=#{self.nzbSessionID}" if self.nzbSmoke && self.nzbSessionID
0
response = http.request(req)
0
def request_url(params)
0
- # http://v3.newzbin.com/search/?q=speed&searchaction=Search&fpn=p&category=6&area=-1ps_rb_video_format=131072&sort=ps_edit_date&order=desc&areadone=-1&feed=rss&
0
params.delete_if {|key, value| (value == nil || value == '') }
0
- url = "#{@search}?searchaction=Search&fpn=p&area=-1&order=desc&areadone=-1&feed=rss&u_nfo_posts_only=0&sort=ps_edit_date&order=desc&u_url_posts_only=0&u_comment_posts_only=0&u_v3_retention=9504000"
0
+ url = "#{self.search_path}?searchaction=Search&fpn=p&area=-1&order=desc&areadone=-1&feed=rss&u_nfo_posts_only=0&sort=ps_edit_date&order=desc&u_url_posts_only=0&u_comment_posts_only=0&u_v3_retention=9504000&commit=search"
0
params.each_key do |key| url += "&#{key}=" + CGI::escape(params[key].to_s) end if params
0
@@ -65,19 +51,12 @@ module Newzbin
0
- http = Net::HTTP.new(@host)
0
+ http = Net::HTTP.new(self.host)
0
- http.request_post('/dnzb', "username=#{@username}&password=#{@password}&reportid=#{id}") {|response|
0
+ http.request_post(self.dnzb_path, "username=#{self.username}&password=#{self.password}&reportid=#{id}") {|response|
0
p response['content-type']
0
- # response.read_body do |str| # read body now
0
- # response = http.post(@dnzb, "username=#{@username}&password=#{@password}&reportid=#{id}")
0
- # response = Net::HTTP.post_form(URI.parse("#{@host}#{@dnzb}"),{:username => @username, :password => @password, :reportid => id})
0
case response["x-dnzb-rcode"].to_i
0
@@ -93,7 +72,7 @@ module Newzbin
0
- response = Net::HTTP.post_form(URI.parse("#{@host}#{@dnzb}"),{:username => @username, :password => @password, :reportid => id})
0
+ response = Net::HTTP.post_form(URI.parse("#{self.host}#{self.dnzb_path}"),{:username => self.username, :password => self.password, :reportid => id})
0
case response["x-dnzb-rcode"].to_i
0
@@ -116,25 +95,24 @@ module Newzbin
0
attr_accessor :pub_date, :size_in_bytes, :category, :attributes, :title, :info_url, :id
0
def initialize(details)
0
- @pub_date = details["pubDate"]
0
- @size_in_bytes = details["size"]["content"]
0
- @category = details["category"]
0
- @title = details["title"]
0
- @info_url = details["moreinfo"]
0
+ self.pub_date = details["pubDate"]
0
+ self.size_in_bytes = details["size"]["content"]
0
+ self.category = details["category"]
0
+ self.title = details["title"]
0
+ self.id = details["id"]
0
+ self.info_url = details["moreinfo"]
0
case details["attributes"]["attribute"].class.name
0
details["attributes"]["attribute"].each do |attri|
0
- case @attributes.has_key? attri["type"]
0
+ case self.attributes.has_key? attri["type"]
0
- @attributes[attri["type"]] = attri["content"]
0
+ self.attributes[attri["type"]] = attri["content"]
0
- @attributes[attri["type"]] += ", #{attri["content"]}"
0
+ self.attributes[attri["type"]] += ", #{attri["content"]}"
Comments
No one has commented yet.