SVN: toys/rsget.pl: Get/UpFile README RSGet/Curl.pm RSGet/Get.pm RSGet/Tools.pm
sparky
sparky at pld-linux.org
Thu Oct 15 16:58:24 CEST 2009
Author: sparky
Date: Thu Oct 15 16:58:24 2009
New Revision: 10791
Modified:
toys/rsget.pl/Get/UpFile
toys/rsget.pl/README
toys/rsget.pl/RSGet/Curl.pm
toys/rsget.pl/RSGet/Get.pm
toys/rsget.pl/RSGet/Tools.pm
Log:
- some changes to ease backend debugging
Modified: toys/rsget.pl/Get/UpFile
==============================================================================
--- toys/rsget.pl/Get/UpFile (original)
+++ toys/rsget.pl/Get/UpFile Thu Oct 15 16:58:24 2009
@@ -15,7 +15,8 @@
my $info = $self->form( match => { action => qr{^/sms/check2.php$} } );
INFO( name => $info->get( "realname" ), size => $info->get( "sssize" ) );
- MULTI() if /Downloading is in process from your IP-Address/;
+ MULTI( "multi-download or free limit reached" )
+ if /Downloading is in process from your IP-Address/;
my $form;
! $form = $self->form( id => "Premium" );
Modified: toys/rsget.pl/README
==============================================================================
--- toys/rsget.pl/README (original)
+++ toys/rsget.pl/README Thu Oct 15 16:58:24 2009
@@ -3,6 +3,8 @@
- Write more documentation
- When continuing partially downloaded data start few kb before the end and
compare old with new.
+- Add commands: pause downloads, allow/don't allow captcha, clean done
+ downloads, and more
Planned features:
- Multiuser support (may require major changes in the code).
Modified: toys/rsget.pl/RSGet/Curl.pm
==============================================================================
--- toys/rsget.pl/RSGet/Curl.pm (original)
+++ toys/rsget.pl/RSGet/Curl.pm Thu Oct 15 16:58:24 2009
@@ -295,7 +295,7 @@
$supercurl->{fname} = $fname;
}
- $get_obj->set_finfo( $supercurl->{fname}, $supercurl->{size_total} );
+ $get_obj->started_download( fname => $supercurl->{fname}, fsize => $supercurl->{size_total} );
{
my $fn = $supercurl->{filepath} =
@@ -374,6 +374,7 @@
$get_obj->linedata();
my $eurl = $curl->getinfo( CURLINFO_EFFECTIVE_URL );
+ $get_obj->{content_type} = $curl->getinfo( CURLINFO_CONTENT_TYPE );
my $error = $curl->errbuf;
$curl = undef; # destroy curl before destroying getter
@@ -396,9 +397,6 @@
return undef;
}
- return unless $get_obj->{after_curl};
-
- my $func = $get_obj->{after_curl};
if ( $supercurl->{file} ) {
rename_done: {
my $infile = $supercurl->{filepath};
Modified: toys/rsget.pl/RSGet/Get.pm
==============================================================================
--- toys/rsget.pl/RSGet/Get.pm (original)
+++ toys/rsget.pl/RSGet/Get.pm Thu Oct 15 16:58:24 2009
@@ -53,6 +53,8 @@
_cmd => $cmd,
_pkg => $pkg,
_outif => $outif,
+ _id => (sprintf "%.6x", int rand 1 << 24),
+ _last_dump => 0,
make_cookie( $getter->{cookie}, $cmd ),
};
bless $self, $pkg;
@@ -186,7 +188,13 @@
my $keep_ref = shift;
$self->{_referer} = $ref unless $keep_ref;
+ $self->dump() if setting( "debug" ) >= 2;
+
my $func = $self->{after_curl};
+ unless ( $func ) {
+ $self->log( "WARNING: no after_curl" );
+ return;
+ }
$_ = $self->{body};
&$func( $self );
}
@@ -213,7 +221,8 @@
sub multi
{
my $self = shift;
- return $self->wait( \&start, -60 - 240 * rand, "multi-download not allowed", "multi" );
+ my $msg = shift || "multi-download not allowed";
+ return $self->wait( \&start, -60 - 240 * rand, $msg, "multi" );
}
sub finish
@@ -244,16 +253,7 @@
my $self = shift;
my $msg = shift;
if ( $self->{body} and setting( "debug" ) ) {
- my $n = 0;
- my $name;
- do {
- $name = "errorlog." . (++$n) . ".html";
- } while ( -r $name );
- open ERR_OUT, '>', $name;
- print ERR_OUT $self->{body};
- close ERR_OUT;
-
- $msg .= "; saved $name";
+ $self->dump();
}
$self->print( $msg ) || $self->log( $msg );
@@ -275,6 +275,29 @@
}
}
+sub dump
+{
+ my $self = shift;
+ my $ct = $self->{content_type};
+
+ my $ext = "txt";
+ if ( $ct =~ /javascript/ ) {
+ $ext = "js";
+ } elsif ( $ct =~ /(ht|x)ml/ ) {
+ $ext = "html";
+ } elsif ( $ct =~ m{image/(.*)} ) {
+ $ext = $1;
+ }
+ my $file = sprintf "dump.$self->{_id}.%.4d.$ext",
+ ++$self->{_last_dump};
+
+ open my $f_out, '>', $file;
+ print $f_out $self->{body};
+ close $f_out;
+
+ $self->log( "dumped to file: $file ($ct)" );
+}
+
sub bestinfo
{
my $self = shift;
@@ -332,19 +355,24 @@
return 1;
}
-sub set_finfo
+sub started_download
{
my $self = shift;
- my $fname = shift;
- my $fsize = shift;
+ my %opts = @_;
+ my $fname = $opts{fname};
+ my $fsize = $opts{fsize};
+
my $o = $self->{_opts};
$o->{fname} = $fname;
$o->{fsize} = $fsize;
$self->bestinfo();
+ my @osize;
+ @osize = ( fsize => $fsize ) if $fsize > 0;
+
RSGet::FileList::save( $self->{_uri},
globals => { fname => $fname, fsize => $fsize },
- options => { fname => $fname, fsize => $fsize } );
+ options => { fname => $fname, @osize } );
RSGet::FileList::update();
}
Modified: toys/rsget.pl/RSGet/Tools.pm
==============================================================================
--- toys/rsget.pl/RSGet/Tools.pm (original)
+++ toys/rsget.pl/RSGet/Tools.pm Thu Oct 15 16:58:24 2009
@@ -164,6 +164,7 @@
sub verbose
{
my $min = shift;
+ return 1 if setting( "debug" );
return 1 if setting( "verbose" ) >= $min;
return 0;
}
More information about the pld-cvs-commit
mailing list