What's new
PGBlitz.com

Register Now! Find useful tips, Interact /w Community Members and join the part the Best Community on the Internet!

Discussion Add to NZBGet queue automatically from pgtrakt when empty?

BornSlacker

Junior Member
Patron
Hello,

Is it possible to have a nzbget post processing script that will automatically call a shell script to execute a pgtrakt command when the nzbget queue is empty?

I have a custom movie and tv list on Trakt I’d like to process two shows at a time. Add two tv shows, let them completely download, wait an hour or so, and then add two more.

That hour break gives me time to double check that everything was downloaded in the quality I wanted, delete any bogus files, etc.

I know you can have nzbget postprocessing scripts that call a shell command, but I’m not sure how to structure the shell command or make it so the script fires when the queue is empty.
 

BornSlacker

Junior Member
Patron
I was able to find this script online. Now I just need help with creating a .sh file I can execute from this script that will ssh into my box and run a pgtrakt command. Something like "pgtrakt movies -t trending -l 2"

Python:
#!/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:%[email protected]%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) > 1:
    # 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)
Anyone willing to help a noob out?
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.


Development Donations

 

Top NZB NewsGroups!

Members - Up To a 58% Discount!

Trending

Online statistics

Members online
5
Guests online
79
Total visitors
84
Top