pre-queue assistance
Posted: August 27th, 2014, 9:02 am
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' '' '' '' ''
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