Re: trn and yEnc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In article <20030820185431.GB24525@binome.blorf.net>,
Wayne Davison  <trn@blorf.net> wrote:
>Trn doesn't support yEnc directly because it was a poorly designed
>format and I was kinda hoping it would go away (however, that doesn't

Hear! Hear!

>look to be very likely these days).

>Personally, I've switched over to using "ubh" for extracting binaries --
>since that's it's sole purpose in life, it does a good job of it.  I
>haven't tried the 3.x version (it puts the article data into a mySQL
>database), but the 2.x version works well for me (grab the ubh script
>from the web-browsable CVS to get the latest fixes).  I combine it with
>uudeview (a fast decoder) for extra speed.

Reminds of of aub.

Personally I use the following cheesy perl script.  Note that it automatically
adds crossposted groups to the newsrc file as unsubbed.  It makes it grow,
but you can discover new groups this way.


#!/usr/bin/perl -w

eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
if 0; # not running under some shell

# connection, newsrc, xref
sub mark_groups
{
	my ($conn, $rc, $x) = @_;

	foreach $v (split " ", $x) {
		($g, $n) = split ":", $v;
		$g =~ tr/A-Z/a-z/;
		next if not defined $n || !$n;

		# active() is expensive.  So, if we've already added it to
		# goodgroups, don't do it again.
		$goodgroups{$g} = keys %{$conn->active($g)} if !  exists($goodgroups{$g});
		next if ! $goodgroups{$g};

		print "\tg=$g, n=$n\n";

		if ( ! $rc->exists($g)) {
			print "New group: $g\n";
			$rc->unsubscribe($g, %last);
		}
		$rc->mark($g,$n);
	}
}

sub checkpoint
{
	my ($rc) = @_;
	print "Checkpointing...\n";
	$rc->save;
	print "Done.\n";
	sleep 2;
}

use News::Newsrc;
use Net::NNTP;
use News::Article;
use Date::Parse;
use Date::Manip;

%goodgroups = ();
$limit = 100;
$totcount = 0;
$totartcount = 0;
$conn = new Net::NNTP("thune");
$newsrc = new News::Newsrc("$ENV{HOME}/.newsstuffrc");

$first{"where"}="first";
$last{"where"}="last";

GROUP: foreach $group ($newsrc->sub_groups) {
	print "$group\n";
	($num, $first, $last, $ngroup)=$conn->group($group);
	print "$ngroup\n\t$first-$last";

	if ($first > 1) {
		$fm = $first - 1;
		$newsrc->mark_range($group, 1, $fm);
	}
	@marked=$newsrc->marked_articles($group);
	if ($last < $marked[-1]) {
		print "Backing out article marks for $group...";
		$newsrc->unmark_range($group, $first, $marked[-1]);
	}
	@articles = $newsrc->unmarked_articles($group, $first, $last);
	$artcount = @articles;
	$totartcount += $artcount;
	print "\t$artcount articles: @articles\n";
	$count = 0;
        ARTS:  foreach $num (@articles) {
		$art = $conn->article($num);
		$xref = "$group:$num";
		if (! $art) {
			if ($conn->code != 430 && $conn->code != 000) {
				checkpoint($newsrc) if $count;
				$code=$conn->code;
				print "$code\n";
				print "Reconnecting for $num...\n";
				$conn = new Net::NNTP("thune");
				$conn->group($group);
				print "Reconnected.\n";
				$count = 0;
				next ARTS;
			} else {
				$count++;
			}
		} else {
			$filename = "$ENV{HOME}/News/uue/$group.$num.uue";
			print "save file to: $filename\n";
			open(OUTFILE, ">$filename") or die "Can't open $filename: $!";
			print OUTFILE @{$art};
			close OUTFILE;
			$article = new News::Article();
			$article->read_headers($art, 16*1024);
			$date = $article->header("date");
			$d=str2time($date);
			utime $d, $d, $filename;
			print "number=$num count=$count artcount=$artcount limit=$limit\n";
			#foreach $v ($article->rawheaders) {print "$v\n";}
			$xref=$article->header("xref");
			$count++;
			$totcount++;
			if ($count > $limit) {
				$count=0;
				checkpoint($newsrc);
				$left = $last-$num;
				print "group=$group last=$last, at most $left left\n";
				next GROUP;
			}
		}
		mark_groups($conn, $newsrc, $xref);
	}
	$newsrc->move_group($group, %last);
	checkpoint($newsrc) if $count;
}
print "Total number of articles downloaded: $totcount\n";
print "Total number of articles possible:   $totartcount\n";

-- 
     Mike Castle      dalgoda@ix.netcom.com      www.netcom.com/~dalgoda/
    We are all of us living in the shadow of Manhattan.  -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); -- gcc


-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines
at the same time. Free trial click here:http://www.vmware.com/wl/offer/358/0

[Index of Archives]     [Photo]     [Yosemite]     [Epson Inkjet]     [Mhonarc]     [Nntpcache]

  Powered by Linux