TV Show Post-Processing Script (linux)

Come up with a useful post-processing script? Share it here!
tret
Full Member
Full Member
Posts: 148
Joined: August 2nd, 2008, 2:07 pm

TV Show Post-Processing Script (linux)

Post by tret »

I have abandoned these bash scripts in favor of an improved python script.

The new thread can be found here: http://forums.sabnzbd.org/index.php?topic=1847.0
Last edited by tret on March 2nd, 2009, 12:36 am, edited 1 time in total.
revelation_22
Newbie
Newbie
Posts: 21
Joined: October 19th, 2008, 12:21 pm

Re: TV Show Post-Processing Script (linux)

Post by revelation_22 »

This script sounds great. I'll give it a go. I would also be interested in your movie and music scripts you mentioned.

Thanks
tret
Full Member
Full Member
Posts: 148
Joined: August 2nd, 2008, 2:07 pm

Re: TV Show Post-Processing Script (linux)

Post by tret »

let me know how it goes. Also I have made a few changes to the script, minor changes but I figured I would put the updated script code here. I added a failed directory variable so that when the script detects a failed sab job it moves the failed job to a pre-defined directory. This is important so that a later running of the script doesn't move the failed job to your finished library location along with any new completed jobs. I have also added some more documentation in case anyone is trying to figure out what each section is doing. And lastly I have the script set the permissions to the completed job to 777 just in case the permissions are too restrictive after sabnzbd is finished with them.

I will post the movie and music scripts as well, they are much less complicated but do mostly the same thing, sans thetvdb.com stuff.


See the top post for the latest code
Last edited by tret on October 23rd, 2008, 9:03 pm, edited 1 time in total.
tret
Full Member
Full Member
Posts: 148
Joined: August 2nd, 2008, 2:07 pm

Re: TV Show Post-Processing Script (linux)

Post by tret »

Here is a more simple version of my tv show script used for movies instead

Code: Select all

#!/bin/sh
# $1 (source path) is provided by sabnzbd+ upon execution
# $3 (job title) is provided by sabnzbd+ upon execution

# ---------- User definable section
LIBRARY_PATH="/home/sabnzbd/Media/videos/movies/" #Define where files should be moved (Use full path)
FAILED_PATH="/home/sabnzbd/Downloads/failed/" #Define where failed downloads should be moved (Use full path)
MIN_SIZE='102400k' #Files below this size will be deleted unless they match known types
XBMC_IP='192.168.1.6:8080' #XBMC Web Server address and port
# ---------- User definable section


# Search $1 (source path) for folders including _FAILED_, move contents of $1 to $FAILED_PATH if found and exit script
FAILED_TEST=`find "$1" -type d \( -iname "*_FAILED_*" \) -print`
if [ "$FAILED_TEST" ] ; then
echo "failed download detected, movie_clean aborted"
cp -Rf "$1" $FAILED_PATH
rm -Rf "$1"
exit
fi


echo ""
echo "- movie_clean v1.0 by tret"
echo ""
echo "- the following junk files and empty directories were removed:"
# Remove small files except for those defined "-not", remove defined files
find "$1" -type f -not \( -iname "*video_ts*" -o -iname "*vts_*" -o -iname "*.nfo" -o -iname "*.jpg"  -o -iname "*.srt" -o -iname "*.sub" -o -iname "*.idx" \) -a \( -iname "*par2*" -o -iname "*sample*" -o -size -$MIN_SIZE \) -print -exec rm -rf {} \;
# Remove any empty directories
find "$1" -depth -type d -empty -print -exec rmdir {} \;


echo ""
echo "- $3 has been moved to $LIBRARY_PATH"
# move processed movies to LIBRARY_PATH
cp -Rf "$1" $LIBRARY_PATH
rm -Rf "$1"
chmod -R 777 $LIBRARY_PATH


echo ""
echo "- movie_clean complete, video library update request sent to XBMC"
# access the xbmc web interface and trigger a video library update
wget --delete-after 'http://'$XBMC_IP'/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.updatelibrary(video)' >/dev/null 2>&1

Last edited by tret on October 23rd, 2008, 9:07 pm, edited 1 time in total.
revelation_22
Newbie
Newbie
Posts: 21
Joined: October 19th, 2008, 12:21 pm

Re: TV Show Post-Processing Script (linux)

Post by revelation_22 »

The TV show script is working great. This was the icing on the cake for my NZBivo -> sabnzbd -> XBMC setup. Trying out your movie script next. Thanks for sharing your work and script foo.
revelation_22
Newbie
Newbie
Posts: 21
Joined: October 19th, 2008, 12:21 pm

Re: TV Show Post-Processing Script (linux)

Post by revelation_22 »

also how would one modify these scripts to update multiple instances of XBMC? Thanks again.
tret
Full Member
Full Member
Posts: 148
Joined: August 2nd, 2008, 2:07 pm

Re: TV Show Post-Processing Script (linux)

Post by tret »

revelation_22 wrote: The TV show script is working great. This was the icing on the cake for my NZBivo -> sabnzbd -> XBMC setup. Trying out your movie script next. Thanks for sharing your work and script foo.
Hey revelation, glad to hear that it is working well for you. Check the top most post for my latest revision of the script. I reworked it a little to eliminate the need to define your sabnzbd download directory. I also cleaned up the echo outputs a little and a few other bits in the code. Let me know how it works.

If you would like to send an update notification to a second XBMC machine it shouldn't be too difficult.

Add this line to the user variables section at the top (alter the IP and Port of course) :

Code: Select all

XBMC2_IP='192.168.1.6:8080' #XBMC Web Server address and port
And add this line just beneath the first "wget --delete-after code" (towards the bottom of the script) :

Code: Select all

wget --delete-after 'http://'$XBMC2_IP'/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.updatelibrary(video)' >/dev/null 2>&1
Good luck!
tret
Full Member
Full Member
Posts: 148
Joined: August 2nd, 2008, 2:07 pm

Re: TV Show Post-Processing Script (linux)

Post by tret »

I just found some issues with extracting the SERIES_ID from the tvdb.com xml file, this was causing the nfo file to have the wrong URL in some cases. I have fixed the issues and reposted the latest version of the script on the first post in this thread. Replace any older versions with this new code.

tret
tret
Full Member
Full Member
Posts: 148
Joined: August 2nd, 2008, 2:07 pm

Re: TV Show Post-Processing Script (linux)

Post by tret »

I just posted a new version that eliminates the need to download and install curl, it uses wget instead. Enjoy!

Check the first post for the latest code
superultra
Newbie
Newbie
Posts: 8
Joined: October 26th, 2008, 1:08 pm

Re: TV Show Post-Processing Script (linux)

Post by superultra »

Tret, this is great. But I'm having an issues with whatever is downloaded "disappearing." Basically what the script did is delete my current show name directory, effectively deleting everything already downloaded.

And here's the TV Sorting Folder:
%sn/Season %0s/%sn - S%0sE%0e - %en.%ext
(note, I had it originally set to "Season %s" but when you start getting into double digits, XBMC doesn't know how to order properly)

Completed download folder:
/mnt/350gb
Last edited by Anonymous on November 26th, 2008, 9:12 pm, edited 1 time in total.
tret
Full Member
Full Member
Posts: 148
Joined: August 2nd, 2008, 2:07 pm

Re: TV Show Post-Processing Script (linux)

Post by tret »

superultra wrote: Tret, this is great. But I'm having an issues with whatever is downloaded "disappearing." Basically what the script did is delete my current show name directory, effectively deleting everything already downloaded.

And here's the TV Sorting Folder:
%sn/Season %0s/%sn - S%0sE%0e - %en.%ext
(note, I had it originally set to "Season %s" but when you start getting into double digits, XBMC doesn't know how to order properly)

Completed download folder:
/mnt/350gb
From the info here it looks like maybe your completed downloads dir and your xbmc library dir are set to the same directory. If this is the case the result would be as you describe. Once all of the main processing in this script is completed, the TV show and everything within it is copied to your xbmc library directory and then the copy within the download directory is deleted. If both directories are set to the same path then the copy won't happen (see your cp: error above) but the removal of the copy in the download directory (in this case the copy you want to keep) will still happen.

This can be fixed in one of two ways.

1. Make the sabnzbd completed download path different from your xbmc library path
2. Remove the copy and delete code from the script, keep in mind though if you do this and change the paths later like i suggest above, the script will not function properly without the missing code.

tret
Last edited by Anonymous on November 26th, 2008, 9:12 pm, edited 1 time in total.
superultra
Newbie
Newbie
Posts: 8
Joined: October 26th, 2008, 1:08 pm

Re: TV Show Post-Processing Script (linux)

Post by superultra »

That did the trick Tret. Thanks, for the help and the great script.
revelation_22
Newbie
Newbie
Posts: 21
Joined: October 19th, 2008, 12:21 pm

Re: TV Show Post-Processing Script (linux)

Post by revelation_22 »

Tret, I just wanted to say that youe tv_clean script seems to be working great. I had an issue with pushd and popd in Ubuntu Hardy but I resolved that by installing bash-builtins. Thanks again.
revelation_22
Newbie
Newbie
Posts: 21
Joined: October 19th, 2008, 12:21 pm

Re: TV Show Post-Processing Script (linux)

Post by revelation_22 »

How would I modify the tv_clean script to skip creating the tvshow.nfo file if it already exists?  Thanks.
tret
Full Member
Full Member
Posts: 148
Joined: August 2nd, 2008, 2:07 pm

Re: TV Show Post-Processing Script (linux)

Post by tret »

Hi revelation. This would involve checking the destination location to see if the show already exists there, and then also checking to see if the show in the destination folder has the tvshow.nfo file.

I actually have a newer version of the script, I'll play around with it and see if I can add your request as well as post the newer version.

tret
Post Reply