Changeset 590 for grabbers/jrobbo

Show
Ignore:
Timestamp:
03/04/07 19:25:06 (6 years ago)
Author:
max
Message:

jrobbo now uses IO::Uncompress::unzip and performs extraction in memory rather than piping through /usr/bin/unzip.

This adds a new dependency, but a relatively common one. The advantage is
that user systems without /usr/bin/unzip will no longer run this grabber
uselessly nor die with runtime errors.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • grabbers/jrobbo

    r393 r590  
    88 
    99my $progname = "jrobbo"; 
    10 my $version = "0.06"; 
     10my $version = "0.07"; 
    1111 
    1212use LWP::UserAgent; 
    1313use Getopt::Long; 
    1414use XMLTV; 
     15use IO::Uncompress::Unzip qw(unzip $UnzipError) ; 
    1516$| = 1; 
    1617 
     
    4344$opt->{channels_file} =         ""; 
    4445$opt->{outputfile} =            "output.xmltv"; 
    45 $opt->{downloadfile} =          "last_jrobbo_download.zip"; 
    4646$opt->{region} =                94; 
    4747 
     
    5757        'channels_file=s' => \$opt->{channels_file},    # ignored 
    5858        'output=s'      => \$opt->{outputfile}, 
    59         'downloadfile=s' => \$opt->{downloadfile}, 
    6059        'warper'        => \$opt->{warper}, 
    6160        'anonymous'     => \$opt->{anonymous}, 
     
    7776        printf "   --region=<i>           region as per the table below (default $opt->{region})\n"; 
    7877        printf "   --output=<file>        file to send output to (default $opt->{outputfile})\n"; 
    79         printf "   --downloadfile=<file>  file to send output to (default $opt->{downloadfile})\n"; 
    8078        printf "   --warper               fetch via webwarper (default: don't)\n"; 
    8179        printf "   --anonymous            fetch anonymously (default: don't)\n"; 
     
    149147die "Failed to fetch $url after 3 retries!\n" if (!($response->is_success)); 
    150148 
    151 open(F,">$opt->{downloadfile}") || die "can't open $opt->{downloadfile} for writing: $!\n"; 
    152 print F $response->content; 
    153 close(F); 
    154  
    155  
    156149# 
    157150# 4. uncompress data 
     
    159152 
    160153my $data; 
    161 my $inputpipe = "/usr/bin/unzip -p $opt->{downloadfile} |"; 
    162 open(INFILE,"$inputpipe") || die "can't open $inputpipe for reading: $!\n"; 
    163 while (<INFILE>) { 
    164         $data .= $_; 
    165 } 
    166 close(INFILE); 
    167  
     154unzip \$response->content => \$data  
     155    or die "unzip failed: $UnzipError\n"; 
    168156 
    169157#