Page 1 of 1

grab nzo_id in post script

Posted: October 9th, 2018, 3:43 pm
by GhostCOM97
Hi

I'm not familiar with python, so how would a post-processing script look like if would like to get the nzo_id for the just downloaded item and save it for later use ?

Re: grab nzo_id in post script

Posted: October 9th, 2018, 3:47 pm
by safihre
You could get it from the os.env variables, see the wiki for the right key :)

You do know a tiny bit of python?

Re: grab nzo_id in post script

Posted: December 28th, 2018, 5:07 pm
by GhostCOM97
Only some and it is giving me some troubble.

have this script as of now, but it is not working. I dont know how from python directly delete something from the history, so I'm building this url to do so via the REST api. The goal is to build and call a url like this:
The url gets build correctly. If I let it print the url into the SABnzbs logs I can cut and paste into a curl command or webbrowser and it will delete the specified SAB_NZO_ID from the history. Modifiing the script to manually define the SAB_NZO_ID works as well - the troubble is that when SABnzbd calls the script it does not work. No errors - just nothing happens.

Code: Select all

import os
import sys
import urllib2

urlopen = urllib2.urlopen
nzoid = os.environ.get('SAB_NZO_ID', '')
apikey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
baseurl = 'http://10.0.0.10:8080/'
url = '%sapi?mode=history&name=delete&value=%s&apikey=%s' % (baseurl, nzoid, apikey)
#print url
r = urlopen(url)
sys.exit(0)

Re: grab nzo_id in post script

Posted: December 28th, 2018, 5:36 pm
by safihre
Aaah that's what you want.
You can't do that, because when the script is called it's not in a state that allows it to be removed.

If you want no history to be kept, you can use History Retention setting in Config Switches and set it to Number=0