Delete files with specific text in already added job in queue?

Come up with a useful post-processing script? Share it here!
Post Reply
iUseNetter
Jr. Member
Jr. Member
Posts: 81
Joined: December 1st, 2019, 2:53 pm

Delete files with specific text in already added job in queue?

Post by iUseNetter »

I have written a python script which works fine if I execute it in a SSH console window on my Synology NAS with

Code: Select all

python3 DeleteSampleFilesFromJob.sh
This script uses the API calls to retrieve the queue details, looking for filenames with "sample" or "nfo" and eventually execute delete_nzf.

(Just imagine: It's the same as if I were to click on the ‘Edit NZB details - Password’ icon and manually select all entries with ‘sample’ or ‘nfo’ in their name and then click on the ‘Remove all selected entries’ icon at the bottom of the details window)

But I can't get SABnzbd to run this script automatically when a new NZB is added via drag & drop.

Where exactly do I have to set/use such a script so that it is always executed after all listed files in a NZB have been added to the queue (in a job)?
Last edited by iUseNetter on May 4th, 2025, 4:52 am, edited 1 time in total.
iUseNetter
Jr. Member
Jr. Member
Posts: 81
Joined: December 1st, 2019, 2:53 pm

Re: Delete files with specific text in already added job in queue?

Post by iUseNetter »

I would not ask, if it would be that easy ;)

The script itself works from command-line.
Where do I have to set it in SABnzbd to be executed after adding a new Job?

And as you know for Pre-queue scripts:
You can choose to let SABnzbd run a script just before an NZB enters the queue.
My script should be executed AFTER the Job is added to the queue.
User avatar
sander
Release Testers
Release Testers
Posts: 9254
Joined: January 22nd, 2008, 2:22 pm

Re: Delete files with specific text in already added job in queue?

Post by sander »

Sab has no handle for that

Suggestions:

Cron job
Sleep 50
User avatar
safihre
Administrator
Administrator
Posts: 5580
Joined: April 30th, 2015, 7:35 am
Contact:

Re: Delete files with specific text in already added job in queue?

Post by safihre »

But why not use the Config Switches option to delete samples?
Might kee nfo files but those are tiny tiny.
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
iUseNetter
Jr. Member
Jr. Member
Posts: 81
Joined: December 1st, 2019, 2:53 pm

Re: Delete files with specific text in already added job in queue?

Post by iUseNetter »

safihre wrote: May 4th, 2025, 6:53 am But why not use the Config Switches option to delete samples?
Might kee nfo files but those are tiny tiny.
I want to prevent the unnecessary mkv sample files (and also the nfo files) from being downloaded and not that they are only deleted after the download.

The nfo files are tiny, you are right.
But the mkv movie sample are (for me) just unnecessary garbage.
User avatar
safihre
Administrator
Administrator
Posts: 5580
Joined: April 30th, 2015, 7:35 am
Contact:

Re: Delete files with specific text in already added job in queue?

Post by safihre »

We used to remove them already in the queue, but the resulted in problems where the samples were part of the par2 set. So removing them would then force those jobs through repair or even fail if not enough blocks were available.
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
iUseNetter
Jr. Member
Jr. Member
Posts: 81
Joined: December 1st, 2019, 2:53 pm

Re: Delete files with specific text in already added job in queue?

Post by iUseNetter »

Thank you for your explanation, @safihre

I see no difference between manually deleting the sample and nfo files in the mentioned “Edit NZB details - Password” window and automatic deletion by a script.

Example:
Image

But if we don't have the technical possibility to automatically execute API calls to a job in the Queue (after the job is added to it), then that's how it is.
User avatar
safihre
Administrator
Administrator
Posts: 5580
Joined: April 30th, 2015, 7:35 am
Contact:

Re: Delete files with specific text in already added job in queue?

Post by safihre »

Indeed, there's only a pre queue script and not one after the job was added to the queue.
You might have to just set some cronjob to do it, unfortunately.
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
Post Reply