[BASH] Pre-processing script (or queue-filter scripts)

Come up with a useful post-processing script? Share it here!
wally007
Release Testers
Release Testers
Posts: 155
Joined: August 28th, 2009, 5:24 pm

Re: [BASH] Pre-processing script (or queue-filter scripts)

Post by wally007 »

Is there API for 'Pause for' xyz amount of minutes feature ? I like the pause script but cant find option to pause for 12 hours ....

Mar2zz wrote:A script that pauses all nzb's coming from sickbeard (can also be used to set low priority) (someone asked for in PM, thought to share it here):

Code: Select all

#!/usr/bin/env bash


### Set to paused if it's a file from sickbeard
case $3
	TV) 	# <- change this to your Sickbeard category
		priority="-2" # -2 means paused, change to 0 if you want to set it to low (low means: goes to end of queue automatic)
		;;
	*)
		priority="-100" # -100 means Default
		;;
esac


### now tell sab what to do with nzb (note, this must be echoed in specific order, every command on a new line)
echo "1" 		# 1 tell sab to use this .nzb (1) or not (0)
echo $1 		# 2 set nzbname
echo $2 		# 3 set pp
echo			# 4 set category
echo			# 5 set script
echo "$priority"	# 6 Set priority
echo			# 7 Used group
nextasy
Newbie
Newbie
Posts: 6
Joined: February 1st, 2012, 8:57 am

Re: [BASH] Pre-processing script (or queue-filter scripts)

Post by nextasy »

case $7 in
*movie*)
cat=movies
;;
*book*)
cat=ebooks
;;
*teevee*)
hmm, how can i make this case insensitive? *movies* matches on "bla.movies.blub" but NOT on "bla.Movies.blub" or "bla.moVies.blub"
wassy
Newbie
Newbie
Posts: 4
Joined: January 28th, 2012, 7:06 pm

Re: [BASH] Pre-processing script (or queue-filter scripts)

Post by wassy »

hmm, how can i make this case insensitive? *movies* matches on "bla.movies.blub" but NOT on "bla.Movies.blub" or "bla.moVies.blub"
try this:

case $7 in
*[Mm][Oo][Vv][Ii][Ee]*)
cat=movies
;;
*[Bb][Oo][Oo][Kk]*)
cat=ebooks
;;
*[Ee][Ee][Vv][Ee][Ee]*)
daspixl
Newbie
Newbie
Posts: 1
Joined: April 4th, 2013, 7:49 pm

Re: [BASH] Pre-processing script (or queue-filter scripts)

Post by daspixl »

Just wonder if someone can guide me. I have set up Dognzb and Sab to auto download and now I am wanting to use the pre-processing to compare to a list of kids movies and apply the kids category and a list of kids shows and apply the kids tv category. I need to do this because dognzb has a movie section but not a kids section so sab doesn't know which folder to push to. I hope that is clear enough.
sparklyballs
Newbie
Newbie
Posts: 8
Joined: April 4th, 2013, 3:32 pm

Re: [BASH] Pre-processing script (or queue-filter scripts)

Post by sparklyballs »

hi there, this seems like a good place to ask a question, i'm looking to get a prequeue script to give movies with a date later than 2012 a higher priority than those that don't.

but i'm new to bash (running unraid) and i don't have the first clue how to do the if (movie name contains 2012 or 2013) bit.

anyone ?
sparklyballs
Newbie
Newbie
Posts: 8
Joined: April 4th, 2013, 3:32 pm

Re: [BASH] Pre-processing script (or queue-filter scripts)

Post by sparklyballs »

got it working by using the following.


#!/usr/bin/env bash


curyear=`date +%Y`
lastyear=$((`date +%Y` -1))
testyear=($lastyear,$curyear)


if [[ $1 == *$testyear* ]]
then
case $3 in
*movie*)
priority="1"
;;
*)
priority="$5"
;;
esac
else
priority="$5"
fi



echo "1"
echo $1
echo $2
echo $3
echo $4
echo "$priority"
echo $6
echo $7
SecTSys
Newbie
Newbie
Posts: 1
Joined: May 17th, 2013, 9:44 am

Re: [BASH] Pre-processing script (or queue-filter scripts)

Post by SecTSys »

Ok I have a pre-processing script request, that I need, I am using sabnzbd on windows 8.

The idea of the script is to be able to set the defaults in config to only download the files, then copy a single .exe file and have it run in that folder where the .rar files are downloaded to after completion. now I will be honest here I am no good at writing scripts myself,

It's either that or I ask for a way to replace sabnzbd's repair and unpack process completely with the new unpacker.
strooth
Newbie
Newbie
Posts: 1
Joined: January 6th, 2014, 5:39 am

Re: [BASH] Pre-processing script (or queue-filter scripts)

Post by strooth »

I'm not sure if this is relevant to anyone or just plain outdated but i updated the acceptance section of Mar2zz's script to refuse Nzb's larger than a absolute max size and then max size per category because i was getting a few rouge nzb's of substantial size, both killing my queue and quota.

I removed the xbmc notification as i didn't need/want this

This was modified to suit MY NEEDS and may or may not be of some help to others.

Credit to Mar2zz for the original work.

Code: Select all

#!/bin/sh

### INPUT VARIABLES ###

# input (this is what sabnzbd feeds to this script and can be changed before the nzb hits the queue)

# All parameters (except 1) can be empty, meaning a default value.
# 1 : Name of the NZB (no path, no ".nzb")
# 2 : PP (0, 1, 2 or 3)
# 3 : Category
# 4 : Script (no path)
# 5 : Priority (-100, -1, 0 or 1 meaning Default, Low, Normal, High)
# 6 : Size of the download (in bytes)
# 7 : Group list (separated by spaces)
# 8 : Show name
# 9 : Season (1..99)
# 10 : Episode (1..99)
# 11: Episode name



    ##################
    ### ACCEPTANCE ###
    ##################

    ### Refuse or Accept script in queue
    ### 0=Refuse, 1=Accept
	
        moviemaxsize="4294967296" #insert max movie size in binary bytes
        musicmaxsize="524288000" #insert max music size in binary bytes
        tvmaxsize="2147483648"  #insert max tv size in binary bytes
        maxsize="10737418240" #insert abosolute max nzb size in binary bytes
		
        if [ "$6" -le "$maxsize" ]
        then
                if [ $3="movies" -a "$6" -le "$moviemaxsize" ] || [ $3="music" -a "$6" -le "$musicmaxsize" ] || [ $3="tv" -a "$6" -le "$tvmaxsize" ]
                then
                accept="1"
                else
                accept="0"
                fi
        else
        accept="0"
        fi
        echo $accept

    ##########################
    ### NZB NAME HANDLING ####
    ##########################

    ### Name of the NZB (no path, no ".nzb")
    ### Clean up unwanted words in nzbnames
    case $3 in
       movies)
          # cleanup _ and everything after (year)
          nzb=$(echo $1 | sed -e '
                   s/_/ /
                   s/).*/)/
                ' )
          ;;
       *)
          # cleanup unwanted words
          nzb=$(echo $1 | sed -e '
                   s/.par2//
                   s/.rar//
                   s/.001//
                   s/_/ /
                ' )
          ;;
    esac

    #####################
    #### PP HANDLING ####
    #####################

    # PP (0, 1, 2 or 3)
    echo $2


    ###########################
    #### CATEGORY HANDLING ####
    ###########################

    ### Set category if no category is specified
    if [ -n $3 ]
       then
       case $7 in
          *movie*)
             echo movies
             ;;
          *songs*)
             echo music
             ;;
          *teevee*)
             echo tv
             ;;
          *)
             echo $3
             ;;
       esac
    else
       echo $3
    fi



    #########################
    #### SCRIPT HANDLING ####
    #########################

    ### Use this to set a script (No Path, just basename, e.g. sabToSickbeard.py)
    echo $4


    ##########################
    ### PRIORITY HANDLING ####
    ##########################

    ### Priority (-100 -2, -1, 0 or 1, meaning Default, Paused, Low, Normal, High )

    ### Set priority X if it's a file from category X
    case $3 in
       tv)   # <- change this to your Sickbeard category
          priority="1"
          ;;
       couchpotato)
          priority="1"
          ;;
       *)
          priority="$5"
          ;;
    esac

    ### Set a Size treshold for priority in bytes
    ### To calculate see http://easycalculation.com/bandwidth-calculator.php (9663676416 bytes = 9 GB)
    maxsize="9663676416" # <- change the number for a maximum filesize
    if [ "$6" -gt "$maxsize" ]
       then
       priority="-1"
    fi

    echo $priority


    ########################
    #### GROUP HANDLING ####
    ########################

    ### Group to be used (in case your provider doesn't carry all groups and there are multiple groups in the NZB)
    echo $7
Post Reply