API call to update filter in rss feed

Get help with all aspects of SABnzbd
Forum rules
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.
Post Reply
e38383
Newbie
Newbie
Posts: 3
Joined: March 23rd, 2025, 5:30 am

API call to update filter in rss feed

Post by e38383 »

I'm trying to update a specific filter in one of my RSS feeds, but whatever I'm trying it doesn't update the filter. So far I got this:

Code: Select all

/api?output=json&mode=set_config&section=rss&keyword=rss+feed+name&filter10=%2C%2C%2CS%2CShow+Name+S03E59%2C-100%2C1
It's working if I try to set enable=0, so the basic call is correct. I just can't find out how to set a filter. I tried various combinations for filter10 (with spaces after the ",", None instead of empty fields, …), but I always get the same config back with nothing changed.

The web-interface is using a completely different method:

Code: Select all

index=10&feed=rss+feed+name&enabled=1&new_index=10&filter_type=S&filter_text=Show+Name+S03E59&cat=Default&priority=-100&pp=&script=Default
But that's not working over the API either.

So, how can I change one specific filter via the API?
User avatar
sander
Release Testers
Release Testers
Posts: 9221
Joined: January 22nd, 2008, 2:22 pm

Re: API call to update filter in rss feed

Post by sander »

Documentation https://sabnzbd.org/wiki/configuration/ ... set_config says
RSS feed example: api?mode=set_config&section=rss&name=FEED_NAME&enable=VALUE_1&pp=VALUE_2

So let's try that:

Code: Select all

curl -s 'http://127.0.0.1:8080/api?output=json&apikey=335ca9bb72554157864aa3c94d8f0aff&mode=set_config&section=rss&name=FEED_NAME&enable=VALUE_1&pp=VALUE_2'
... which does result in ~/.sabnzbd/sabnzbd.ini :

Code: Select all

[[FEED_NAME]]
name = FEED_NAME
uri = ,
cat = ""
pp = VALUE_2
script = ""
enable = 0
priority = -100
filter0 = "", "", "", A, *, -100, 1
So that does work for me. For you too?
User avatar
sander
Release Testers
Release Testers
Posts: 9221
Joined: January 22nd, 2008, 2:22 pm

Re: API call to update filter in rss feed

Post by sander »

Code: Select all

curl  'http://127.0.0.1:8080/api?output=json&apikey=335ca9bb72554157864aa3c94d8f0aff&mode=set_config&section=rss&name=GORDON2&uri=https://nzbindex.nl/search/rss?q=gordon'
results in

Code: Select all

[[GORDON2]]
name = GORDON2
uri = https://nzbindex.nl/search/rss?q=gordon,
cat = ""
pp = ""
script = ""
enable = 0
priority = -100
filter0 = "", "", "", A, *, -100, 1
e38383
Newbie
Newbie
Posts: 3
Joined: March 23rd, 2025, 5:30 am

Re: API call to update filter in rss feed

Post by e38383 »

sander wrote: March 23rd, 2025, 12:02 pm RSS feed example: api?mode=set_config&section=rss&name=FEED_NAME&enable=VALUE_1&pp=VALUE_2



So that does work for me. For you too?
Yes, I can set enable and other top-level keys. But I need to edit a filter.
User avatar
sander
Release Testers
Release Testers
Posts: 9221
Joined: January 22nd, 2008, 2:22 pm

Re: API call to update filter in rss feed

Post by sander »

Ah, yes, I now understand your question now.

... and I tried a few things but couldn't the the correct input for filter either. Sorry.
User avatar
sander
Release Testers
Release Testers
Posts: 9221
Joined: January 22nd, 2008, 2:22 pm

Re: API call to update filter in rss feed

Post by sander »

FWIW: those None and empties: the format is like this
filter0 = tv, 3, bla.sh, A, dit, 1, 1
filter1 = "", "", "", A, heracles, -100, 1
filter2 = None, "", None, R, *, None, 1

So with my guess from the GUI:
Category
Processing
Script
Accept / Reject / etc
Search term
Priority
Enabled/Disabled

So are you able to fill out "filter0 = tv, 3, bla.sh, A, dit, 1, 1" ... so without None / empty?
User avatar
safihre
Administrator
Administrator
Posts: 5567
Joined: April 30th, 2015, 7:35 am
Contact:

Re: API call to update filter in rss feed

Post by safihre »

Seems there's magic in the code here that we should document.
https://github.com/sabnzbd/sabnzbd/blob ... i.py#L1226

So need to supply filter_action=update and then supply the index= parameter to indicate which filter you want to change

https://github.com/sabnzbd/sabnzbd/blob ... e.py#L1405
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
e38383
Newbie
Newbie
Posts: 3
Joined: March 23rd, 2025, 5:30 am

Re: API call to update filter in rss feed

Post by e38383 »

safihre wrote: March 23rd, 2025, 4:34 pm Seems there's magic in the code here that we should document.
Thank you, that helped a lot. The correct api call is:

Code: Select all

api?output=json&mode=set_config&section=rss&keyword=Feed+Name&filter_action=update&index=10&filter_type=S&filter_text=Show+Name+S03E60&cat=&priority=-100&pp=&script=&enabled=1
cat/script/pp can also be set to "Default".
User avatar
sander
Release Testers
Release Testers
Posts: 9221
Joined: January 22nd, 2008, 2:22 pm

Re: API call to update filter in rss feed

Post by sander »

Cool!

Full command:

Code: Select all

$ curl 'http://127.0.0.1:8080/api?output=json&apikey=3aa5b2faa7874d75a7fd3059f351d595&mode=set_config&section=rss&keyword=nzbindexnieuws&filter_action=update&index=1&filter_type=A&filter_text=Jannes&cat=&priority=-100&pp=&script=&enabled=1'
output:

Code: Select all

{"config":{"rss":[{"name":"nzbindexnieuws","uri":["https:\/\/nzbindex.nl\/search\/rss?q=nieuws&max=250"],"cat":"","pp":"","script":"","enable":1,"priority":-100,"filter0":["","","None","A","dit","-100","1"],"filter1":["","","","A","Jannes","-100","1"],"filter2":["None","","None","R","*","None","1"]}]}}

... in pretty print (with "| python3 -m json.tool")

Code: Select all


{
    "config": {
        "rss": [
            {
                "name": "nzbindexnieuws",
                "uri": [
                    "https://nzbindex.nl/search/rss?q=nieuws&max=250"
                ],
                "cat": "",
                "pp": "",
                "script": "",
                "enable": 1,
                "priority": -100,
                "filter0": [
                    "",
                    "",
                    "None",
                    "A",
                    "dit",
                    "-100",
                    "1"
                ],
                "filter1": [
                    "",
                    "",
                    "",
                    "A",
                    "Jannes",
                    "-100",
                    "1"
                ],
                "filter2": [
                    "None",
                    "",
                    "None",
                    "R",
                    "*",
                    "None",
                    "1"
                ]
            }
        ]
    }
}

User avatar
sander
Release Testers
Release Testers
Posts: 9221
Joined: January 22nd, 2008, 2:22 pm

Re: API call to update filter in rss feed

Post by sander »

Maybe handy for testing: different CLI curl format using -F parameters

Input:

Code: Select all

$ curl http://localhost:8080/api -F apikey=3aa5b2faa7874d75a7fd3059f351d595 -F output=json  -F mode=set_config  -F section=rss -F keyword=nzbindexnieuws -F filter_action=update -F index=1 -F filter_type=A -F filter_text=PietJan -F cat='' -F priority=-100 -F pp='' -F script='' -F enabled=1
Result:

Code: Select all

{"config":{"rss":[{"name":"nzbindexnieuws","uri":["https:\/\/nzbindex.nl\/search\/rss?q=nieuws&max=250"],"cat":"","pp":"","script":"","enable":1,"priority":-100,"filter0":["","","None","A","dit","-100","1"],"filter1":["","","","A","PietJan","-100","1"],"filter2":["None","","None","R","*","None","1"]}]}}
From curl manpage:

Code: Select all

       -F, --form <name=content>
              (HTTP SMTP IMAP) For HTTP protocol family, this lets curl emulate a filled-in form in which a user has pressed the submit button. This causes curl to POST data using
              the Content-Type multipart/form-data according to RFC 2388.
Post Reply