How to obtain the unrar overall progress report?

Dan Thurman dant at cdkkt.com
Sat Sep 13 20:09:40 UTC 2008


Patrick O'Callaghan wrote:
>
> On Sat, 2008-09-13 at 12:29 -0700, Dan Thurman wrote:
> > I am using fedora's "native" unrar for my python
> > application - no dll version or whatever else is out there.
> >
> > I have been trying to figure out how to obtain
> > unrar's overall progress report for inclusion into my
> > python code but so far I have not been successful.
> >
> > I tried to turn off all of the comments except for
> > the progress report and all I have so far is:
> >
> > unrar x -ierr +o- $file | sed -e 's/.*\([0-9]\+\)[%]$/\1/
> >
> > I have tried: -c-, -inul, and many other switches but
> > none of these switches helped.
> >
> > There is also a -id[c,d,p,q] command line
> > option but this does not seem to work and this is
> > option is not discussed in the man pages.
>
> Perhaps if you give us a sample of output from the command (without the
> sed filtering) someone can come up with something. Just a few lines
> please, including any header lines.
>
Thanks for responding!

Ok, the hard part is that what you do not see is the overall progress
report is because the OPR appears at the end of each unrar output line
and is overwritten by OK before moving to the next line.  I have managed
to terminate the program at the point where the accumulative OPR is seen:

===================================================
# unrar x -ierr -o+ ~dant/Desktop/foo.rar \
    | sed -e 's#\([0-9]\+\)[%]$#\1#'

UNRAR 3.71 beta 1 freeware      Copyright (c) 1993-2007 Alexander Roshal


Extracting from /home/dant/Desktop/foo.rar

Extracting  foo/cd1/Track01.flac  OK
Extracting  foo/cd1/Track02.flac  OK
Extracting  foo/cd1/Track03.flac  OK
Extracting  foo/cd1/Track04.flac  OK
Extracting  foo/cd1/Track05.flac  OK
Extracting  foos/cd1/Track06.flac  OK
Extracting  foos/cd1/Track07.flac  21%^C
User break
===================================================

So notice that the 21% is the accumulative progress of unrar at the point
where I terminated the program.  This value is difficult for me to capture
and it almost seems that the output is sent through stdout and/or stderr or
something else that I have not been able to figure out.

Anyway, I am trying to capture this number so that the python progress
dialog box is able to take advantage of this to graphically show the
progress report in my python application.  I am trying to enhance the
'audio-convert-mod' program so that it supports unrar, zip, and cue as
well as a way to make the whole operation from recursive extraction to
decode/encoding of audio files more automatic, user selectable, from
start to finish - something that would be more useful - at least for me.

I also am thinking of changing the gui-layout a bit - to be more intuitive
and allow for the user to choose one or more of the steps through the
operation(s) and in what order (rar,zip.ape.cue,flac....) with or without
recursion and so on.  I already wrote a bash script to do this which is 
quite
useful but unfortunately, my daughter is computer illiterate so that is why
I am working on this gui application for her, but also for others as well.

I am not an expert with python but I think I can get a handle on this,
albeit slowly.  Seems like a good project for me to work on.

Thanks!
Dan




More information about the fedora-list mailing list