Code: Select all
#!/usr/bin/env python
###########################################
### NZBGET POST-PROCESSING SCRIPT ###
# Update media library if queue is empty.
### NZBGET POST-PROCESSING SCRIPT ###
###########################################
import os
import sys
try:
from xmlrpclib import ServerProxy # python 2
except ImportError:
from xmlrpc.client import ServerProxy # python 3
# Exit codes used by NZBGet
POSTPROCESS_SUCCESS=93
POSTPROCESS_ERROR=94
POSTPROCESS_NONE=95
# To get the item log we connect to NZBGet via XML-RPC and call
# method "loadlog", which returns the log for a given nzb item.
# For more info visit http://nzbget.net/RPC_API_reference
# First we need to know connection info: host, port and password of NZBGet server.
# NZBGet passes all configuration options to post-processing script as
# environment variables.
host = os.environ['NZBOP_CONTROLIP'];
port = os.environ['NZBOP_CONTROLPORT'];
username = os.environ['NZBOP_CONTROLUSERNAME'];
password = os.environ['NZBOP_CONTROLPASSWORD'];
if host == '0.0.0.0': host = '127.0.0.1'
# Build an URL for XML-RPC requests
rpcUrl = 'http://%s:%s@%s:%s/xmlrpc' % (username, password, host, port);
# Create remote server object
server = ServerProxy(rpcUrl)
# Call remote method 'listgroups'.
groups = server.listgroups()
# Check if queue is not empty
if len(groups) > 0:
# Queue is not empty, exiting
sys.exit(POSTPROCESS_NONE)
# Here insert your code to update library
#call a bat script
os.system('C:\\Users\\Software\\Scripts\\Delete.bat')
sys.exit(POSTPROCESS_SUCCESS)
I am not a coder and this is from trial and error.
Can somebody point me in the right direction? Thanks