I've made a few more modifications to pads.py for sabnzbd integration.
The latest version of sabnzbd has both a web username,password and the apikey.
Here's my modified version of the QueueID method:
Code: Select all
def QueueID(id):
DeBug("QueueID(" + id + ")")
u = 'http://192.168.15.50:31337/sabnzbd/api?mode=addid&name=' + id + '&pp=3&cat=TV&apikey=YOUR_API_KEY&ma_username=YOUR_USER_NAME&ma_password=YOUR_PASS_WORD'
DeBug(u)
try:
sabnzbd = urlopen(u)
r = sabnzbd.read().lstrip().rstrip()
if r == "ok":
print "ok"
else:
print "Failed to queue"
print "Exitting..."
sys.exit()
except:
print "Unable to connect to Sabnzb"
print "Exiting..."
sys.exit()
You can note that I also added a check to see if the return from the sabnzbd call was "ok" or not - if it is "error" or anything else, the script will stop ... so you can resolve the problem. You'll need to replace 'YOUR_USERNAME_HERE' and 'YOUR_PASSWORD_HERE' with the approriate values ... or remove them if you've disabled this in sabnzb (if you remove them, remove the querystring parameters entirely). Replae 'YOUR_API_KEY' with the value from sabnzbd Config->General page as well.
I also made a modification to the nzbSearch method, the updated nzbSearch method is as follows:
Code: Select all
def nzbSearch(searchstring,postidlist):
searchstring = "(" + searchstring + ") -(password)"
searchurl = FormSearchURL(searchstring)
DeBug("Searching using feed:\n" + searchurl)
try:
nzbin = feedparser.parse(searchurl)
except:
print "Unable to connect to " + searchurl
print "Exiting..."
sys.exit()
for postid in nzbin.entries:
pid = re.compile('.*(\d{7}).*').sub(r'\1',postid.id)
if CheckPostIDok(pid,postidlist):
DeBug(pid + " will be added to the queue.")
queuedpostids.append(pid)
time.sleep(3)
return True,pid
return False,"00000"
The only change to this was the addition of the "searchstring = "(" + searchstring + ") -(password)". The reason for this addition is that Usenet seems to have become quite the spot for people to attempt to make a few bucks off of TV Shows. They upload password protected archives and then request that you visit a webpage, take a survey flooded with ads and then hopefully the password is provided to you afterwards. Obviously SabNZBd can not extract the password-protected archive ... and Newzbin Editors are kind enough to flag it as '(Passworded)' in the title ... so this addition to the search string omits searches containing 'password' in the text.
I made a handful of other changes as well, but they are specific to my setup ...
I may be making a port of pads.py to .NET/C# and providing it as an Installable Windows Service, with a much higher functionality set ... so that some more filtering can be achieved, as well as validation checks against sabnzbd to see if the report was downloaded and processed properly, so that failed downloads are attempted with another Newzbin Report ID, etc ...
I'll post back here if I startup that project and/or get it to a point where it's distributable.