I've been wanting to put together an API call that I could throw in a post-processing script and would delete all history for the "movies" category. I came up with the following API call hoping it would do just that, however when I tested it, it deleted ALL history by accident
So I guess I was kind of in the right ballpark, just not right enough
Would anyone mind taking a peak and tweaking it to how it should be written to ONLY delete history from the "movies" category?
http://localhost:port/sabnzbd/api?mode=history&category=movies&name=delete&value=all&apikey=MYAPIKEY
Thank you!
a little API help?
Forum rules
Help us help you:
Help us help you:
- Are you using the latest stable version of SABnzbd? Downloads page.
- Tell us what system you run SABnzbd on.
- Adhere to the forum rules.
- Do you experience problems during downloading?
Check your connection in Status and Interface settings window.
Use Test Server in Config > Servers.
We will probably ask you to do a test using only basic settings. - Do you experience problems during repair or unpacking?
Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Re: a little API help?
Two steps:
Get all NZO_IDs in category movies like this:
https://sabnzbd.org/wiki/advanced/api#history says
category optional Only return jobs in this category (Only 1.0.0+)
Then delete those NZO_IDs like this
https://sabnzbd.org/wiki/advanced/api#delete_history tells
api?mode=history&name=delete&value=NZO_ID_1,NZO_ID_2,NZO_ID_3
Get all NZO_IDs in category movies like this:
https://sabnzbd.org/wiki/advanced/api#history says
category optional Only return jobs in this category (Only 1.0.0+)
Then delete those NZO_IDs like this
https://sabnzbd.org/wiki/advanced/api#delete_history tells
api?mode=history&name=delete&value=NZO_ID_1,NZO_ID_2,NZO_ID_3
Re: a little API help?
I'm having trouble identifying the NZO_ID's.. I tried running "api?mode=queue&start=START&limit=LIMIT&search=SEARCH" as that looks like it resulted in listing NZO_ID's in that big output on the wiki, so I ran it but nothing about NZO_ID's. Lists a bunch of other information instead.
I'm really very much a noob when it comes to API stuff. Are you able to give me a little more specific instructions on what I need to do to identify these NZO_ID's? Thanks
I'm really very much a noob when it comes to API stuff. Are you able to give me a little more specific instructions on what I need to do to identify these NZO_ID's? Thanks
Re: a little API help?
Before starting you should know that a job can't delete itself from history, or at least it will not be pretty.
Make sure you add &mode=json the output should be more structured.
The nzo_id is listed under queue > slots > 0 > nzo_id
Make sure you add &mode=json the output should be more structured.
The nzo_id is listed under queue > slots > 0 > nzo_id
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
Re: a little API help?
Before I go further with this then, is there even a point in trying, or an alternative method I'm not utilizing (if I'm going about this the wrong way)? I would just like certain categories to not be retained in the history. If there's a different or better way to skin that cat, I'm all ears.
Re: a little API help?
If you want to avoid the limitation safihre mentioned you could just as well run your script as a cronjob (or whatever scheduler option your os provides).
Removing a subset of completed jobs from the history through the api isn't a problem, the only "but" being that this specific subset cannot be done in a single call. You'll need your script to do two api calls: the first to get info on all completed jobs in the history; then, after selecting the ids of the ones that match your deletion criteria, a second call for the delete action.
Removing a subset of completed jobs from the history through the api isn't a problem, the only "but" being that this specific subset cannot be done in a single call. You'll need your script to do two api calls: the first to get info on all completed jobs in the history; then, after selecting the ids of the ones that match your deletion criteria, a second call for the delete action.
Re: a little API help?
You can also use the History Retention setting in Config Switches, although it applies for the whole history and not 1 category.
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate