Problems using API (Switch)

Questions and bug reports for Beta releases should be posted here.
Forum rules
Help us help you:
  • 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.
dogzipp
Newbie
Newbie
Posts: 49
Joined: April 3rd, 2012, 5:27 pm

Problems using API (Switch)

Post by dogzipp »

With 7.0b2 I am getting this when I try a switch command like:

api?mode=switch&value=SABnzbd_nzo_RjARgX&value2=1&apikey=[apikey]

Code: Select all

500 Internal Server Error

The server encountered an unexpected condition which prevented it from fulfilling the request.

Traceback (most recent call last):
  File "/mnt/DroboFS/Shares/DroboApps/sabnzbd/cherrypy/_cprequest.py", line 618, in respond
    cherrypy.response.body = self.handler()
  File "/mnt/DroboFS/Shares/DroboApps/sabnzbd/cherrypy/_cpdispatch.py", line 25, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/mnt/DroboFS/Shares/DroboApps/sabnzbd/sabnzbd/interface.py", line 403, in api
    return api_handler(kwargs)
  File "/mnt/DroboFS/Shares/DroboApps/sabnzbd/sabnzbd/api.py", line 99, in api_handler
    response = _api_table.get(mode, _api_undefined)(name, output, kwargs)
  File "/mnt/DroboFS/Shares/DroboApps/sabnzbd/sabnzbd/api.py", line 356, in _api_switch
    return report(output, data=(pos, prio))
  File "/mnt/DroboFS/Shares/DroboApps/sabnzbd/sabnzbd/api.py", line 854, in report
    data = ' '.join(data)
TypeError: sequence item 0: expected string, int found
BTW, the switch command is processed sucesfully. It's just that there's no XML success response, just the cherrypy error.
Thanks
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Problems using API (Switch)

Post by shypike »

It crashes when trying to return the new positions,
by expecting a text where an integer number is delivered.
I'll fix that in the next 0.7.0Beta.
Thanks for reporting.

BTW: a work-around is to add "output=json" to the command.
We recommend the use of the json and XML forms instead of plain text.
dogzipp
Newbie
Newbie
Posts: 49
Joined: April 3rd, 2012, 5:27 pm

Re: Problems using API (Switch)

Post by dogzipp »

I am trying out the XML output. Altough it returns XML output, how do I know if the operation was succesful or not? (I don't see any success/error message). Should I assume position -1 is an error?
i get:

<result>
<priority>0</priority>
<position>-1</position>
</result>

I can even use a Non Existant NZBID, and I still get the same XML results. I don't even get an Invalid NZB error or anything.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Problems using API (Switch)

Post by shypike »

A non-existing id will return position -1.
dogzipp
Newbie
Newbie
Posts: 49
Joined: April 3rd, 2012, 5:27 pm

Re: Problems using API (Switch)

Post by dogzipp »

Also, another thing I noticed using the API.

I am sending files using the Addurl option. I am also sending the category. But for some reasons, if you're using wildcards on Config->Categories, they are ignored when using the API. Only an exact match will do.

For example, if I send two files, one with category Movies > HD, and another TV > HD, if I have categories "Movies*" and "TV*" they will be ignored, and the files are put on "default".

If I have an exact match (Movies > HD and TV > HD) it works perfectly.

Can you double check that wildcards should work through API addurl?

Thanks a lot for all the patience with my reports ;-)
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Problems using API (Switch)

Post by shypike »

I think you misunderstand the purpose of category in the API.
You're supposed to send an actual category as defined in SABnzbd.
The matching column in Config->Categories is used to match to categories
coming from (some) indexers.
dogzipp
Newbie
Newbie
Posts: 49
Joined: April 3rd, 2012, 5:27 pm

Re: Problems using API (Switch)

Post by dogzipp »

I think perhps you misundertood my problem. I am the indexer. I am sending the Category to my users.

For example one of my users downloads files from TV > Sports, TV > HD, and TV > SD.

He doesn't want to create 3 different categories in SABnzbd. He creates one that says "TV*"

After all, Config->Categories says: "Wildcards are supported."

Right now if I am sending a file through the API, the Wildcard is being ignored. Unless user has TV > Sports, TV > HD and TV > SD define as three separate categories, the pushed file will be put in "default".

I mean, that's the purpose of using wilcards on Config->Categories, right? So you could group all your "TV" and "MOVIES" no matter what the subcategory is?
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Problems using API (Switch)

Post by shypike »

The API supports user defined categories.
User-defined categories can be mapped to categories as defined by indexers.
I understand that you are trying to send your own indexer categories to SABnzbd,
but that's not what the API calls were designed for.
They were created to create an alternative user interface (like the many iPhone and Android apps do).
They query the user category list and create a pick list based on that.
I'm not saying your request is not useful, but it's currently not implemented.
So this is not a problem report but you're asking for additional functionality.
I'll see if that can be accommodated somehow.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Problems using API (Switch)

Post by shypike »

I can add an "xcat" parameter to the calls "addlocalfile" and "addfile".
The xcat parameter will be mapped to a category using the method used for indexer mapping.
dogzipp
Newbie
Newbie
Posts: 49
Joined: April 3rd, 2012, 5:27 pm

Re: Problems using API (Switch)

Post by dogzipp »

Great I cant wait to test the new funtionality. Because several users are asking (complaining) that their downloads are not being correctly categorized, even tough they are using wildcards. The xcat would result in much less headaches for both my users and me. I can just tell them if they want it to work with wildcards, they should upgrade to 7.0

Thank you.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Problems using API (Switch)

Post by shypike »

As Beta3 is about to be released, it will be in Beta4.
dogzipp
Newbie
Newbie
Posts: 49
Joined: April 3rd, 2012, 5:27 pm

Re: Problems using API (Switch)

Post by dogzipp »

Shypike, please make it so that xcat can also be repeated for uploading multiple NZBs with different categories.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Problems using API (Switch)

Post by shypike »

The calls (addfile, addlocalfile) which support xcat don't allow multiple files to be uploaded.
For the other calls (addid and addurl) which do allow multiple NZBs, xcat makes no sense.
dogzipp
Newbie
Newbie
Posts: 49
Joined: April 3rd, 2012, 5:27 pm

Re: Problems using API (Switch)

Post by dogzipp »

I actually believe multiple xcats makes perfect sense... A user might have 3 files. One Movies, one TV HD and one TV SD. If I am adding all three on the same HTTP request, what's the point of them all ending up in the same category). The User might have two categories: TV*, and Movies.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Problems using API (Switch)

Post by shypike »

Have you tried uploading multiple files?
Post Reply