Testing PP Script?

Come up with a useful post-processing script? Share it here!
Post Reply
tom34
Newbie
Newbie
Posts: 5
Joined: March 22nd, 2015, 2:09 am

Testing PP Script?

Post by tom34 »

Hi,

I want to use this:
If the category is tmp, do nothing, if not, search for .mkv or .mp4 in subfolders and move them to a defined directory.
I create the following script:

Code: Select all

#!/bin/bash

Seriendownloads=/media/56b9d2c0-0811-4d2d-8bfe-9372a5aa76e2/Public/Seriendownloads/

if $5!=tmp
   then
   find $1 -name *.avi -or -name *.mkv -or -name *.mp4 -execdir mv '{}' $Seriendownloads \;
else
fi
But how can i test the script?
Do I have to download a nzb for testing it? If it doesent work, do I have to download another nzb?
Or is there a hint to test it with current nzbs or completed nzbs?
tom34
Newbie
Newbie
Posts: 5
Joined: March 22nd, 2015, 2:09 am

Re: Testing PP Script?

Post by tom34 »

Hm, the given Parameters $1 etc doesen't work for me?

Not even this works:

Code: Select all

#!/bin/sh

echo $1 >>ausgabe.ext
File "/media/56b9d2c0-0811-4d2d-8bfe-9372a5aa76e2/Download/sabnzbd/scripte/Postprocessing.py", line 3
echo $1 >>ausgabe.ext
^
SyntaxError: invalid syntax

How to run normal .sh scripts? Do i have to rename them to .py?
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Testing PP Script?

Post by shypike »

Did you create the file with a Windows editor?
Make sure the line endings are LF instead of CR LF.
User avatar
sander
Release Testers
Release Testers
Posts: 8811
Joined: January 22nd, 2008, 2:22 pm

Re: Testing PP Script?

Post by sander »

I think tom34 is trying to run a .sh script with python. Not good.
tom34
Newbie
Newbie
Posts: 5
Joined: March 22nd, 2015, 2:09 am

Re: Testing PP Script?

Post by tom34 »

Thanks for your answers.

The files are created with nano directly from terminal.
Yes, they are shellscripts, but with extension .sh they don't appear in "category - script"

What has to be modified to use .sh scripts as postprocessing scripts in sabnzbd?
User avatar
sander
Release Testers
Release Testers
Posts: 8811
Joined: January 22nd, 2008, 2:22 pm

Re: Testing PP Script?

Post by sander »

To me you seem unexperienced with SABnzbd PP scripts and shell & python scripting.
So my advice to you is to first get some experience with an existing, working SABnzbd PP script

HTH
tom34
Newbie
Newbie
Posts: 5
Joined: March 22nd, 2015, 2:09 am

Re: Testing PP Script?

Post by tom34 »

Right, i do know nothing about python :(
But my shellscripts are working till now.

Why doesen't sabnzbd recognize my .sh scripts in the dropdown menus?
Or could you please help me to create a simple python script that runs my shell script with the sabnzbd parameters $1-7?
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Testing PP Script?

Post by shypike »

Does your shell script run from a interactive shell?
Does it have its X bit set?
tom34
Newbie
Newbie
Posts: 5
Joined: March 22nd, 2015, 2:09 am

Re: Testing PP Script?

Post by tom34 »

After 1,5 days of work, try and error all my problems are resolved.

My scripts doesen't work direclty on console with ./script.sh, because the operating system Openmediavault mounts every hdd unter /media as "noexec".
Read, write and delete works, but not execute.
After deleting the noexec in fstab mount the scipts runs on console.
AND: Alle the .sh sctips are visible in sabnzbd!

So here is my working script, that looks for extensions in the downloaded folder and moves the files to other folders, depending on category which was chosen.
If no category was chosen, an error message is written to the logfile.

Code: Select all

#!/bin/bash

Seriendownloads='/media/56b9d2c0-0811-4d2d-8bfe-9372a5aa76e2/Public/Seriendownloads/'
FilmeHD='/media/56b9d2c0-0811-4d2d-8bfe-9372a5aa76e2/Public/Filme-HD/'
tmp='/media/56b9d2c0-0811-4d2d-8bfe-9372a5aa76e2/Download/transmission/completed/tmp/'
quellordner=$1

function kopiervorgang()
{
 for k in $(find $1 -name *.avi -or -name *.mkv -or -name *.mp4 -or -name *.apk)
      do mv $k $2
        done
}


IFS="
"

case $5 in
  "serie")
    ziel=$Seriendownloads;
    kopiervorgang $quellordner $ziel
 ;;
  "film")
    ziel=$FilmeHD;
    kopiervorgang $quellordner $ziel
 ;;
  tmp)
   echo "Kategorie ist $5" ;;
  *)
   echo "Keine gueltige Kategorie" ;;
esac

exit 0
User avatar
sander
Release Testers
Release Testers
Posts: 8811
Joined: January 22nd, 2008, 2:22 pm

Re: Testing PP Script?

Post by sander »

Well done, tom34!
Post Reply