Page 1 of 1

Sickbeard to Sab - Different Category based on regex

Posted: February 7th, 2017, 12:42 am
by adic26
Apologies in advance if this was asked before as I couldn't find it.

On the basis of title of the show or some custom regex, is there anyway I can setup a different category in Sabnzbd? Mostly my Sickbeard sends all my shows with the 'tv' category and for all intents and purposes that works great. However, for 1 or 2 different type of show I like to 'force' download right away but Sickbeard allows only one category without any filter. Is this possible for me to setup in Sabnzbd?

Thanks in advance.

Re: Sickbeard to Sab - Different Category based on regex

Posted: February 7th, 2017, 1:23 am
by safihre
This is only possible by using a Pre-Queue script (see wiki). In general when an external program sets a category for a download, that one is always used.
With a script you could still detect that category and search for the titles you want and then modify the category.

Re: Sickbeard to Sab - Different Category based on regex

Posted: February 7th, 2017, 11:50 am
by adic26
Thanks safihre.

Can you help me Validate whether this script makes sense part of Pre-Queue?

Code: Select all

import sys
import re

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

prio = -100    # Default
# Example --> The.Daily.Show.with.Trevor.Noah.2017.02.06.Keith.Ellison.Extended.1080p.CC.WEB-DL
if re.search('^The\.Daily\.Show.*', nzbname):
    prio = 2

print "1"    # Accept
print
print
print
print
print prio
print
# 0 means OK
sys.exit(0)
Does that make sense?

Re: Sickbeard to Sab - Different Category based on regex

Posted: February 7th, 2017, 2:17 pm
by jcfp
The script would probably need a python shebang line at the start or the operating system wouldn't know what to do.

The basic concept looks ok, though I would suggest making the part with the regex and prio change conditional on the job being in the tv category in the first place. Could also consider hardening the regex part a bit so it can deal with job names that don't have caps at the start of every word.

Re: Sickbeard to Sab - Different Category based on regex

Posted: February 7th, 2017, 2:55 pm
by adic26
Thanks jcfp.

Corrected Script:

Code: Select all

#!/usr/bin/env python

import sys
import re

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

prio = -100    # Default
# Example --> The.Daily.Show.with.Trevor.Noah.2017.02.06.Keith.Ellison.Extended.1080p.CC.WEB-DL
if (re.search('^[Tt]he.+[Dd]aily.+[Ss]how.*, nzbname) and category == 'tv'):
    prio = 2

print "1"    # Accept
print
print
print
print
print prio
print
# 0 means OK
sys.exit(0)
My follow up question would be, how does Sab know to run this part of pre-queue script? According to WIKI - I can add this script in my 'Post-Processing Scripts Folder' , but how does SAB know to execute this particular script as PRE-queue?

Re: Sickbeard to Sab - Different Category based on regex

Posted: February 8th, 2017, 1:37 am
by adic26
My follow up question would be, how does Sab know to run this part of pre-queue script? According to WIKI - I can add this script in my 'Post-Processing Scripts Folder' , but how does SAB know to execute this particular script as PRE-queue?

Re: Sickbeard to Sab - Different Category based on regex

Posted: February 8th, 2017, 1:40 am
by safihre
You select it in Config Switches, after placing it in your Scripts folder.