public this repo is viewable by everyone
Description: Your friendly neighborhood nzb downloader
Clone URL: git://github.com/maddox/pyrot.git
Click here to lend your support to: pyrot and make a donation at www.pledgie.com !
Merge branch 'master' of git@github.com:maddox/pyrot
maddox (author)
2 days ago
commit  cbc72c7efdfaa5706a17121ed0fda9744def21c0
tree    74a0b2ecacb15b4862ebeac1eb9e677b71cc5293
parent  10e0bd09fa963635be4fea31ead4dc1132c37b72 parent  0a131f384f35df7fb8999da8c65db1b99a04abf9
...
50
51
52
53
54
 
 
55
56
57
...
50
51
52
 
 
53
54
55
56
57
0
@@ -50,8 +50,8 @@ class ApplicationController < ActionController::Base
0
   end
0
     
0
   def get_nzb(url)
0
- newzbin = Newzbin::Connection.new(PYROT_CONFIG['newzbin']['login'], PYROT_CONFIG['newzbin']['password'])
0
- newzbin.get_nzb(params[:url].match(/\d\d\d+/))
0
+ newzbin_conn = Newzbin::Connection.new(:username => PYROT_CONFIG['newzbin']['login'], :password => PYROT_CONFIG['newzbin']['password'])
0
+ newzbin_conn.get_nzb(params[:url].match(/\d\d\d+/))
0
   end
0
 
0
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
...
21
22
23
24
25
26
27
28
29
30
 
 
 
 
 
 
 
 
 
 
31
32
33
34
35
36
 
37
38
39
40
41
42
43
44
45
46
47
 
48
49
50
...
65
66
67
68
 
69
70
 
71
72
73
74
75
76
77
78
79
80
81
82
83
...
93
94
95
96
 
97
98
99
...
116
117
118
119
120
121
122
123
124
125
126
 
 
 
 
 
 
 
127
128
129
130
131
132
133
 
134
135
 
136
137
 
138
139
140
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
...
6
7
8
 
 
 
 
 
 
 
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
24
25
 
26
27
28
29
30
31
 
32
 
33
34
35
36
...
51
52
53
 
54
55
 
56
57
58
 
 
 
59
 
 
 
 
60
61
62
...
72
73
74
 
75
76
77
78
...
95
96
97
 
 
 
 
 
 
 
 
98
99
100
101
102
103
104
105
106
107
108
109
110
 
111
112
 
113
114
 
115
116
117
118
0
@@ -1,18 +1,3 @@
0
-####### Newzbin API
0
-### http://v3.newzbin.com
0
-
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
-#
0
-# newz = Newzbin::Connection.new('username', 'password')
0
-# nzbs = newz.search(:q => 'casino royale', :ps_rb_video_format => 131072)
0
-#
0
-# puts nzbs.inspect
0
-#
0
-# newz.get_nzb(nzbs.first.id)
0
-
0
-
0
-
0
 require 'rubygems'
0
 require 'net/http'
0
 require 'cgi'
0
@@ -21,30 +6,31 @@ require 'xmlsimple'
0
 module Newzbin
0
   
0
   class Connection
0
-
0
- def initialize(username=nil, password=nil)
0
- @host = 'http://v3.newzbin.com'
0
- @search = '/search/'
0
- @dnzb = '/dnzb'
0
- @username = username
0
- @password = password
0
+ attr_accessor :host, :search_path, :dnzb_path, :username, :password, :nzbSmoke, :nzbSessionID
0
+
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
     end
0
 
0
     def http_get(url)
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
- # puts response.body
0
         response.body
0
       end
0
       
0
     end
0
 
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
       url
0
     end
0
@@ -65,19 +51,12 @@ module Newzbin
0
     end
0
     
0
     def get_name(id)
0
- http = Net::HTTP.new(@host)
0
+ http = Net::HTTP.new(self.host)
0
       
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.status
0
         p response['content-type']
0
- # response.read_body do |str| # read body now
0
- # print str
0
- # end
0
       }
0
-
0
- # response = http.post(@dnzb, "username=#{@username}&password=#{@password}&reportid=#{id}")
0
-
0
- # response = Net::HTTP.post_form(URI.parse("#{@host}#{@dnzb}"),{:username => @username, :password => @password, :reportid => id})
0
 
0
       case response["x-dnzb-rcode"].to_i
0
       when 200
0
@@ -93,7 +72,7 @@ module Newzbin
0
     end
0
 
0
     def get_nzb(id)
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
 
0
       case response["x-dnzb-rcode"].to_i
0
       when 200
0
@@ -116,25 +95,24 @@ module Newzbin
0
     attr_accessor :pub_date, :size_in_bytes, :category, :attributes, :title, :info_url, :id
0
 
0
     def initialize(details)
0
- #puts details.inspect
0
- @pub_date = details["pubDate"]
0
- @size_in_bytes = details["size"]["content"]
0
- @category = details["category"]
0
- @title = details["title"]
0
- @id = details["id"]
0
- @info_url = details["moreinfo"]
0
- @attributes = {}
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
+ self.attributes = {}
0
       
0
 
0
       case details["attributes"]["attribute"].class.name
0
       when "Array"
0
         details["attributes"]["attribute"].each do |attri|
0
 
0
- case @attributes.has_key? attri["type"]
0
+ case self.attributes.has_key? attri["type"]
0
           when false
0
- @attributes[attri["type"]] = attri["content"]
0
+ self.attributes[attri["type"]] = attri["content"]
0
           when true
0
- @attributes[attri["type"]] += ", #{attri["content"]}"
0
+ self.attributes[attri["type"]] += ", #{attri["content"]}"
0
           end
0
 
0
         end

Comments

    No one has commented yet.