SVN: toys/rsget.pl: Get/MegaShares RSGet/Curl.pm RSGet/Dispatch.pm RSGet/FileList.pm RSGet/Get.pm RS...
sparky
sparky at pld-linux.org
Thu Aug 27 17:25:16 CEST 2009
Author: sparky
Date: Thu Aug 27 17:25:15 2009
New Revision: 10498
Modified:
toys/rsget.pl/Get/MegaShares
toys/rsget.pl/RSGet/Curl.pm
toys/rsget.pl/RSGet/Dispatch.pm
toys/rsget.pl/RSGet/FileList.pm
toys/rsget.pl/RSGet/Get.pm
toys/rsget.pl/RSGet/Processor.pm
Log:
- minor improvements
Modified: toys/rsget.pl/Get/MegaShares
==============================================================================
--- toys/rsget.pl/Get/MegaShares (original)
+++ toys/rsget.pl/Get/MegaShares Thu Aug 27 17:25:15 2009
@@ -45,8 +45,7 @@
my $left = $1;
m{Your download passport will renew in\s*<strong>0</strong>:<strong>(\d+)</strong>:<strong>(\d+)</strong>}s;
my $time = s2string( $1 * 60 + $2 );
- my $if = $-{_outif} ? "[$-{_outif}]" : "";
- p "${if}[MS] Passport: $left, $time";
+ LOG( "Passport: $left, $time" );
return $self->stage_download();
}
@@ -74,8 +73,8 @@
GET( $ajax );
- RESTART( 10, "Passport reactivated" ) if m{Thank you for reactivating your passport};
- RESTART( 10, "Wrong captcha ?" );
+ RESTART( 2, "Passport reactivated" ) if m{Thank you for reactivating your passport};
+ RESTART( 2, "Wrong captcha ?" );
GET( "" );
stage_download:
Modified: toys/rsget.pl/RSGet/Curl.pm
==============================================================================
--- toys/rsget.pl/RSGet/Curl.pm (original)
+++ toys/rsget.pl/RSGet/Curl.pm Thu Aug 27 17:25:15 2009
@@ -155,7 +155,7 @@
open my $f_out, '+<', $fn;
seek $f_out, $start, SEEK_SET;
- p "Continuing '$fn' at " . bignum( $start ) . $old_msg;
+ $supercurl->{get_obj}->log( "Continuing at " . bignum( $start ) . $old_msg );
hadd $supercurl,
@@ -179,7 +179,7 @@
my $fn = $supercurl->{fname};
my $old = file_backup( $fn );
if ( $old ) {
- p "'$fn' renamed to '$old'";
+ $supercurl->{get_obj}->log( "Old renamed to '$old'" );
rename $fn, $old;
}
open my $f_out, '>', $fn;
@@ -232,7 +232,7 @@
if ( $supercurl->{file} ) {
close $supercurl->{file};
- $get_obj->print( donemsg( $supercurl ) );
+ $get_obj->print( "DONE " . donemsg( $supercurl ) );
}
if ( $err ) {
@@ -244,7 +244,8 @@
RSGet::Dispatch::remove_interface( $if, "Interface $if is dead" );
$get_obj->{_abort} = "Interface $if is dead";
} elsif ( $error =~ /transfer closed with (\d+) bytes remaining to read/ ) {
- $get_obj->{_abort} = "PARTIAL, " . bignum( $1 ) . " bytes left";
+ RSGet::Dispatch::mark_used( $get_obj );
+ $get_obj->{_abort} = "PARTIAL " . donemsg( $supercurl );
}
$get_obj->problem();
return undef;
@@ -371,7 +372,7 @@
my $eta = s2string( $time_diff );
my $speed = sprintf "%.2f", $size_diff / ( $time_diff * 1024 );
- return "DONE " . bignum( $supercurl->{size_got} ) . "; ${speed}KB/s $eta";
+ return bignum( $supercurl->{size_got} ) . "; ${speed}KB/s $eta";
}
Modified: toys/rsget.pl/RSGet/Dispatch.pm
==============================================================================
--- toys/rsget.pl/RSGet/Dispatch.pm (original)
+++ toys/rsget.pl/RSGet/Dispatch.pm Thu Aug 27 17:25:15 2009
@@ -69,6 +69,7 @@
return "";
}
+ my %by_pos = map { $interfaces[ $_ ] => $_ } (0..$#interfaces);
my %by_if = map { $_ => 0 } @interfaces;
foreach ( values %$working ) {
next unless $_->{_pkg} eq $pkg;
@@ -81,8 +82,8 @@
my $lu = $last_used{$pkg} ||= {};
my @min_if = sort {
- my $_a = $lu->{ $a } || 0;
- my $_b = $lu->{ $b } || 0;
+ my $_a = $lu->{ $a } || $by_pos{ $a };
+ my $_b = $lu->{ $b } || $by_pos{ $b };
$_a <=> $_b
} grep { $by_if{ $_ } <= $min } keys %by_if;
return $min_if[ 0 ];
Modified: toys/rsget.pl/RSGet/FileList.pm
==============================================================================
--- toys/rsget.pl/RSGet/FileList.pm (original)
+++ toys/rsget.pl/RSGet/FileList.pm Thu Aug 27 17:25:15 2009
@@ -65,6 +65,11 @@
}
$reread = 2;
+ } elsif ( $type eq "text" ) {
+ foreach ( split /\n/, $text ) {
+ s/\s+$//;
+ push @added_text, $_."\n";
+ }
} elsif ( $type eq "comment" ) {
foreach ( split /\n/, $text ) {
s/\s+$//;
Modified: toys/rsget.pl/RSGet/Get.pm
==============================================================================
--- toys/rsget.pl/RSGet/Get.pm (original)
+++ toys/rsget.pl/RSGet/Get.pm Thu Aug 27 17:25:15 2009
@@ -55,6 +55,19 @@
}
}
+sub log
+{
+ my $self = shift;
+ my $text = shift;
+ my $line = $self->{_line};
+ return unless $line;
+
+ my $outifstr = $self->{_outif} ? "[$self->{_outif}]" : "";
+ my $getter = $getters{ $self->{_pkg} };
+ new RSGet::Line( "[$getter->{short}]$outifstr ", $self->{_name} . ": " . $text );
+}
+
+
sub print
{
my $self = shift;
Modified: toys/rsget.pl/RSGet/Processor.pm
==============================================================================
--- toys/rsget.pl/RSGet/Processor.pm (original)
+++ toys/rsget.pl/RSGet/Processor.pm Thu Aug 27 17:25:15 2009
@@ -217,6 +217,12 @@
} elsif ( s/^MULTI\s*\(// ) {
p_ret( "multi" );
p_line();
+ } elsif ( s/^PRINT\s*\(// ) {
+ pr $space . '$self->print(';
+ p_line();
+ } elsif ( s/^LOG\s*\(// ) {
+ pr $space . '$self->log(';
+ p_line();
} elsif ( s/^!\s+// ) {
my $line = quotemeta $_;
pr $space . 'return $self->problem( "'. $line .'" ) unless ';
More information about the pld-cvs-commit
mailing list