grab nzo_id in post script

Come up with a useful post-processing script? Share it here!
Post Reply
GhostCOM97
Newbie
Newbie
Posts: 3
Joined: October 26th, 2017, 7:20 am

grab nzo_id in post script

Post by GhostCOM97 » October 9th, 2018, 3:43 pm

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 ?

User avatar
safihre
Administrator
Administrator
Posts: 3042
Joined: April 30th, 2015, 7:35 am
Location: Switzerland
Contact:

Re: grab nzo_id in post script

Post by safihre » October 9th, 2018, 3:47 pm

You could get it from the os.env variables, see the wiki for the right key :)

You do know a tiny bit of python?

GhostCOM97
Newbie
Newbie
Posts: 3
Joined: October 26th, 2017, 7:20 am

Re: grab nzo_id in post script

Post by GhostCOM97 » December 28th, 2018, 5:07 pm

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)

User avatar
safihre
Administrator
Administrator
Posts: 3042
Joined: April 30th, 2015, 7:35 am
Location: Switzerland
Contact:

Re: grab nzo_id in post script

Post by safihre » December 28th, 2018, 5:36 pm

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

Post Reply