"Status" of Group with API.

Get help, report and discuss bugs.
Post Reply
Kev1000000
Posts: 10
Joined: 20 Dec 2013, 02:43

"Status" of Group with API.

Post by Kev1000000 » 20 Dec 2013, 02:45

Hello, I am the developer of nzb360, and I am integrating nzbget, but I am having trouble with denoting status for items in the queue. The API doesn't seem to return a status for groups. I have no idea if something is downloading, paused, queued, etc.

Any ideas?

hugbug
Developer & Admin
Posts: 7627
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: "Status" of Group with API.

Post by hugbug » 20 Dec 2013, 08:54

Thanks for integrating NZBGet into your app.

First of all, the web-interface communicates with NZBGet via RPC. Everything possible in web-interface is also possible in any other app. There are no (private) functions used by web-interface which could not be used in other app.

The related unit in web-interface is downloads.js.

The design of queue(s) is somewhat complicated but this has historical reasons. NZBGet has separate queues for downloads and for post-processing jobs. In older versions it was possible to have multiple post-jobs for one download - if download had multiple par-sets for each par-set a separate post-job was created. Since v10 only one post-job for one download can exists. In the old web-interface (prior v9) these two queues were shown as separate lists. In the new web-interface (since v9) I decided to not show a separate list for post-jobs but instead integrate it into the download queue list on front page. This was made without API changes solely based on data processing on client side.

The web-interface-app uses two RPC-functions ("listgroups" and "postqueue"). Each group-object and each post-object have NZBID. The web-app then links post-objects to related group-objects as property "post". See function "mergequeues" in downloads.js.

Usually a download have many par-files and the option ParCheck is set to "auto". In that usual case at the time when a post-job is created there are remaining files in download queue and method "listgroups" returns a group for remaining files.

Sometimes however all files of a download may be downloaded before a post-job is created (for example if the download doesn't have any par-files or if the option ParCheck is set to "force"). In that case the method "listgroups" will not return the group (it doesn't exist anymore) but the method "postqueue" will return a job. In that case the web-app creates a fake group-object, connects the post-job to it and puts the group-object into group-list (at the beginning of the list). The post-object has most of the fields the group-object has. Again see function "mergequeues" in downloads.js.

That was the difficult part. Now we can determine the status of download. In web-app this is done be function "detectStatus" in downloads.js:
  • group is in post-processing state if it has a connected post-object;
  • group is in downloading if its ActiveDownloads is greater than 0;
  • group is considered paused if its PausedSize is not 0 and PausedSize==RemainingSize;
More than one of these conditions can be true. See function "detectStatus" for how it prioritizes them.

Kev1000000
Posts: 10
Joined: 20 Dec 2013, 02:43

Re: "Status" of Group with API.

Post by Kev1000000 » 21 Dec 2013, 19:23

Thank you so much for this info. I will apply those checks. As a friendly third-party developer suggestion, I would consider adding status info (and ETA info) for each group / history item within the API.

I really enjoy using the XMLRPC interface, but the API structure is a bit confusing. I really appreciate the help.

hugbug
Developer & Admin
Posts: 7627
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: "Status" of Group with API.

Post by hugbug » 21 Dec 2013, 21:27

In the next version (v13) I'm going to rework the internal queue. Post-queue will be integrated into the main download queue. There will be a new RPC-method for download queue. The merging of groups and post-jobs on client side will not be necessary anymore.

Good tip about fields "status" and "estimated time", this should make things easier for developers.

Despite the changes current RPC-methods "listgroups" and "postqueue" will still work, for compatibility with existing software.

Kev1000000
Posts: 10
Joined: 20 Dec 2013, 02:43

Re: "Status" of Group with API.

Post by Kev1000000 » 21 Dec 2013, 21:42

hugbug wrote:In the next version (v13) I'm going to rework the internal queue. Post-queue will be integrated into the main download queue. There will be a new RPC-method for download queue. The merging of groups and post-jobs on client side will not be necessary anymore.

Good tip about fields "status" and "estimated time", this should make things easier for developers.

Despite the changes current RPC-methods "listgroups" and "postqueue" will still work, for compatibility with existing software.
Ah, awesome! Any ETA on v13? If it's relatively close, I may wait for that version before pushing out my update.

hugbug
Developer & Admin
Posts: 7627
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: "Status" of Group with API.

Post by hugbug » 21 Dec 2013, 21:48

V12 is currently in "testing" state and will be pushed to "stable" soon (hopefully this year). After that v13 will be developed and it usually takes several months before a new version makes it way into "stable".

In other words: don't wait ;)

Kev1000000
Posts: 10
Joined: 20 Dec 2013, 02:43

Re: "Status" of Group with API.

Post by Kev1000000 » 21 Dec 2013, 21:51

Haha, sounds good. Thank you!

Kev1000000
Posts: 10
Joined: 20 Dec 2013, 02:43

Re: "Status" of Group with API.

Post by Kev1000000 » 21 Dec 2013, 21:55

Oh, is there any way to upload an NZB file through your API?

hugbug
Developer & Admin
Posts: 7627
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: "Status" of Group with API.

Post by hugbug » 21 Dec 2013, 22:09

Kev1000000 wrote:Oh, is there any way to upload an NZB file through your API?
Sure. Remember, every function in web-app works through RPC-API and since there is nzb upload in web-app there is an API function for that.

See methods append and appendurl and python-example Adding file to download queue.

The corresponding part in web-app is in file upload.js.

V12 introduces additional parameters such as an ability to add file in paused state. These parameters are not yet documented in wiki (like all other changes made in v12):

Code: Select all

bool append(string NZBFilename, string Category, int Priority, bool AddToTop, string Content, bool AddPaused, string DupeKey, int DupeScore, string DupeMode);

bool appendurl(string NZBFilename, string Category, int Priority, bool AddToTop, string URL, bool AddPaused, string DupeKey, int DupeScore, string DupeMode);

Kev1000000
Posts: 10
Joined: 20 Dec 2013, 02:43

Re: "Status" of Group with API.

Post by Kev1000000 » 21 Dec 2013, 23:01

hugbug wrote:
Kev1000000 wrote:Oh, is there any way to upload an NZB file through your API?
Sure. Remember, every function in web-app works through RPC-API and since there is nzb upload in web-app there is an API function for that.

See methods append and appendurl and python-example Adding file to download queue.

The corresponding part in web-app is in file upload.js.

V12 introduces additional parameters such as an ability to add file in paused state. These parameters are not yet documented in wiki (like all other changes made in v12):

Code: Select all

bool append(string NZBFilename, string Category, int Priority, bool AddToTop, string Content, bool AddPaused, string DupeKey, int DupeScore, string DupeMode);

bool appendurl(string NZBFilename, string Category, int Priority, bool AddToTop, string URL, bool AddPaused, string DupeKey, int DupeScore, string DupeMode);
Sorry, I should have been more specific. This looks like it accepts an NZB file that is already on the same local machine. Is there a method that allows it to accept a remote NZB file, from say a mobile device?

Use case: a user downloads an NZB file on their mobile device, and wants to upload it to NZBget that is hosted on a separate computer in their home.

EDIT: Ahh, never mind. That is what the "Content" param is for. Thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests