Help with script to delete completed history

Come up with a useful post-processing script? Share it here!
Post Reply
ash881
Newbie
Newbie
Posts: 3
Joined: March 19th, 2012, 1:56 am

Help with script to delete completed history

Post by ash881 »

Hi all,

I need some help with a script that can delete the history (the same as if you were to open the web ui and click 'delete completed").

I currently have script set up that runs after the queue is finished. The script grabs the data from the history rss feed (http://localhost:8080/sabnzbd/rss?mode=history) and dumps it as an xml file on my desktop. - basically a log of what has been downloaded during the day. ( I didn't write this script I found it on the net - so don't ask me how it does what it does).

This allows me to come home, open the file sitting on the desktop and see exactly what has happened during the day.

The issue is - unless the history is deleted after reading the log, all of the history from this log will be included in the next history log since it is still sitting in sab's history.

I'm looking for something that I can run after I have read the log (it would be launched manually by a key combination) that would delete sab's history and then delete the xml from the desktop..

So basically I come home, read the log on the desktop, close the log, and then hit a key combo which launches the script which clears the history and deletes the log from the desktop.

Any help would be great.

Thanks, Ash
User avatar
sander
Release Testers
Release Testers
Posts: 8812
Joined: January 22nd, 2008, 2:22 pm

Re: Help with script to delete completed history

Post by sander »

Deleting SAB 's history can be done via the API; see http://wiki.sabnzbd.org/api#toc42:

Deleting all items:
URL: api?mode=history&name=delete&value=all

A curl / wget / lynx command should be able to do that. Do you have one of those three installed?

Deleting the log file can be done via the operating system by just deleting the file (I guess; not tested).

You can put both commands in a shell script. It depends on your operating system how the script should look like.
ash881
Newbie
Newbie
Posts: 3
Joined: March 19th, 2012, 1:56 am

Re: Help with script to delete completed history

Post by ash881 »

Thanks for the fast reply.

I've just installed Curl (having never used it before) but am not sure how to send the api key.

I've tried using this url:

Code: Select all

http://localhost:8080/sabnzbd/api?mode=history&name=delete&value=all&apikey=XXXXXXXXXXXXXXXXXXXXXXX
The url works fine when entered accessed through my browser, it returns an "ok" message and the history is cleared.

But when using it with Curl I get "error Api Key required".
User avatar
sander
Release Testers
Release Testers
Posts: 8812
Joined: January 22nd, 2008, 2:22 pm

Re: Help with script to delete completed history

Post by sander »

How about putting (double?) quotes around the complete URL?
ash881
Newbie
Newbie
Posts: 3
Joined: March 19th, 2012, 1:56 am

Re: Help with script to delete completed history

Post by ash881 »

Brilliant, that was all it needed. Works like a charm now.

Thanks very much for your help.

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

Re: Help with script to delete completed history

Post by GhostCOM97 »

It would be reallly great if you could from the API delete just a specific category from the history e.g. "TV" or something else configures under http://localhost:8080/config/categories/
User avatar
jcfp
Release Testers
Release Testers
Posts: 986
Joined: February 7th, 2008, 12:45 pm

Re: Help with script to delete completed history

Post by jcfp »

GhostCOM97 wrote: September 17th, 2019, 3:25 am It would be reallly great if you could from the API delete just a specific category from the history e.g. "TV" or something else configures under http://localhost:8080/config/categories/
Should be possible already? First api call to get the history output limited to a specific category, collect ids from that; then a second api call to delete those.
Post Reply