pre-queue assistance

Get help with all aspects of SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
slvrdragn
Newbie
Newbie
Posts: 17
Joined: April 29th, 2013, 12:38 pm

pre-queue assistance

Post by slvrdragn »

I'm trying to write a pre-queue script that will read from a blacklist file (one banned phrase per line) and reject the nzb if any of the words match. Using the below code, there is never match, though my test commandline contains 2 banned words. Any suggestions would be appreciated.


Test commandline with " FR " and "boheme" in the blacklist file.
# /opt/Sick-Beard/autoProcessTV/preq-name.py 'Alien Uprising 2013 FR DVDRiP XViD boheme cp(tt2040578)' '' 'movies' '' '-1' '838402469' 'alt.binaries.movies.french alt.binaries.movies.divx.french alt.binaries.movies.divx' '' '' '' ''

Code: Select all

#!/usr/bin/env python

import sys

try:
    (scriptname, nzbname, postprocflags, category, script, prio, downloadsize, grouplist, showname, season, episodenumber, episodename) = sys.argv
except:
    sys.exit(1)    # exit with 1 causes SABnzbd to ignore the output of this script

prio = -100    # Default
if downloadsize < 50111222:
    prio = 2

nzbnamelower = nzbname.lower()

with open('/opt/blacklist.names.2') as my_file:
    words = my_file.readlines()

matched = 'false'

for pointr in words:
	pointer = pointr.lower()
	#print nzbnamelower.find(pointer)
	#print pointer
	#print nzbnamelower
	pointer = pointr.lower()
	if nzbnamelower.find(pointer) != -1: 
		
		matched = 'true'
		#print "1"    # Accept
		print "0"    # reject
		print
		print
		print
		print
		print prio    
		print
		break
	  
if 'false' in matched:	
	print "1"
	print	
	print
	print	
	print
	print prio    
	print

sys.exit(0)    # 0 means OK
User avatar
shypike
Administrator
Administrator
Posts: 19773
Joined: January 18th, 2008, 12:49 pm

Re: pre-queue assistance

Post by shypike »

Does it work without SABnzbd?
At first sight it looks ok, although the Python is a bit awkward.
User avatar
shypike
Administrator
Administrator
Posts: 19773
Joined: January 18th, 2008, 12:49 pm

Re: pre-queue assistance

Post by shypike »

You forgot to .strip() the newlines ("\n") from the blacklisted words.
Try this one:

Code: Select all

#!/usr/bin/env python
import sys

try:
    (scriptname, nzbname, postprocflags, category, script, prio, downloadsize, grouplist, showname, season, episodenumber, episodename) = sys.argv
except:
    sys.exit(1) # exit with 1 causes SABnzbd to ignore the output of this script

prio = -100 # Default
if downloadsize < 50111222:
    prio = 2
nzbnamelower = nzbname.lower()

with open('/opt/blacklist.names.2') as my_file:
    words = my_file.readlines()

print words
for pointr in words:
    pointer = pointr.lower().strip()
    if pointer in nzbnamelower: 
        print "0"    # reject
        print
        print
        print
        print
        print prio    
        print
        sys.exit(0)

print "1"
print
print
print
print
print prio
print

sys.exit(0) # 0 means OK
Post Reply