From d2593acdca013fa1db5bc5276d32d3aa96ccbcc0 Mon Sep 17 00:00:00 2001 From: Jurgen S Date: Tue, 20 Nov 2012 07:56:48 +0100 Subject: [PATCH 1/5] Changed arguments to work with NZBGet Reduced number of arguments and removed description not used arguments, set status of NZB to success --- sabToCouchPotato.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/sabToCouchPotato.py b/sabToCouchPotato.py index 4fdbfe60..ef4a4276 100644 --- a/sabToCouchPotato.py +++ b/sabToCouchPotato.py @@ -3,22 +3,18 @@ import sys import autoProcessMovie -if len(sys.argv) < 8: - print "Not enough arguments received from SABnzbd." +if len(sys.argv) < 2: + print "Not enough arguments received from NZBGet." print "Running autoProcessMovie as a manual run" autoProcessMovie.process('Manual Run', 'Manual Run', 0) else: - status = int(sys.argv[7]) + status = 0 autoProcessMovie.process(sys.argv[1], sys.argv[2], status) -# SABnzbd argv: +# NZBGet 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 +# 3 Status of post processing. 0 = OK From ecd7e3785a2a6a233976a7a44ca1700abef943ba Mon Sep 17 00:00:00 2001 From: Jurgen S Date: Tue, 20 Nov 2012 18:25:42 +0100 Subject: [PATCH 2/5] Added installation details for nzbget --- README.md | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 88df2b69..c799506e 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,26 @@ -sabToCouchPotato -================ +nzbgetToCouchPotato +=================== -Provides SABnzbd postprocessing for CouchPotatoServer +Provides NZBGet postprocessing for CouchPotatoServer, based on sabToCouchPotato from clinton-hall -Rename the file autoProcessMovie.cfg.sample to autoProcessMovie.cfg and fill in the appropriate fields as -they apply to your installation. +To get this to work with NZBGet you have to do the following: -In order to utilize failed download handling in CPS you will need to chnage the following settings in sabnzbd: -sabnzbd, config, switches, Post-Process Only Verified Jobs = Off -sabnzbd, config, special, empty_postproc = On +1) Put all the files eg. in a directory named /scripts and change the permission so nzbget can use them. +2) Add the following lines into postprocess.conf in the "PATH" section: + + # Set the full path to sabToCouchpotato.py for Couchpotato's postprocessing + SabToCouchpotato=/usr/local/nzbget/var/scripts/sabToCouchpotato.py + +3) Add the following lines into postproecess.sh right before the line "# Check if destination directory was set in postprocessing parameters" + + if [ $NZBPP_CATEGORY = "movies" -a -e "$SabToCouchpotato" ]; then + # Call Couchpotatos postprocessing script + echo "[INFO] Post-Process: Running Couchpotato's postprocessing script ($SabToCouchpotato $NZBPP_DIRECTORY $NZBPP_NZBFILENAME)" + $PythonCmd $SabToCouchpotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" >/dev/null 2>&1 + fi + +4)Rename the file autoProcessMovie.cfg.sample to autoProcessMovie.cfg and fill in the appropriate fields as they apply to your installation. [Notes_On_Delay] delay must be a minimum of 60 seconds for the renamer.scan to run successfully. CouchPotato @@ -34,7 +45,7 @@ sabnzbd, config, special, empty_postproc = On If you have added .py to your PATHEXT (in windows) or you have given sabToCouchPotato.py executable permissions, or you are using the compiled executables you can manually call this process outside of -sabnzbd for testing your configuration or in case a postprocessing event failed. +your nzbclient for testing your configuration or in case a postprocessing event failed. To do this, execute sabToCouchPotato.py e.g. via ssl issue the following command: #./sabToCouchPotato.py when in the directory where sabToCouchPotato.py is located. \ No newline at end of file From 454f989c1baa3562b534d56fd389820abaee8b56 Mon Sep 17 00:00:00 2001 From: Jurgen S Date: Tue, 20 Nov 2012 19:25:42 +0100 Subject: [PATCH 3/5] Revised installation details --- README.md | 100 +++++++++++++++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index c799506e..e3be047f 100644 --- a/README.md +++ b/README.md @@ -1,51 +1,51 @@ -nzbgetToCouchPotato -=================== - -Provides NZBGet postprocessing for CouchPotatoServer, based on sabToCouchPotato from clinton-hall - -To get this to work with NZBGet you have to do the following: - -1) Put all the files eg. in a directory named /scripts and change the permission so nzbget can use them. - -2) Add the following lines into postprocess.conf in the "PATH" section: - - # Set the full path to sabToCouchpotato.py for Couchpotato's postprocessing - SabToCouchpotato=/usr/local/nzbget/var/scripts/sabToCouchpotato.py - -3) Add the following lines into postproecess.sh right before the line "# Check if destination directory was set in postprocessing parameters" - - if [ $NZBPP_CATEGORY = "movies" -a -e "$SabToCouchpotato" ]; then - # Call Couchpotatos postprocessing script - echo "[INFO] Post-Process: Running Couchpotato's postprocessing script ($SabToCouchpotato $NZBPP_DIRECTORY $NZBPP_NZBFILENAME)" - $PythonCmd $SabToCouchpotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" >/dev/null 2>&1 - fi - -4)Rename the file autoProcessMovie.cfg.sample to autoProcessMovie.cfg and fill in the appropriate fields as they apply to your installation. - -[Notes_On_Delay] - delay must be a minimum of 60 seconds for the renamer.scan to run successfully. CouchPotato - performs a test to ensure files/folder are not newer than 1 minute to prevent renaming of - files that are still extracting. - -[Notes_On_Method_renamer] - method "renamer" is the default which will cause CouchPotato to move and rename downloaded files - as specified in the CouchPotato renamer settings. - This will also add the movie to the manage list and initiate any configured notifications. - In this case SABnzbd (or your download client) must extract the files to the "from" folder - as specified in your CouchPotato renamer settings. Renamer must be enabled but you should - increase the "run every" option in CouchPotato renamer settings (advanced settings) to only - run daily (1440) or weekly (10080) or automatic scan can be disabled by setting run every =0. - -[Notes_On_Method_manage] - method "manage" will make CouchPotato update the list of managed movies if manager - is enabled but renamer is not enabled. - In this case SABnzbd (or your download client) must extract the files directly - to your final movies folder (as configured in CouchPotato manage settings) and Manage must - be enabled. - -If you have added .py to your PATHEXT (in windows) or you have given sabToCouchPotato.py executable -permissions, or you are using the compiled executables you can manually call this process outside of -your nzbclient for testing your configuration or in case a postprocessing event failed. -To do this, execute sabToCouchPotato.py -e.g. via ssl issue the following command: #./sabToCouchPotato.py +nzbgetToCouchPotato +=================== + +Provides NZBGet postprocessing for CouchPotatoServer, based on sabToCouchPotato from clinton-hall + +To get this to work with NZBGet you have to do the following: + +1) Put all the files eg. in a directory wherever you want to keep them (eg. /scripts/ in the home directory of nzbget) and change the permission accordingly so nzbget has access to this files. + +2) Add the following lines into nzbget's postprocess.conf in the "PATH" section: + + # Set the full path to sabToCouchpotato.py for Couchpotato's postprocessing + SabToCouchpotato=/usr/local/nzbget/var/scripts/sabToCouchpotato.py + +3) Add the following lines into nzbget's postprocess.sh right before the line "# Check if destination directory was set in postprocessing parameters" + + if [ $NZBPP_CATEGORY = "movies" -a -e "$SabToCouchpotato" ]; then + # Call Couchpotatos postprocessing script + echo "[INFO] Post-Process: Running Couchpotato's postprocessing script ($SabToCouchpotato $NZBPP_DIRECTORY $NZBPP_NZBFILENAME)" + $PythonCmd $SabToCouchpotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" >/dev/null 2>&1 + fi + +4)Rename the file autoProcessMovie.cfg.sample to autoProcessMovie.cfg and fill in the appropriate fields as they apply to your installation. + +[Notes_On_Delay] + delay must be a minimum of 60 seconds for the renamer.scan to run successfully. CouchPotato + performs a test to ensure files/folder are not newer than 1 minute to prevent renaming of + files that are still extracting. + +[Notes_On_Method_renamer] + method "renamer" is the default which will cause CouchPotato to move and rename downloaded files + as specified in the CouchPotato renamer settings. + This will also add the movie to the manage list and initiate any configured notifications. + In this case SABnzbd (or your download client) must extract the files to the "from" folder + as specified in your CouchPotato renamer settings. Renamer must be enabled but you should + increase the "run every" option in CouchPotato renamer settings (advanced settings) to only + run daily (1440) or weekly (10080) or automatic scan can be disabled by setting run every =0. + +[Notes_On_Method_manage] + method "manage" will make CouchPotato update the list of managed movies if manager + is enabled but renamer is not enabled. + In this case SABnzbd (or your download client) must extract the files directly + to your final movies folder (as configured in CouchPotato manage settings) and Manage must + be enabled. + +If you have added .py to your PATHEXT (in windows) or you have given sabToCouchPotato.py executable +permissions, or you are using the compiled executables you can manually call this process outside of +your nzbclient for testing your configuration or in case a postprocessing event failed. +To do this, execute sabToCouchPotato.py +e.g. via ssl issue the following command: #./sabToCouchPotato.py when in the directory where sabToCouchPotato.py is located. \ No newline at end of file From 8d7bea83e5f5e161c34d299b434d306057332e40 Mon Sep 17 00:00:00 2001 From: Jurgen S Date: Wed, 21 Nov 2012 00:30:54 +0100 Subject: [PATCH 4/5] corrected path --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e3be047f..bd3c2eb1 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ To get this to work with NZBGet you have to do the following: 2) Add the following lines into nzbget's postprocess.conf in the "PATH" section: # Set the full path to sabToCouchpotato.py for Couchpotato's postprocessing - SabToCouchpotato=/usr/local/nzbget/var/scripts/sabToCouchpotato.py + SabToCouchpotato=/sabToCouchpotato.py 3) Add the following lines into nzbget's postprocess.sh right before the line "# Check if destination directory was set in postprocessing parameters" From 301e889026652e5ce00095180c0a09d7d5861be1 Mon Sep 17 00:00:00 2001 From: Jurgen S Date: Sun, 25 Nov 2012 03:06:55 +0100 Subject: [PATCH 5/5] Renamed project and added installation details --- README.md | 111 ++++++++++++++++++++++++++++---------------- nzbToCouchPotato.py | 32 +++++++++++++ sabToCouchPotato.py | 20 -------- 3 files changed, 103 insertions(+), 60 deletions(-) create mode 100644 nzbToCouchPotato.py delete mode 100644 sabToCouchPotato.py diff --git a/README.md b/README.md index bd3c2eb1..6ff47da5 100644 --- a/README.md +++ b/README.md @@ -1,51 +1,82 @@ -nzbgetToCouchPotato -=================== +nzbToCouchPotato +================ -Provides NZBGet postprocessing for CouchPotatoServer, based on sabToCouchPotato from clinton-hall +Provides an efficient way to handle postprocessing for [CouchPotatoServer](https://couchpota.to/ "CouchPotatoServer") +when using one of the popular NZB download clients like [SABnzbd](http://sabnzbd.org/) and [NZBGet](http://nzbget.sourceforge.net/ "NZBGet") on low performance systems like a NAS. +This script is based on [sabToCouchPotato] (https://github.com/clinton-hall/sabToCouchPotato "sabToCouchPotato") from Clinton Hall, but extends the original script with the support for NZBGet. -To get this to work with NZBGet you have to do the following: +Introduction +------------ +My Synology DS211j was too weak to provide decent downloads rates with SABnzbd and CouchPotatoServer even by using sabToCouchPotato. +The only alternative was to switch to NZBGet which uses far less resources and helped to reach the full download speed. +But i was still unsatisfied as i could not use sabToCouchPotato anymore. +Even worse the renamer of CouchPotatoServer caused broken downloads by interfering with NZBGet while it was still unpacking the files. +In needed a solution and out of this motivation i started working on a own version of sabToCouchPotato named "nzbToCouchPotato". -1) Put all the files eg. in a directory wherever you want to keep them (eg. /scripts/ in the home directory of nzbget) and change the permission accordingly so nzbget has access to this files. +Installation +------------ +### General +1. Put all files in a directory wherever you want to keep them (eg. /scripts/ in the home directory of your nzb client) + and change the permission accordingly so the nzb client can access to this files. -2) Add the following lines into nzbget's postprocess.conf in the "PATH" section: +2. Rename the file autoProcessMovie.cfg.sample to autoProcessMovie.cfg and fill in the appropriate + fields as they apply to your installation. - # Set the full path to sabToCouchpotato.py for Couchpotato's postprocessing - SabToCouchpotato=/sabToCouchpotato.py + [Notes_On_Delay] + Delay must be a minimum of 60 seconds for the renamer.scan to run successfully. CouchPotato + performs a test to ensure files/folder are not newer than 1 minute to prevent renaming of + files that are still extracting. -3) Add the following lines into nzbget's postprocess.sh right before the line "# Check if destination directory was set in postprocessing parameters" + [Notes_On_Method_renamer] + Method "renamer" is the default which will cause CouchPotato to move and rename downloaded files + as specified in the CouchPotato renamer settings. + This will also add the movie to the manage list and initiate any configured notifications. + In this case your nzb client must extract the files to the "from" folder + as specified in your CouchPotato renamer settings. Renamer must be enabled + but automatic scan can be disabled by setting "Run Every" to "0". - if [ $NZBPP_CATEGORY = "movies" -a -e "$SabToCouchpotato" ]; then - # Call Couchpotatos postprocessing script - echo "[INFO] Post-Process: Running Couchpotato's postprocessing script ($SabToCouchpotato $NZBPP_DIRECTORY $NZBPP_NZBFILENAME)" - $PythonCmd $SabToCouchpotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" >/dev/null 2>&1 - fi + [Notes_On_Method_manage] + Method "manage" will make CouchPotato update the list of managed movies if manager + is enabled but renamer is not enabled. + In this case your nzb client must extract the files directly + to your final movies folder (as configured in CouchPotato manage settings) and Manage must + be enabled. -4)Rename the file autoProcessMovie.cfg.sample to autoProcessMovie.cfg and fill in the appropriate fields as they apply to your installation. +3. If you have added .py to your PATHEXT (in windows) or you have given nzbToCouchPotato.py executable + permissions, or you are using the compiled executables you can manually call this process outside of + your nzb client for testing your configuration or in case a postprocessing event failed. + To do this, execute nzbToCouchPotato.py e.g. via ssl issue the following command: + $ ./nzbToCouchPotato.py when in the directory where nzbToCouchPotato.py is located. -[Notes_On_Delay] - delay must be a minimum of 60 seconds for the renamer.scan to run successfully. CouchPotato - performs a test to ensure files/folder are not newer than 1 minute to prevent renaming of - files that are still extracting. +### SABnzbd +If you are using SABnzbd perform the following steps to configure postprocessing for "nzbToCouchPotato": -[Notes_On_Method_renamer] - method "renamer" is the default which will cause CouchPotato to move and rename downloaded files - as specified in the CouchPotato renamer settings. - This will also add the movie to the manage list and initiate any configured notifications. - In this case SABnzbd (or your download client) must extract the files to the "from" folder - as specified in your CouchPotato renamer settings. Renamer must be enabled but you should - increase the "run every" option in CouchPotato renamer settings (advanced settings) to only - run daily (1440) or weekly (10080) or automatic scan can be disabled by setting run every =0. +1. In SABnzbd go to "Config" -> "Folders", then configure in the section "User Folders" + the option "Post-Processing Scripts Folder" with the path where you keep the post-processings scripts for SABnzbd. + +2. Then go to "Config" -> "Categories" + and configure the category which you want to use for CouchPotato (eg. movies) + then select "nzbToCouchPotato.py" as the script that shall be executed after the job was finished by SABnzbd. + +3. For better handling of failed downloads in version 0.7.5 of SABnzbd a new special parameter named "empty_postproc" was introduced, + so at last go to "Config" -> "Special" in the web-interface and tick the option "empty_postproc". + + Description of this special parameter according to SABnzbd manual: + > Do post-processing and run the user script even if nothing has been downloaded. + This is useful in combination with tools like SickBeard, for which running the script on an empty or failed download is a trigger to try an alternative NZB. + Note that the "Status" parameter for the script will be -1. [0.7.5+ only] + +### NZBGet +If you are using NZBGet perform the following steps to configure postprocessing for "nzbToCouchPotato": -[Notes_On_Method_manage] - method "manage" will make CouchPotato update the list of managed movies if manager - is enabled but renamer is not enabled. - In this case SABnzbd (or your download client) must extract the files directly - to your final movies folder (as configured in CouchPotato manage settings) and Manage must - be enabled. - -If you have added .py to your PATHEXT (in windows) or you have given sabToCouchPotato.py executable -permissions, or you are using the compiled executables you can manually call this process outside of -your nzbclient for testing your configuration or in case a postprocessing event failed. -To do this, execute sabToCouchPotato.py -e.g. via ssl issue the following command: #./sabToCouchPotato.py -when in the directory where sabToCouchPotato.py is located. \ No newline at end of file +1. Replace the config files with the ones from the download below according to the version you are using (0.8.0 or 9.0): + https://github.com/downloads/thorli/nzbToCouchPotato/nzbget-postprocessing-files.zip + + These files enable additional postprocessing settings for CouchPotato (and SickBeard as well) in the NZBGet webinterface. + If NZBGet is running either restart (0.8.0) or reload (9.0) to activate the changes after you have replaced the files. + To be on the safe side, don't forget to make a backup of the existing files! + +2. In NZBGet go to "POSTPROCESSING SCRIPT" -> "PATHS" and apply the option "NzbToCouchpotato" according to your environment, + this setting configures the path where NZBGet has to look for "nzbToCouchpotato.py". + +3. Then go to "POSTPROCESSING SCRIPT" -> "OPTIONS" and set there the category which you want to use for CouchPotato post-processing. \ No newline at end of file diff --git a/nzbToCouchPotato.py b/nzbToCouchPotato.py new file mode 100644 index 00000000..1fc4cd6b --- /dev/null +++ b/nzbToCouchPotato.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +import sys +import autoProcessMovie + +# SABnzbd +if len(sys.argv) == 8: +# 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 autoProcessMovie..." + autoProcessMovie.process(sys.argv[1], sys.argv[2], sys.argv[7]) + +# NZBGet +elif len(sys.argv) == 3: +# NZBGet argv: +# 1 The final directory of the job (full path) +# 2 The original name of the NZB file +# From NZBGet only successful downloads are triggered so status is set to "0" + print "Script triggered from NZBGet, starting autoProcessMovie..." + + autoProcessMovie.process(sys.argv[1], sys.argv[2], 0) + +else: + print "Invalid number of arguments received from client." + print "Running autoProcessMovie as a manual run..." + autoProcessMovie.process('Manual Run', 'Manual Run', 0) diff --git a/sabToCouchPotato.py b/sabToCouchPotato.py deleted file mode 100644 index ef4a4276..00000000 --- a/sabToCouchPotato.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python - -import sys -import autoProcessMovie - -if len(sys.argv) < 2: - print "Not enough arguments received from NZBGet." - print "Running autoProcessMovie as a manual run" - autoProcessMovie.process('Manual Run', 'Manual Run', 0) -else: - status = 0 - autoProcessMovie.process(sys.argv[1], sys.argv[2], status) - - -# NZBGet argv: -# 1 The final directory of the job (full path) -# 2 The original name of the NZB file -# 3 Status of post processing. 0 = OK - -