Using sabToSickBeard with NZBGet

Share your scripts or request scripts with specific features.
Forum rules
Please keep the forum clean - one topic per script. Questions not related to a specific script should be posted in Support forum.
kjKmcQN3
Posts: 75
Joined: 29 Aug 2015, 15:09

Using sabToSickBeard with NZBGet

Post by kjKmcQN3 » 29 Aug 2015, 20:15

I've recently moved from SABnzbd+ to NZBGet and am very happy and impressed with it. I use SickRage to manage my TV library and have so far relied on the sabToSickBeard script that works quite nicely with SAB. I would like to use the same setup on NZBGet. However, all my attempts to get the sabToSickBeard script to work with NZBGet have been unsuccessful so far. I tried copying the .py files over to the NZBGet scripts folder (set to the default ${MainDir}/scripts) which didn't work. I also tried copying the autoProcessTV folder over but that didn't work either.

I have seen many pointers to clinton hall's nzbToMedia scripts that people seem to be using instead. While I am sure that they work extremely well they are a bit of an overkill for me. I don't need all of the additional features that they incorporate and like the simplicity of the sabToSickBeard script, with the configuration done at the SickRage end. I've seen older forum posts (such as this and this) and also tried looking elsewhere but can't seem to find a solution. I'd greatly appreciate help in getting the classic SickBeard post-processing scripts to work with NZBGet.

kloaknet
Posts: 335
Joined: 23 Jul 2014, 08:52

Re: Using sabToSickBeard with NZBGet

Post by kloaknet » 29 Aug 2015, 20:24

I doubt the sab script will work in NZBget, as NZBget has its own typical scripts. For very simple file sorting, you might be happy already with VideoSort: https://github.com/nzbget/VideoSort

hugbug
Developer & Admin
Posts: 7514
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: Using sabToSickBeard with NZBGet

Post by hugbug » 29 Aug 2015, 20:29

To adopt the script to nzbget you need to:
- add script signature in order for nzbget to see it as pp-script;
- adjust the script to read the parameters from environment vars instead of parameters passed directly to the script;
- when the script terminates pass a correct exit cod for nzbget to show correct processing status.

See https://github.com/nzbget/nzbget/wiki/Extension-scripts for details.

clintonhall
Posts: 449
Joined: 15 Dec 2012, 01:52
Location: Australia
Contact:

Re: Using sabToSickBeard with NZBGet

Post by clintonhall » 29 Aug 2015, 22:05

Look at nzbToMedia.

This script started from sabToSickBeard, I created a sabToCouchPotato variant, then added more features, NZBGet support (and later Torrent Client support).
it has all features of sabToSickBeard and more.

kjKmcQN3
Posts: 75
Joined: 29 Aug 2015, 15:09

Re: Using sabToSickBeard with NZBGet

Post by kjKmcQN3 » 31 Aug 2015, 16:42

clintonhall wrote:Look at nzbToMedia.

This script started from sabToSickBeard, I created a sabToCouchPotato variant, then added more features, NZBGet support (and later Torrent Client support).
it has all features of sabToSickBeard and more.
Thanks for looking into this, clinton hall. I have looked at your nzbToMedia scripts. While they seem excellent and very comprehensive, I am looking for something far simpler for the reasons explained in the OP. Could you suggest an alternative?

clintonhall
Posts: 449
Joined: 15 Dec 2012, 01:52
Location: Australia
Contact:

Re: Using sabToSickBeard with NZBGet

Post by clintonhall » 01 Sep 2015, 10:49

Sorry, I just saw the thread title and last last responses..

the reality is this should be that simple... all you do is put your autoProcessTV.cfg in the same directory as nzbToMedia and this should auto migrate and do what you want.

I haven't had a chance to test, but if you replace the contents of sabToSickBeard.py with the below... this should do what you want.

Code: Select all

#!/usr/bin/env python
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT                                          ###

# Post-Process to SickBeard.
#
# This script sends the download to your automated media management servers.
#
# NOTE: This script requires Python to be installed on your system.

### NZBGET POST-PROCESSING SCRIPT                                          ###
##############################################################################

import os
import sys
import autoProcessTV
POSTPROCESS_NONE=1

# NZBGet V11+
# Check if the script is called from nzbget 11.0 or later
if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5] < '11.0':
    print("MAIN: Script triggered from NZBGet (11.0 or later).")

    # NZBGet argv: all passed as environment variables.
    # Exit codes used by NZBGet
    POSTPROCESS_PARCHECK=92
    POSTPROCESS_SUCCESS=93
    POSTPROCESS_ERROR=94
    POSTPROCESS_NONE=95

    status = 0

    if os.environ['NZBOP_UNPACK'] != 'yes':
        print("Please enable option \"Unpack\" in nzbget configuration file, exiting")
        sys.exit(POSTPROCESS_ERROR)

    # Check par status
    if os.environ['NZBPP_PARSTATUS'] == '3':
        print("Par-check successful, but Par-repair disabled, exiting")
        sys.exit(POSTPROCESS_NONE)

    if os.environ['NZBPP_PARSTATUS'] == '1':
        print("Par-check failed, setting status \"failed\"")
        status = 1

    # Check unpack status
    if os.environ['NZBPP_UNPACKSTATUS'] == '1':
        print("Unpack failed, setting status \"failed\"")
        status = 1

    if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] != '2':
        # Unpack is disabled or was skipped due to nzb-file properties or due to errors during par-check

        for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']):
            for file in filenames:
                fileExtension = os.path.splitext(file)[1]

                if fileExtension in ['.rar', '.7z'] or os.path.splitext(fileExtension)[1] in ['.rar', '.7z']:
                    print("Post-Process: Archive files exist but unpack skipped, setting status \"failed\"")
                    status = 1
                    break

                if fileExtension in ['.par2']:
                    print("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), setting status \"failed\"g")
                    status = 1
                    break

        if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")) and not status == 1:
            print("Post-Process: _brokenlog.txt exists, download is probably damaged, exiting")
            status = 1

        if not status == 1:
            print("Neither archive- nor par2-files found, _brokenlog.txt doesn't exist, considering download successful")

    # Check if destination directory exists (important for reprocessing of history items)
    if not os.path.isdir(os.environ['NZBPP_DIRECTORY']):
        print("Post-Process: Nothing to post-process: destination directory %s doesn't exist", os.environ['NZBPP_DIRECTORY'])
        status = 1

    # All checks done, now launching the script.
    print("Script triggered from NZBGet, starting autoProcessTV...")
    autoProcessTV.processEpisode(os.environ['NZBPP_DIRECTORY'], os.environ['NZBPP_NZBNAME'], status)
# SABnzbd
elif len(sys.argv) > 5:
    # SABnzbd argv:
    # 1 The final directory of the job (full path)
    # 2 The original name of the NZB file
    # 3 Clean version of the job name (no path info and ".nzb" removed)
    # 4 Indexer's report number (if supported)
    # 5 User-defined category
    # 6 Group that the NZB was posted in e.g. alt.binaries.x
    # 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2
    print("Script triggered from SABnzbd, starting autoProcessTV...")
    autoProcessTV.processEpisode(sys.argv[1], sys.argv[2], sys.argv[7])
else:
    print("Invalid number of arguments received from client.")
    print("Exiting...")
    sys.exit(POSTPROCESS_NONE)
Last edited by clintonhall on 10 Sep 2015, 11:46, edited 2 times in total.

kjKmcQN3
Posts: 75
Joined: 29 Aug 2015, 15:09

Re: Using sabToSickBeard with NZBGet

Post by kjKmcQN3 » 01 Sep 2015, 19:47

clintonhall wrote:Sorry, I just saw the thread title and last last responses..

the reality is this should be that simple... all you do is put your autoProcessTV.cfg in the same directory as nzbToMedia and this should auto migrate and do what you want.

I haven't had a chance to test, but if you replace the contents of sabToSickBeard.py with the below... this should do what you want.

Code: Select all

#!/usr/bin/env python
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT                                          ###

# Post-Process to SickBeard.
#
# This script sends the download to your automated media management servers.
#
# NOTE: This script requires Python to be installed on your system.

### NZBGET POST-PROCESSING SCRIPT                                          ###
##############################################################################

import os
import sys
import autoProcessTV

# NZBGet V11+
# Check if the script is called from nzbget 11.0 or later
if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5] < '11.0':
    print("MAIN: Script triggered from NZBGet (11.0 or later).")

    # NZBGet argv: all passed as environment variables.
    # Exit codes used by NZBGet
    POSTPROCESS_PARCHECK=92
    POSTPROCESS_SUCCESS=93
    POSTPROCESS_ERROR=94
    POSTPROCESS_NONE=95

    status = 0

    if os.environ['NZBOP_UNPACK'] != 'yes':
        print("Please enable option \"Unpack\" in nzbget configuration file, exiting")
        sys.exit(POSTPROCESS_ERROR)

    # Check par status
    if os.environ['NZBPP_PARSTATUS'] == '3':
        print("Par-check successful, but Par-repair disabled, exiting")
        sys.exit(POSTPROCESS_NONE)

    if os.environ['NZBPP_PARSTATUS'] == '1':
        print("Par-check failed, setting status \"failed\"")
        status = 1

    # Check unpack status
    if os.environ['NZBPP_UNPACKSTATUS'] == '1':
        print("Unpack failed, setting status \"failed\"")
        status = 1

    if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] != '2':
        # Unpack is disabled or was skipped due to nzb-file properties or due to errors during par-check

        for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']):
            for file in filenames:
                fileExtension = os.path.splitext(file)[1]

                if fileExtension in ['.rar', '.7z'] or os.path.splitext(fileExtension)[1] in ['.rar', '.7z']:
                    print("Post-Process: Archive files exist but unpack skipped, setting status \"failed\"")
                    status = 1
                    break

                if fileExtension in ['.par2']:
                    print("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), setting status \"failed\"g")
                    status = 1
                    break

        if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")) and not status == 1:
            print("Post-Process: _brokenlog.txt exists, download is probably damaged, exiting")
            status = 1)

        if not status == 1:
            print("Neither archive- nor par2-files found, _brokenlog.txt doesn't exist, considering download successful")

    # Check if destination directory exists (important for reprocessing of history items)
    if not os.path.isdir(os.environ['NZBPP_DIRECTORY']):
        print("Post-Process: Nothing to post-process: destination directory %s doesn't exist", os.environ['NZBPP_DIRECTORY'])
        status = 1

    # All checks done, now launching the script.
    print("Script triggered from NZBGet, starting autoProcessTV...")
    autoProcessTV.processEpisode(os.environ['NZBPP_DIRECTORY'], os.environ['NZBPP_NZBNAME'], status)
# SABnzbd
elif len(sys.argv) > 5:
    # SABnzbd argv:
    # 1 The final directory of the job (full path)
    # 2 The original name of the NZB file
    # 3 Clean version of the job name (no path info and ".nzb" removed)
    # 4 Indexer's report number (if supported)
    # 5 User-defined category
    # 6 Group that the NZB was posted in e.g. alt.binaries.x
    # 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2
    print("Script triggered from SABnzbd, starting autoProcessTV...")
    autoProcessTV.processEpisode(sys.argv[1], sys.argv[2], sys.argv[7])
else:
    print("Invalid number of arguments received from client.")
    print("Exiting...")
    sys.exit(POSTPROCESS_NONE)
Awesome! Do I put the autoProcessTV.cfg from the SickRage folder into the same directory as nzbToMedia? Do I do that in conjunction with the edited sabToSickBeard.py script that you have posted or are these two different options, ie, Option 1) put autoProcessTV.cfg in the same directory as nzbToMedia and Option 2) Use the edited sabToSickBeard.py script?

Thanks a ton.

clintonhall
Posts: 449
Joined: 15 Dec 2012, 01:52
Location: Australia
Contact:

Re: Using sabToSickBeard with NZBGet

Post by clintonhall » 02 Sep 2015, 04:32

2 options...

for option 1, your settings can be imported... however you would still need to add the correct host, port, user, pass etc in the config of nzbToMedia shown in NZBGet web UI (so actually, the migration would be rather pointless). I forgot that I did the migration BEFORE allowing the settings to be specified in NZBGet WebUI...

So, option 2 is probably what you want. Just edit the sabToSickBeard.py as per mys post, then when you point NZBGet to this scripts folder, you should see the sabToScikBeard.py script.
The settings should be as per your existing autoProcessTV.cfg

Give it a go and let me know if you have any issues (I never had a chance to test it)

kjKmcQN3
Posts: 75
Joined: 29 Aug 2015, 15:09

Re: Using sabToSickBeard with NZBGet

Post by kjKmcQN3 » 03 Sep 2015, 11:25

clintonhall wrote:2 options...

for option 1, your settings can be imported... however you would still need to add the correct host, port, user, pass etc in the config of nzbToMedia shown in NZBGet web UI (so actually, the migration would be rather pointless). I forgot that I did the migration BEFORE allowing the settings to be specified in NZBGet WebUI...

So, option 2 is probably what you want. Just edit the sabToSickBeard.py as per mys post, then when you point NZBGet to this scripts folder, you should see the sabToScikBeard.py script.
The settings should be as per your existing autoProcessTV.cfg

Give it a go and let me know if you have any issues (I never had a chance to test it)
I just tried post-processing a file with the sabToSickBeard.py script that you added but the post-processing failed. The messages I got from the NZBGet log are pasted below. Was I supposed to copy paste the entire autoProcessTV folder from SickRage into the NZBGet scripts directory? I simply put your edited sabToSickBeard.py script into the NZBGet scripts directory.

INFO Thu Sep 03 2015 16:33:11 Collection some.tv.show added to history
ERROR Thu Sep 03 2015 16:33:11 Post-process-script sabToSickBeard.py for some.tv.show failed (terminated with unknown status)
INFO Thu Sep 03 2015 16:33:11 sabToSickBeard: SyntaxError: invalid syntax
INFO Thu Sep 03 2015 16:33:11 sabToSickBeard: ^
INFO Thu Sep 03 2015 16:33:11 sabToSickBeard: status = 1)
INFO Thu Sep 03 2015 16:33:11 sabToSickBeard: File "/Users/abc_xyz/Library/Application Support/NZBGet/scripts/sabToSickBeard.py", line 70
INFO Thu Sep 03 2015 16:33:11 Executing post-process-script sabToSickBeard.py for some.tv.show

Thanks again for your help!

clintonhall
Posts: 449
Joined: 15 Dec 2012, 01:52
Location: Australia
Contact:

Re: Using sabToSickBeard with NZBGet

Post by clintonhall » 05 Sep 2015, 02:45

sorry... not sure how that got in there. the file I copied from to put in this forum did not have that "0"... I must have hit a wrong key when checking/posting here.

The script has been edited in my post above. Please try editing the script and replacing from my original post. This should now run.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests