Script noob :(

Come up with a useful post-processing script? Share it here!
Post Reply
killerkebab
Newbie
Newbie
Posts: 6
Joined: April 21st, 2010, 1:52 pm

Script noob :(

Post by killerkebab »

I've worked out a few things on sab, but now that it looks like the menus won't have all of my answers and I'm going to have to script, I'm totally lost :(

I'm trying to figure out:

- After the job is downloaded, unpacked, et cetera, a way to delete everything that isn't the TV show. Like .nfo files. I know there's a menu option for that but it deletes for all jobs, and I want to keep *.nfo files if I download a video game... but not if I download a TV show.

- How do I get sabnzbd to check for duplicates. My RSS feed is set so that:
Requires: 720p
Accepts: 24*S08
This is great but if sabnzbd sees... (I'm making the report names up here because my memory isn't awesome but you'll get the idea)
24.S08E17.720p.x264-DIMENSION
24.S08E17.720p.WEB-DL
or
The.Pacific.pt.VI.720p-IMMERSE
The.Pacific.pt.VI.720p-SYS
... sabnzbd assumes that the jobs are different and download both.

I think I need to get sabnzbd to check the download folder for "S08E17" and reject the job if the nzb title contains "S08E17" but I don't know how. This also happens if two 720p nzbs for the same TV episode are found, but one has DD5.1 audio and the other doesn't, say. I've figured out how to reject those by adding a "reject" for "DD5" in the feed.
markus101
Release Testers
Release Testers
Posts: 406
Joined: August 13th, 2008, 2:51 am

Re: Script noob :(

Post by markus101 »

You will need to look at using another application to smartly download missing episodes, SABnzbd RSS feeds are limited as you describe.

If you're on Windows, SABSync (Shameless advertisement) :) - SABSync uses .Net 2.0

Otherwise, Sick Beard or Media Rover will work, both are Python based.

For deleting .nfo's for TV shows you could create a post-processing script that takes in the first argument passed from SABnzbd to it (Final unpack folder) and deletes *.nfo and set that to run on the TV show category.

-Markus
Co-developer of NzbDrone (.Net NNTP PVR) - http://www.nzbdrone.com
randyharris
Full Member
Full Member
Posts: 146
Joined: January 21st, 2010, 5:36 pm

Re: Script noob :(

Post by randyharris »

Markus mentioned his programs for Windows, I've written myself a script for Mac that does the sort of thing you're talking about for my situation. There are solutions on these boards if you look, and hopefully you can start with something as your base and customize to suit you.
killerkebab
Newbie
Newbie
Posts: 6
Joined: April 21st, 2010, 1:52 pm

Re: Script noob :(

Post by killerkebab »

I like your solutions except I don't think any of them work for nzbsrus.com RSS feeds (I also have a Newzbin account but they don't post reports any more due to their court case).

As for creating my own script, I truly haven't got a clue where to start. I will search the forum a bit more for deletion scripts.

EDIT: I've found something, I think. I've shamelessly copied it from this forum and decided to use it as a base for what I'm doing here.

Code: Select all

@echo off
cd /d %1
del /q *.sff *.sfv *.nfo *.nzb *.srr
With that template in mind, I've decided to try making my own, using some help from cmd (typing help IF, or help GOTO) because I don't know anything :(

Code: Select all

@ECHO OFF
IF %5=="tv" GOTO POSTPROC
EXIT

:POSTPROC
ECHO Begin TV post-processing script
ECHO.
ECHO.
ECHO Deleting all non-video files for download: %3
CD /d %1
DEL /q *.sff *.sfv *.nfo *.nzb *.srr
EXIT
Does this look ok to delete every non-video file? Also, what if I want to add "movies" as a category to post-process? Could I have: IF %5=="tv" OR "movies"?

EDIT AGAIN:
I just realised that in the categories bit of the sabnzbd menu you can give different categories different scripts, so I can delete the IF statement at the start anyway. Out of curiosity though, would my code have worked?
Last edited by killerkebab on April 21st, 2010, 7:48 pm, edited 1 time in total.
minimeh
Newbie
Newbie
Posts: 34
Joined: March 26th, 2010, 12:42 pm

Re: Script noob :(

Post by minimeh »

There are a couple of problems. First the test for category should have been

Code: Select all

IF "%5"=="tv" GOTO POSTPROC
Notice the matching quotes on the left and right sides of ==. Without them, you would get tv=="tv" which is not a match.

Next, you probably wanted to call EXIT with a /B parameter to exit the batch file, not close the command window. This would really matter only if running interactively, not from being invoked by another process.

Lastly, there is a CD in the batch that doesn't restore the original current directory. It's a better practice to PUSHD, do something, POPD, then exit. That guarantees returning the current directory to where it was for the next process or batch file.

Here's one way to clean things up a bit and ensure that you're operating on either a tv or movies category job:

Code: Select all

@echo off
echo.
echo.
if not "%5"=="tv"  (
	if not "%5"=="movies" (
		echo Invalid category, exiting.
		goto :eof
	)
)
::POSTPROC
echo Begin TV post-processing script
echo.
echo.
echo Deleting all non-video files for download: %3
for %%i in ("%1\*.sff" "%1\*.sfv" "%1\*.nfo" "%1\*.nzb" "%1\*.srr" ) do del /q "%%i"
echo Complete
echo.
echo.
Here I don't change directory but use the completely qualified file name returned in the FOR statement. The file specification in the DEL statement is quoted to ensure that spaces in the file spec don't cause any problems.

Just food for thought. Cheers!
markus101
Release Testers
Release Testers
Posts: 406
Joined: August 13th, 2008, 2:51 am

Re: Script noob :(

Post by markus101 »

I had forgotten about nzbsrus... Shouldn't be too hard to add that in :)

Actually working on it now, as I had intended to add it when I first started.

EDIT - nzbsrus should be supported already, but I have it added in and it officially works :) It'll be in the next release.
EDIT2 - SABSync 0.9.5 should fully support nzbrus.com now :) happy downloading.

-Markus
Last edited by markus101 on April 22nd, 2010, 2:45 am, edited 1 time in total.
Co-developer of NzbDrone (.Net NNTP PVR) - http://www.nzbdrone.com
killerkebab
Newbie
Newbie
Posts: 6
Joined: April 21st, 2010, 1:52 pm

Re: Script noob :(

Post by killerkebab »

Thank you very, very much. More questions though:
In alias.config, it says type the show as it appears in the RSS feed: sabnzbd is currently searching for shows like this: Family*Guy

Is that appropriate, or do I need to change the search terms to something like Family.Guy or Family Guy?

In quality.config, if I set a show to download in 720p and the feed only has SD content, will it download SD first, then get HD content at a later date and replace the old SD stuff?
Do I need to start sabhide.exe every time I boot my computer? (put in startup folder?)
markus101
Release Testers
Release Testers
Posts: 406
Joined: August 13th, 2008, 2:51 am

Re: Script noob :(

Post by markus101 »

Alias.config would be for shows that are different on the RSS feed than they are on disk, see the list already in Alias.config for examples. SABSync will match to shows on disk in your TVRoot folder(s), based on the folder name.
Currently I have not implemented a way to improve the quality of a TV show from SD to HD, so if you're looking for 720p, it will only download 720p, not SD than HD.

You will need to run SABSyncHide.exe every time you want to check the queue, so set it up as a scheduled task to run every 15+ minutes, running it only at start would only run it once and not again until the next start-up.

-Markus
Co-developer of NzbDrone (.Net NNTP PVR) - http://www.nzbdrone.com
killerkebab
Newbie
Newbie
Posts: 6
Joined: April 21st, 2010, 1:52 pm

Re: Script noob :(

Post by killerkebab »

sabsynchide.exe crashes every time I run it, I get this:

Description:
  Stopped working

Problem signature:
  Problem Event Name: CLR20r3
  Problem Signature 01: sabsync.exe
  Problem Signature 02: 0.9.5.0
  Problem Signature 03: 4bcfccae
  Problem Signature 04: mscorlib
  Problem Signature 05: 2.0.0.0
  Problem Signature 06: 4a27471d
  Problem Signature 07: 7a9
  Problem Signature 08: 75
  Problem Signature 09: System.InvalidOperationException
  OS Version: 6.1.7600.2.0.0.256.1
  Locale ID: 2057
markus101
Release Testers
Release Testers
Posts: 406
Joined: August 13th, 2008, 2:51 am

Re: Script noob :(

Post by markus101 »

Upgrade to SABSync 0.9.6, there is an issue with 0.9.5 that causes it to not exit cleanly, very likely this is causing your issue.

For future support it would be best to use the SABSync forum post: http://forums.sabnzbd.org/index.php?topic=3097.0

-Markus
Co-developer of NzbDrone (.Net NNTP PVR) - http://www.nzbdrone.com
Post Reply