Friday, December 23, 2005

Usenet binaries with Linux tutorial



Most of the techniques and software detailed in this FAQ can of course work with MacOSX, FreeBSD, and probably even with Windows.


How do I extract multiple-part Rar archives with Linux ? ( rar r00 r01 r02, etc )

With the unrar command line. Unrar is open source ( exotic licence). Notice that once unrar is installed, front-ends like File-roller, Ark, Xarchiver, or Gnome's right click's "Extract here" can extract Rar archives automatically.

$ unrar e file.rar

Do not install the "GNU unrar" it will not work on Rar3 files, use the unrar-nonfree ( Debian/Ubuntu ) , unrar from plf ( Mandriva ) packages, or the files from the author's website ( rarlab ).


How do I create Rar archives with Linux ? ( thanks to Ohmster for this part, see his comment bellow for reference )

The Rar command-line is the only way to do it. It costs about 30$ at rarlab.com. Like you probably already know, it is the de facto standard way for posting binaries.

example of use :

rar a -s -v15m ppv-erica_campbell-672 *.* ( LOL!!! )

This will create 15Mb volumes from the content of the current directory.
The file mask "*.*" will include all files ( including par2, nzb, nfo, screenshot, video sample, etc ) in the

To create a rar archive file that is broken into specified size parts, use this syntax:

rar a -v15000k hotstuff *

What this does:

  • rar to run the rar program.
  • "a" to command "Add to archive". If the archive does not exist, it will be created.
  • -v15000k is the switch to tell rar to create archive parts no larger than 15,000Kb or 15Mb.
  • hotstuff is the name of the archive you wish to create.
  • * will tell the rar program to include all files in the current directory.

If you're not willing to pay 30$, consider splitting the file in chunks instead ( see question below ) since it's the second most common way to post usenet binaries these days.


How do I repair incomplete files with the par2 parity files ?

With the parchive package ( or par2 package if you use Debian/Ubuntu )and the par2 command :

$ par2 r file.par2

or :

$ par2repair file.par2

Or with Quickpar that works fine with Wine.



How do par2/repair by double-clicking from my file manager without opening a console ? Is there a par2 GUI ?

Those using KDE/Konqueror won't have any problem associating par2 files with par2repair and letting the console open after the operation, it's very straight forward.
With Gnome opening a gnome-terminal from Nautilus is tricky since it the window closes too quickly you can't see what happened, so let's use xterm instead :

In Nautilus, associate par2 extensions with custom command-line :

xterm -hold -e par2repair

About the Par2 GUIs there are several :

How to join split files .001 .002 .003 .004... back together ?
Concatenation of multiple split files.

These split files are likely to be made by Quickpar users under windows, so the perfect way to assemble them is to use the par2 command line. ( from the parchive package )

par2 r myfile.par2 myfile.*

That way, all the split files will be considered as additionnal blocks, and it will check, repair, concatenate the files at the same time.

Note that it's also possible to join the split files back together and then use the new file to find additionnal blocks. It takes one step more but it can save some processing time.

Sometimes the posters mistakenly create parity files that will repair the split files instead of the actual file, after repairing the split files use one of these sweet shell wildcard to merge them back together :

$ cat *.[0-9][0-9][0-9] >output.avi

If the split files are not the only ones in the folder :

$ cat yourfile.avi.[0-9][0-9][0-9] >yourfile.avi

or :

$ cat yourfile.avi.??? >yourfile.avi


This is very rare but sometimes .001 .002 .003 files are not split files but actual Rar multiple-part archives, in that case, unrar should do the job :

$ unrar e yourfile.avi.001



Which binaries grabber for Linux ?

* Multi-server, multi-sources :

1. Pan 0.1** beta now uses less memory, handles multiple servers and nzb files. It only allows 4 connections per server though, which is kind of bad for those of us who pay for using more. I wish it could support SSL and nntps as well.
2. Klibido : GNU, handles Nzb files, OK but unstable
3. BNR2 : heavy, unstable, coded with Kylix, ( not free? )
4. Newsbin Pro is also reported to work fine with Wine and seem to use very few memory. ( not free )

* Nzb command-lines : nzb, hellanzb, NZBget, nzbperl, Knzb.
* Command-line binary grabbers : ubh, brag, aub, nget,


How do I split files, create parity files and post them ? ( Thanks a lot to "Nobody" @ a.b.m.a.d for this part! )

You don't need a file splitter do it, the split command-line will do the job easily.

Posting rules :

* The split files must be a multiple of the par2 block-size, if not some blocks can be lost between two split files.
* The par2 block-size should be equal to the size of the article, or a multiple of it.
* Posting with Newspost constrains the article size to be a multiple of 45, and thus, so must be the Par2 block-size and the split file size.


Here's an example of good settings :

# Par2 block-size : 225,000 bytes
# Article size : 225,000 bytes and 5000 lines
# Split files size : 9,000,000 bytes ( 40 articles )

#!/bin/sh
par2 create -s225000 $1
split --suffix-length=3 --numeric-suffixes --bytes=9000000 $1 $1'.'

Example of use :
$ sh parsplit.sh myfile.avi

To join the files back together and check them at the same time :
par2 r myfile.avi.par2 myfile.avi*

To post with Newspost, don't forget to specify the good number of lines :

$ newspost ........ -l 5000 ......

Here's another binary poster : yencee.


How do batch-repair all the files that I downloaded ? ( Thanks to Anthony @ a.b.m.a.d for this part! )

You can use this perl script.

$ mass-par2repair alt.binaries.*

Where arguments are directories, NOT files.


#!/usr/bin/perl -w
# Copyright (C) 2005 Anthony DeRobertis (netnews at derobert d0t net)
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this file; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

sub run_par(@);

my %results = ();
foreach my $dir (@ARGV) {
opendir DH, $dir or die "Could not open directory $dir: $!";

my %par_files = ();
my %segment_files = ();
foreach my $file (readdir DH) {
my $base = undef;
if ($file =~ /.par2?$/i) {
if ($file =~ /^(.+)\.vol\d+\+\d+\.par2?$/i) {
$base = $1;
} elsif ($file =~ /^(.+)\.par2?/i) {
$base = $1;
} else {
die "Failed to find basename of $file.";
}
push @{$par_files{$base}}, $file;
} elsif ($file =~ /^(.+)\.\d\d\d$/) {
$base = $1;
push @{$segment_files{$base}}, $file;
}
}

foreach my $key (keys %par_files) {
print "$key:\n ";
print join("\n ", @{$par_files{$key}}), "\n";

my @args = ();
foreach my $file (@{$par_files{$key}}, @{$segment_files{$key}}) {
push @args, "$dir/$file";
}
my $retcode = run_par(@args);
if ($retcode == -1) {
die "Could not exec par2: $!";
} elsif ($retcode == 0) {
#$results{$dir}->{$key} = 'OK';
print " OK.\n\n"
} else {
$results{$dir}->{$key} = "FAILED ($retcode).";
print " FAILED ($retcode)\n\n";
}
}
closedir DH;
}

print "\n\n\n";
foreach my $dir (keys %results) {
print "SUMMARY FOR $dir:\n";
foreach my $file (sort keys %{$results{$dir}}) {
print "\t$file: " . $results{$dir}->{$file} . "\n";
}
print "\n";
}

sub run_par(@) {
my $pid = fork();

if ($pid == -1) {
return -1;
} elsif ($pid == 0) {
open STDOUT, '+>', '/dev/null' or die "> /dev/null failed: $!";
exec {'par2'} 'par2', 'r', '--', @_;
die "Exec of par2 failed: $!";
} else {
waitpid($pid, 0);
return $?;
}
}

########END OF PERL SCRIPT #############

As you noticed, I've messed up all the formatting but it still works. If you want the original file, contact the author, his address is in the headers.



Another simple solution is to do this : ( thanks to the anonymous poster for his comment )


for i in *.[pP][aA][rR]2; do par2 r $i; done


let's explain step by step :

echo *.par2
this will obviously print all the par2 files in the current directory

to get one filename per line :
for i in *.par2; do echo $i; done

So, to mass-repair everything in a directory simply type :
for i in *.par2; do par2repair $i; done

This will work 99% of the time, since usually the first par2 file of the a set ( the smallest one ) is not capitalized, whereas the rest if them are.

To make it work 100% of the time, you can do this :
for i in *.[pP][aA][rR]2; do par2 r $i; done
But beware, this is a brute strength method, you will run par2 several times for a same set of parity files.



Many thanks to the people on a.b.m.a.d for their help !


If you have other interesting tips to share about Usenet binaries with Linux, do not hesitate to drop a comment ( no registration required ). Stay tuned, this FAQ is regularly updated.

Last updated July 2007 : rar and Ben's Par2GUI

Labels: , , , , , , ,

22 Comments:

At February 05, 2006, Blogger zoby said...

Hi Christian,

About the CPU usage to 50%, I don't know if it's possible. You could change the priority or renice the process to 19 though, it will still use 100% of the CPU, but the other processes wil not be affected.
Unfortunately I don't know any Perl, so you can contact the author, his email is in the headers of the script.

Each time the script runs "par2" or "par2repair" you need to add a couple of lines to the script tofind the PID of the new subprocess, and change its priority.

I think I know how to do it in python if it helps you, using the renice command line :


import subprocess
p = subprocess.Popen("par2 r blablabla")
subprocess.Popen( "renice 19 -p " + p.pid )

This is basically what you need to do but in Perl.

I don't understand what you're doing with par2 and your vdr, your vdr runs under linux and it also uses par2repair ? sorry I don't get it.

Good luck.

 
At February 05, 2006, Blogger zoby said...

hmm the comment disappeared ?? wtf ??

here's a copy :



Hi,

the mass-par2repair perl script is what i was looking for, thx!

Is there a possibility to set the usage of the cpu to 50 for example?

I am running ur script as a chrown job every hour on a vdr (video disk recorder).

When recording via 2 cards and cutting some advertisment from recordings, its to much for the vdr using the script in the standart way.

Hope u understood my english...smile

So far greets from germany

Christian

Feel free to write me a email to

cPOINTmatthiessenATgmxPOINTde

 
At July 18, 2006, Anonymous Anonymous said...

Good article. Will take a closer look at the mass repair script. Two things for those that read this later:
1. it's good posting form to use par2 -l to limit the size of the par2 files.
2. do not, do not do not make the par2 file against original file instead of the posted files (the rars or the split files). This has two benefits for the downloader: you can check the files you have while the rest are downloading and automatic par2 checkers (nget and any other downloader worth considering) don't fail and download a bunch of unecessary par2 files.

 
At July 19, 2006, Anonymous Anonymous said...

Thank-you, thank-you thank-you!!

You've no idea how much googling I've done searching for how to use .par files in Linux until I stumbled across your blog!

Cat was failing me ~50% of the time, and your little par2 walkthrough works perfectly!

Many thanks once again!

 
At July 14, 2007, Anonymous Ohmster said...

I need a good page like this for reference and I do things pretty much the standard way for posting videos. I can do all of this in Windows but prefer not to tie up my Windows computer with these chores when I can offload them to the Linux machine on my LAN and even have the Linux machine post them for me. This is how I like to do things:

Create preview image with thumbnails of the video.

Create the rar archive set, broken into manageable parts like 10 or 15 megabytes.

Create the par2 recovery file set.

Use news post to post the entire directory of files in my "post" directory, that is where I put everything that I intend to post.

I often use the -E option in news post in order to create a text file at the beginning of the post, giving information or comments, etc.

Let 'er rip, that is to say, use news post to upload everything to my giganews server to the appropriate newsgroup.

I often use the screen command and work entirely from the CLI so that I can begin this job in a VT100 term window with putty from Windows and then detach the screen. I can then check up on it later by reattaching to the screen session from the term program or even the server itself, maybe even remotely with putty again.

Even though rar is not a free program, it is the de-facto method of posting large video files and I would appreciate you including the commands necessary to create multipart rar archive sets from a large video file, like this:

-----------------------------------------------------------------------------
rar Linux Examples
-----------------------------------------------------------------------------
rar a -s -v15m ppv-erica_campbell-672 *.*

Create 15Mb volumes from the contents of the current directory, the file mask,
"*.*" will include all files, in the new the archive and will be named
ppv-erica_campbell-672.partxx.rar.
-----------------------------------------------------------------------------
To create a rar archive file that is broken into specified size parts, use
this syntax:
rar a -v15000k hotstuff *

What this does:

rar to run the rar program.

"a" to command "Add to archive". If the archive does not exist, it will be
created.

-v15000k is the switch to tell rar to create archive parts no larger than
15,000Kb or 15Mb.

hotstuff is the name of the archive you wish to create.

* will tell the rar program to include all files in the current directory.
-----------------------------------------------------------------------------

Please include the rar commands in your page as it would make a great reference and I for one would like to reference it in my FAQ for video posting. I had a hell of a time getting rar Linux to do what I wanted as the instructions were pretty dry and I had to ask for help in the Linux newsgroups.

Other than the rar omission, this is a great page and I thank you for publishing it.
~Ohmster

 
At July 15, 2007, Blogger zobi said...

Thank you Ohmster, I will include your comment.

 
At September 25, 2007, Anonymous Anonymous said...

To repair with par2s and then extract the rars in one go command stack with &&. A typical example would be: par2 r *par2 && rar x *rar. && ensures that if the first command fails it will not go on to the next command. Ideal in this case.
To get by the 4 server connection limit in Pan put the same server address in twice, or as many times as you like.

 
At September 27, 2007, Anonymous oranges said...

this is all awesome...thanks

I'm looking for a way to make directories from file names. Say I download 200 mp3's, I'd like some way to have directories made from a file name minus the extension. Either by right clicking on the file name and choosing make dir or a way to do it from the command line. im using debian and gnome.

I know there is a way to automate this whole process, i just have to find it :)

 
At September 28, 2007, Anonymous oranges said...

I installed Thunar File Manager and added a custom actions under edit>>configure custom actions.

mkdir $(ls %n|awk -F"." '{print $1}')

Add a new action, name it, put in the script, and then go to 'appearance and conditions' tab and select all the check boxes. Your done. Now just right click on the file you want and select the script.

I cant take credit for this, but it does what I wanted and removes one more step for processing binaries :)

 
At November 27, 2007, Blogger Dave "the problem finder" McKeon said...

This post has been removed by the author.

 
At November 27, 2007, Blogger Bonzoli said...

I posted some useful scripts for working with usenet binaries. Its over http://bonzoli.com/?cat=4

Just about everything you could want to do with perl and usenet downloads.

 
At January 06, 2008, Anonymous jfg69 said...

Is there any other way of joining .001, .oo2 etc split files? I cant seem to get them to join. New to *nix and this is soo frustrating! Thanks!

jerry

 
At January 24, 2008, Anonymous Anonymous said...

For posting from the commandline, I've heard good things about newsmangler

It does yEnc encoding.

Requires Python.

 
At February 17, 2008, Anonymous Anonymous said...

Newsmangler is available here:

http://www.madcowdisease.org/mcd/newsmangler

Does work quite well.

 
At February 17, 2008, Anonymous Anonymous said...

1. STIC ('some tools for image collectors') is a set of commandline linux utilities for managing 'an unreasonable amount' of images, including downloading from and posting to usenet with yEnc encoding, and much more.

Includes an interesting-sounding utility called 'similar', which somehow is supposed to find images that are similar in content (including duplicates).

I haven't tried stic (looks much more than I need), but it might warrant exploration for anyone seriously into usenet images.

http://stic.sourceforge.net/


2. LUCY is a Perl commandline newsreader and poster.

http://www.geniegate.com/other/lucy/

Again, I haven't tried this yet (may do) and post this fyi, since I'm happy with newsmangler for posting.

 
At February 20, 2008, Blogger casper said...

I use usenext on linux and it works very well...

easy to use. for me it's the right thing!

http://www.usenext.com/UseNextDE/ShopInt/misc/support/miscSupport.cfm?SNUUID=36B7C32E%2D3048%2D8C24%2D4C3929519529F2AC&1203513255670&&CategoryID=8

 
At February 25, 2008, Blogger Kevin said...

Even though PAN and every other Linux nntp reader I know of do not support SSL directly, you can use the daemon `stunnel` to create a pipe. Your stunnel.conf file will look something like:

---

client = yes

[nntp.client]
accept = 127.0.0.1:119
connect = {your nntp server}:563

---

Then, you can point your client to localhost, and stunnel will handle the ssl connection to the actual server.

 
At March 26, 2008, Blogger ThynksDepot said...

Great Info! Thank you!

 
At March 26, 2008, Blogger ThynksDepot said...

Great Info! Thank you!

 
At April 19, 2008, Anonymous Anonymous said...

A few followup notes:


1. I thought rar 4.41 for linux was shareware. Needs checking, but I have a suspicion there isn't an obligation to buy.

2. Pan2 still is lacking in some ways, but it's all there really is as a half-decent native binary GUI newsreader for linux. It has got a lot right, so it's getting there. It's fine for relatively light use, or if you can get used to its quirks. It will improve.

3. Forte Agent runs well under the current wine release in linux. XNews also runs well under wine but requires the following dlls from a WinXP install to be copied into the XNews root directory: comctl32.dll, ole32.dll, oleaut32.dll, riched20.dll, riched32.dll. Run winecfg and set those libraries as 'native'.

Forte Agent should be installed in the ~/.wine/drive_c/Program Files directory. XNews should be installed in ~/.wine/drive_c (not sure how important that is).

I've heard QuickPar (free) also runs under wine but haven't tested this. In any event Peter Brian Clements' par2cmdline utilities for linux work very well:
http://parchive.sourceforge.net There are precompiled binaries in Debian repos and probably elsewhere.

4. LUCY sucks the sweat off dead donkey balls unfortunately.

5. Newsmangler (commandline, Python) is fine for posting binaries.

 
At April 19, 2008, Anonymous Anonymous said...

Also:

1. Concerning joining parts on the commandline:

I find if all the parts and par files are in their own directory, there's no need to put wildcards in the glob expression. The shell (bash in my case) seems to know I'm talking about numeric globbing only. So I just do:

$ cd thatdirectory
$ cat somefile.avi.* >somefile.avi

Never have any problems - the shell ignores the par2-ending files etc.

Be sure to put quotes around the filenames if they contain spaces, and use double quotes if these contain parentheses (Windows people will put all kinds of garbage in filenames!).

2. Concerning parts that are in fact split rar archive parts: there seems to be a typo in the article.

When rar itself makes split archives, the digits get put between the filestem and the "rar" suffix. So it's quite obvious:

somefile.001.rar
somefile.002.rar
somefile.003.rar
etc

and not as the author says. if it looks like somefile.rar.001 etc then the archive was made with rar and subsequently split with something else.



Combine and extract with:

$ rar x somefile.001.rar

I recommend using x not e because this will preserve any directory structures/paths inside the archive. Files may have been neatly organized into folders, but you'll lose all that with e.

 
At April 20, 2008, Anonymous Anonymous said...

Oh dear, I boo-booed.

Please *disregard* my comment (1) in the previous post.

You should indeed put wildcards in the globbing statement - I must have ended up repairing more files than I needed to!

So:

$ cat filestem.avi.[0-9][0-9][0-9] >filestem.avi

is quite correct.

Sorry!

 

Post a Comment

Links to this post:

Create a Link

<< Home