Show
Ignore:
Timestamp:
12/14/07 23:09:50 (12 months ago)
Author:
hsbt
Message:

lang/perl/plagger/lib/Plagger/Plugin/Filter/FetchNicoVideo.pm: added interval time(optional).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/plagger/lib/Plagger/Plugin/Filter/FetchNicoVideo.pm

    r1105 r3147  
    88use File::Spec; 
    99use HTTP::Request; 
     10use Time::HiRes qw(sleep); 
    1011use Plagger::Enclosure; 
    1112use Plagger::UserAgent; 
     
    7576    my $path = File::Spec->catfile( $self->conf->{dir}, $filename . ".flv" ); 
    7677 
    77     #access video page 
    78     $ua->get("http://www.nicovideo.jp/watch/$video_id"); 
     78    unless ( -e $path ) { 
     79        #access video page 
     80        $ua->get("http://www.nicovideo.jp/watch/$video_id"); 
    7981 
    80     #download flv file 
    81      unless ( -e $path ) { 
    82      my $req = HTTP::Request->new(GET => $enclosure->url); 
    83          $context->log(info => "Fetching $video_id FLV File from " . $enclosure->url . "..." ); 
    84          my $res = $ua->request($req, $path); 
    85          $context->log(warn => "Fetch FLV Error: $video_id" ) if $res->is_error; 
     82        #download flv file 
     83        my $req = HTTP::Request->new(GET => $enclosure->url); 
     84        $context->log(info => "Fetching $video_id FLV File from " . $enclosure->url . "..." ); 
     85        my $res = $ua->request($req, $path); 
     86        $context->log(warn => "Fetch FLV Error: $video_id" ) if $res->is_error;  
     87    }else{ 
     88        $context->log(info => "Exist FLV File: $video_id");  
     89        my $sleeping_time = $self->conf->{interval} || 15; 
     90        $context->log(info => "sleep $sleeping_time."); 
     91        sleep( $sleeping_time ); 
    8692    } 
    8793 
     
    108114    } 
    109115    $entry->add_enclosure($enclosure); 
    110  
    111     sleep(1); 
    112116} 
    113117 
     
    129133      download_xml: 1 #optional default is 0 
    130134      filename_encode: euc-jp #optional default is utf-8 
     135      interval: 60 #optional default is 15 
    131136 
    132137=head1 DESCRIPTION