Skip to content

Instantly share code, notes, and snippets.

@vanhecke
Last active March 5, 2017 12:14
Show Gist options
  • Save vanhecke/e18209d4e207218eb5415c194df63483 to your computer and use it in GitHub Desktop.
Save vanhecke/e18209d4e207218eb5415c194df63483 to your computer and use it in GitHub Desktop.
NZBGet post-processor that notifies SickRage of failure/success.
@echo off
goto start:
########################################
### NZBGET POST-PROCESSING SCRIPT ###
# SickRage notifier
#
# This simple script will notify sickrage of completed downloads
################################
### OPTIONS ###
# SickRage API Key.
#sickrage_api_key=b8248a790bd6842dcf0ce359eff3201c
# SickRage URL.
#sickrage_url=http://localhost:8081
# Waits for the current processing queue item to finish and returns result of this request (yes, no).
#force_next=yes
# Force already post-processed files to be post-processed again (yes, no).
#force_replace=yes
# Replace the file even if it exists in a higher quality (yes, no).
#is_priority=no
# How should valid post-processed files be handled (copy, symlink, hardlink, move).
#process_method=move
# The type of post-process being requested (auto, manual).
#type=auto
# Delete processed files and folders (yes, no).
#delete=yes
### NZBGET POST-PROCESSING SCRIPT ###
#########################################
rem Return an exit code understood by nzbget
rem # Exit codes used by NZBGet
rem POSTPROCESS_SUCCESS=93
rem POSTPROCESS_NONE=95
rem POSTPROCESS_ERROR=94
rem URL: /api/KEY/?cmd=postprocess&failed=1&force_next=1&force_replace=1&is_priority=0&path=PATH&return_data=1&process_method=move&type=auto&delete=1
:start
rem echo Here is a smattering of NZBget server variables:
rem echo NZBPP_DIRECTORY="%NZBPP_DIRECTORY%"
rem echo NZBPP_NZBNAME="%NZBPP_NZBNAME%"
rem echo status = %NZBPP_TOTALSTATUS%
rem get settings
if "%NZBPO_force_next%" == "yes" ( set force_next=1) else ( set force_next=0)
if "%NZBPO_force_replace%" == "yes" ( set force_replace=1) else ( set force_replace=0)
if "%NZBPO_is_priority%" == "yes" ( set is_priority=1) else ( set is_priority=0)
if "%NZBPO_delete%" == "yes" ( set delete=1) else ( set delete=0)
rem get variables
if "%NZBPP_TOTALSTATUS%" == "SUCCESS" ( set failed=0) else ( set failed=1)
set path=%NZBPP_DIRECTORY%
set sickrage_url=%NZBPO_sickrage_url%
set sickrage_api_key=%NZBPO_sickrage_api_key%
set type=%NZBPO_type%
set process_method=%NZBPO_process_method%
set url="%sickrage_url%api/%sickrage_api_key%/?cmd=postprocess&failed=%failed%&force_next=%force_next%&force_replace=%force_replace%&is_priority=%is_priority%&path=%path%&return_data=1&process_method=%process_method%&type=%type%&delete=%delete%"
echo "Notifying SickRage..."
#echo %url%
%~dp0curl -s %url%
exit /B 93
@vanhecke
Copy link
Author

vanhecke commented Mar 5, 2017

This script expects to have a working curl.exe in the same directory.
You can download curl for windows here: https://bintray.com/vszakats/generic/curl/

If you already have curl in your PATH or want to use something else, edit line 70.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment