Help me make one update script for all categories

Come up with a useful post-processing script? Share it here!
Post Reply
nock
Newbie
Newbie
Posts: 28
Joined: October 29th, 2014, 2:55 pm

Help me make one update script for all categories

Post by nock »

Hi, i've been messing around with some scripting lately. Today i have one "update plex" script for each category in sab, but i would like to make one script that can update the correct plex library depending on category in sab.
I'am not sure how is should address sab categories in the script (if possible).

So today i have a bunch of this for each category in sab (modified for each ofc):

Code: Select all

 #! /bin/bash
### Updates Plex movies ###
wget -q --delete-after "http://PLEX_SERVER-IP:32400/library/sections/1/refresh" > /dev/null 
Something like this possible? :

Code: Select all

UpdatePlex () {
if $movies
then
"update plex for movies command"
else
"do noting"
fi

if $standup
then 
"update plex for standup command"
else
"do nothing"
fi
}

Would be nice to learn something new :)
User avatar
sander
Release Testers
Release Testers
Posts: 8827
Joined: January 22nd, 2008, 2:22 pm

Re: Help me make one update script for all categories

Post by sander »

Why not one script that updates all Plex categories at once?

(Disclaimer: I don't know how Plex categories / updates work)
User avatar
jcfp
Release Testers
Release Testers
Posts: 989
Joined: February 7th, 2008, 12:45 pm

Re: Help me make one update script for all categories

Post by jcfp »

Something like this possible? :
Sure is, category info is available to postproc scripts, see http://wiki.sabnzbd.org/user-scripts

If all that changes is the 'sections/$X/refresh' part of the url, you'd probably want a case...esac statement to match the sab category with the one in plex, then a single wget call after all that. Easy enough.
nock
Newbie
Newbie
Posts: 28
Joined: October 29th, 2014, 2:55 pm

Re: Help me make one update script for all categories

Post by nock »

Smart! I shall look in to it:)
nock
Newbie
Newbie
Posts: 28
Joined: October 29th, 2014, 2:55 pm

Re: Help me make one update script for all categories

Post by nock »

Cant seem to get it. "5 user category" does that mean $5? If so how do i know what $5 returns?
something like this?

Code: Select all

#if $5 rerurn category name
movie = 6 #movie libary in plex
standup = 5 #standup libary in plex
x = $movies | $standup # if  x needs to be all categories in sab

UpdatePlex () {
If $5 = $x
Then
### Updates Plex ###
wget -q --delete-after "http://PLEX_SERVER-IP:32400/library/sections/$x/refresh" > /dev/null
Else
Do nothing
Fi
}

User avatar
jcfp
Release Testers
Release Testers
Posts: 989
Joined: February 7th, 2008, 12:45 pm

Re: Help me make one update script for all categories

Post by jcfp »

Code: Select all

#!/bin/sh

# vodka, beer and wine are sabnzbd categories; X their equivalent library section
# add or modify categories as needed, just get the syntax right and keep the catch-all as the last entry
case "$5" in
	vodka)
		X=42;;
	beer|wine)
		X=1;;
	*)
		echo "$(basename "$0"): need a valid category"
		exit 1
esac

# set host and port so this connects to your plex install
wget -nv -S -O /dev/null "http://HOST:PORT/library/sections/${X}/refresh"
Edit: added some script comments for newbie-proofing
nock
Newbie
Newbie
Posts: 28
Joined: October 29th, 2014, 2:55 pm

Re: Help me make one update script for all categories

Post by nock »

Could you explain a little bit?
nock
Newbie
Newbie
Posts: 28
Joined: October 29th, 2014, 2:55 pm

Re: Help me make one update script for all categories

Post by nock »

Thank you, this is exactly what i wanted! :)
Post Reply