Par2 processing - a better way

Come up with a useful post-processing script? Share it here!
Post Reply
RagmanIX
Newbie
Newbie
Posts: 1
Joined: February 3rd, 2016, 12:44 pm

Par2 processing - a better way

Post by RagmanIX »

Ok, I found a bunch of stuff downloaded but since the names were obfuscated so SAB would either stop downloading (not enough parts-even though there are enough parts) or would download but not repair the files, even though it was all there. My solution? Put a bash script in front of PAR2. So, first off I built par2 because I like multi threading. Also I am using Ubuntu as my flavor, so these may not work out of the box for you if you run different.
1.I built par2cmdline and installed them (Mine goes into /usr/bin) I used version par2cmdline v.4 with intel multi-threading support
2. Created the script (Which is below) and put it in /usr/local/sbin/par2 This path will override /usr/bin/par2 which is why I used it.
3. Chrmod the script so you can execute it.
4. which par2 and make sure the correct one is executing.
5. retry all those failed downloads-right out of the SAB interface. I picked up another 15 out of twenty that were in my folder.

The biggest change is to add the * at the end, this tells PAR2 to search for missnammed files. A lot of posters obfuscate after the pars are created, thus the names specifed in the PAR file is not the same as the files you downloaded, and unless you add the * at the end it will ONLY process the files you specify. I also make sure we are in the correct directory. SAB spoecifies all the files it wants PAR2 to use to check, so I use dirname to CD to the correct directory. Otherwise we end up in the /usr/bin directory and PAR2 will try to find file matches in its current directory. I suppose I could change it to specify the directory name/* but it works as is.
Notes: If you dont use the same par I use you might look and see if it has the -N option. Mine does -N by default so I didnt have to mess with it. Another thing I ran into is that SAB does not run par from the directory of the files, so you can see I cd into that directory first so all the files are correctly picked up. Ok, enough of that. Here is my tight little script:
#!/bin/bash
action=$1
shift
for var in "$@"
do
if [[ ${var:0:1} == "/" ]]; then
DIR=$(dirname "$var")
break
fi
done

#I like being in the directory that holds the data If you dont then comment it out and change the case lines below to /usr/bin/par2 X "$@" "$DIR/*";;
cd "$DIR"

case $action in
r) /usr/bin/par2 r "$@" "*";;
v) /usr/bin/par2 v "$@" "*";;
*) /usr/bin/par2 $action "$@" ;;
esac
User avatar
sander
Release Testers
Release Testers
Posts: 8811
Joined: January 22nd, 2008, 2:22 pm

Re: Par2 processing - a better way

Post by sander »

Interesting.

You include the filenames in the par2 command line before the "*", right? If so: what happens when you leave them out, and just use the "*"?

Is there a way to point me to such a malformed NZB?
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Par2 processing - a better way

Post by shypike »

We specify * in the OSX and Windows releases.
Unfortunately there are quite a few buggy versions of par2cmdline around.
Specifying * will include sub-folders, which will trigger bugs in some versions.
That's why we chose to replace the * with all the files in the rar/par set.
This may not work in badly named sets.

What I have seen recently is that some NZB file complete fine on
recent Ubuntu releases, but fail on the (still supported) 12.04LTS.
This almost certainly caused by bugs in the par2cmdline version available for 12.04LTS.
I advise you to look for a recent release of par2cmdline, but you may need to compile it from source.
Post Reply