[Post-Process Script] Progress bar?

Get help, report and discuss bugs.
Post Reply
cguy1234
Posts: 4
Joined: 28 Aug 2017, 21:37

[Post-Process Script] Progress bar?

Post by cguy1234 » 31 Aug 2017, 14:36

I've written a post processing script that transcodes video files if they don't meet my specified parameters. I'd like to add some type of progress meter to the download screen - similar to what we see when a file is being unpacked, or par checked. Is this possible? and if so, how? I've read the docs and can't seem to find anything about how to do it either through messages, or the API.

Thanks for any help.
- Cguy

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

Re: [Post-Process Script] Progress bar?

Post by hugbug » 31 Aug 2017, 17:05

This is not possible. Would be a nice feature to have though.

What you can do in current version is to print messages containing progress info (something like "Processing, 23% completed"), the last message is shown in badge near nzb name.

kloaknet
Posts: 337
Joined: 23 Jul 2014, 08:52

Re: [Post-Process Script] Progress bar?

Post by kloaknet » 01 Sep 2017, 14:17

hugbug wrote:
31 Aug 2017, 17:05
What you can do in current version is to print messages containing progress info (something like "Processing, 23% completed"), the last message is shown in badge near nzb name.
This only works for the post processing, isnt it? or does this work too for the other queue scripts etc?

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

Re: [Post-Process Script] Progress bar?

Post by hugbug » 01 Sep 2017, 14:29

Only post-processing. Since nzbget waits for pp-script to terminate the badge can't conflict with messages from other post-processing stages (repair, unpack). Plus it's nice to see current status detail without switching to messages tab.

If the last message would be shown for queued items all items processed by scan or queue scripts would have a badge forever (until post-processing is started). Any suggestions when to remove the badge?

kloaknet
Posts: 337
Joined: 23 Jul 2014, 08:52

Re: [Post-Process Script] Progress bar?

Post by kloaknet » 01 Sep 2017, 14:52

sorry for basically hijacking this thread ;-)

But I don't see a good moment to let the last message be removed, so I get the difficulty for displaying messages for other script options.

But if a progress bar would be implemented, then it maybe an idea to let any script send messages to the queue page badges via some NZBID related option to send progressbar data and some text message.
[Like: messagequeue(NZBID, 50, Completion: Requested [81/162] articles, 5 failed.) ]. Note that the user then also needs to send a clear message to get the message removed, or until post proc overwrites/clears

cguy1234
Posts: 4
Joined: 28 Aug 2017, 21:37

Re: [Post-Process Script] Progress bar?

Post by cguy1234 » 02 Sep 2017, 13:38

Honestly, I've not found that NZBGET doesn't handle print messages to well....

When I call subprocess.popen from my python program, all print messages stop displaying. It seems it's got something to do with buffering the stdout, and stderr pipes. The instant my subprocess starts (either calling handbrake, or other programs that run for a length of time), all messages to 'print' are stopped and only display once those subprocesses complete.

I've been able to get around this by using the API and writelog, to get messages to display, but as far as getting anything on the download screen it doesn't seem possible. I've tried multiple combinations of changing the way my subprocess communicates, but nothing seems to make a difference. It's entirely possible that handbrake is the issue as well given that it dumps a LARGE amount of data when the process starts into the stdout pipe, possible filling the buffer.

Anyway, an API method to display a percentage bar on the download screen would eliminate any/all of this for anyone calling external programs.

Thanks for listening and your help.
-Cguy

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

Re: [Post-Process Script] Progress bar?

Post by hugbug » 02 Sep 2017, 15:38

Most programs use buffering for stdout. That's why you should flush buffers for messages to arrive to calling process (nzbget).

Test your script without nzbget, directly in terminal. If you see messages, nzbget will see them too. Add flush commands after each print command (without flush you would not see messages in terminal either).

Also, nzbget processes messages line by line. If you print progress text on one line using backspaces to update previous text, nzbget will not processes them until a line break is printed.

kloaknet
Posts: 337
Joined: 23 Jul 2014, 08:52

Re: [Post-Process Script] Progress bar?

Post by kloaknet » 02 Sep 2017, 16:27

I used the following:

Code: Select all

sys.stdout.flush()
to get the messages printed in the correct order, and for some occasions I even had to add this:

Code: Select all

time.sleep(0.1)
as some items in NZBGet would be printed before the flush was finished

cguy1234
Posts: 4
Joined: 28 Aug 2017, 21:37

Re: [Post-Process Script] Progress bar?

Post by cguy1234 » 02 Sep 2017, 20:18

Thanks, I'll give that a shot.

Post Reply

Who is online

Users browsing this forum: No registered users and 49 guests