Page 1 of 1
Help me make one update script for all categories
Posted: January 12th, 2015, 7:19 pm
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
Re: Help me make one update script for all categories
Posted: January 12th, 2015, 11:18 pm
by sander
Why not one script that updates all Plex categories at once?
(Disclaimer: I don't know how Plex categories / updates work)
Re: Help me make one update script for all categories
Posted: January 13th, 2015, 7:31 am
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.
Re: Help me make one update script for all categories
Posted: January 13th, 2015, 7:37 am
by nock
Smart! I shall look in to it:)
Re: Help me make one update script for all categories
Posted: January 13th, 2015, 9:42 am
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
}
Re: Help me make one update script for all categories
Posted: January 13th, 2015, 4:01 pm
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
Re: Help me make one update script for all categories
Posted: January 14th, 2015, 7:57 am
by nock
Could you explain a little bit?
Re: Help me make one update script for all categories
Posted: January 14th, 2015, 1:49 pm
by nock
Thank you, this is exactly what i wanted!