Page 1 of 1

Some API things

Posted: June 18th, 2010, 11:08 am
by Hmail
As you might know, I'm working a bit around with addons, and I would like to know if these things are possible (maybe even now, but couldn't find them in the documentation)
- After a succesfull file upload, get some more details. Like the nzo_id (the string like "SABnzbd_nzo_ipet0h"). Right now, the output says "ok", or, if XML output is requested, True. This is useful for more changes after the file upload.
- Allow more options in the mode. For example, setting the priority or the queue position when you upload a file.

If it's not clear what I mean, this is what I am working on:
If a user downloads a nzb file, he can upload it with category and a new name to sabnzbd. But from time to time, sabnzbd is currently downloading stuff which I need later, but not right now. And I want a movie to be downloaded before everything else is finished. It would be great to have a checkbox called "Put on top of queue". Right now, it looks like I have to do the following:
- Send the file to sabnzbd using mode=addfile.
- Getting the history using mode=qstatus.
- Comparing the filename with the filename the user specified, and retrieving the nzo_id from the xml or json output. (I personally don't like this part. I don't like to compare user input with internal stuff. Usually it's pretty hard to have that fool proof).
- Changing the queue position with mode=switch.
I think it would be great to skip the third step with my first suggestion. The second would be even better, but I guess that would make the development harder, and the documentation a mess with all the available options.

Last but not least, I saw that the file upload documentation was removed and replaced with "Allows a file upload to be sent, will be explained in more depth shortly.". I would love to see it back, I guess this has been removed with the 0.5.0 release?

Re: Some API things

Posted: June 18th, 2010, 2:15 pm
by shypike
Maybe I don't understand, but why don't you use priorities to force certain jobs to the top position?

The file upload was too hard to implement.
Only "addlocalfile" is supported.

Re: Some API things

Posted: June 18th, 2010, 4:04 pm
by Hmail
shypike wrote: Maybe I don't understand, but why don't you use priorities to force certain jobs to the top position?

The file upload was too hard to implement.
Only "addlocalfile" is supported.
:D I never thought about the priorities. I figured these were for the processor, so that sabnzbd would run on a higher level. Although it's not exactly what I was looking for, it does solve my issue. Still it would be great to get some more response beside the "ok\n".
I do use addfile in my addon, and I have some topics on this forum about that, I believe switch answered those. It's a bit hard to implement, but it gives the user the freedom to talk to the server without allowing a server (and maybe other clients as well if it's not implemented properly) to talk to the client. I personally have a server at home and because addfile is there, I can send nzb files to it from a remote location, without opening ports on my system.

So I know how to work with addfile, I just figured maybe more was changed in it since 0.5.0 came out, and it would be nice to have that as a reference instead of topics I had before. But is it really that hard to implement file upload? In my opinion, it's quite hard to use it now, but I always figured it could be a lot easier. Just sending a POST as multipart/form-data with a file isn't enough? Ah well, I have never took a close look at the source of sabnzbd, so I might be saying stupid stuff. If you don't support it, thats alright, I just hope you never remove it ;)