Par2 processing - a better way
Posted: February 3rd, 2016, 3:51 pm
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
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