Sickbeard to Sab - Different Category based on regex

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
adic26
Newbie
Newbie
Posts: 4
Joined: February 7th, 2017, 12:38 am

Sickbeard to Sab - Different Category based on regex

Post 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.
User avatar
safihre
Administrator
Administrator
Posts: 5678
Joined: April 30th, 2015, 7:35 am
Contact:

Re: Sickbeard to Sab - Different Category based on regex

Post 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.
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
adic26
Newbie
Newbie
Posts: 4
Joined: February 7th, 2017, 12:38 am

Re: Sickbeard to Sab - Different Category based on regex

Post 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?
User avatar
jcfp
Release Testers
Release Testers
Posts: 1032
Joined: February 7th, 2008, 12:45 pm

Re: Sickbeard to Sab - Different Category based on regex

Post 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.
adic26
Newbie
Newbie
Posts: 4
Joined: February 7th, 2017, 12:38 am

Re: Sickbeard to Sab - Different Category based on regex

Post 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?
adic26
Newbie
Newbie
Posts: 4
Joined: February 7th, 2017, 12:38 am

Re: Sickbeard to Sab - Different Category based on regex

Post 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?
User avatar
safihre
Administrator
Administrator
Posts: 5678
Joined: April 30th, 2015, 7:35 am
Contact:

Re: Sickbeard to Sab - Different Category based on regex

Post by safihre »

You select it in Config Switches, after placing it in your Scripts folder.
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
Post Reply