Changeset 246

Show
Ignore:
Timestamp:
08/28/06 22:12:18 (2 years ago)
Author:
miya
Message:

Filter::Audi: some fixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plagger/trunk/lib/Plagger/Plugin/Filter/Audio.pm

    r245 r246  
    2020    my($self, $context, $args) = @_; 
    2121 
     22    my $from = $self->conf->{from}; 
     23    my $to   = $self->conf->{to}; 
     24 
    2225    my $e = $args->{entry}; 
    2326 
    2427    { 
    2528        no strict 'refs'; 
    26         *convert = *{ $self->conf->{from} . '2' . $self->conf->{to} }; 
     29        *convert = *{ $from . '2' . $to }; 
    2730    } 
    2831 
     
    3336    } 
    3437 
    35     my $basename = basename($local_path, $self->conf->{from}); 
    36     my $converted_file = File::Spec->catfile($self->conf->{dir}, $basename . $self->conf->{to}); 
    37     my $status = convert($local_path) unless -e $converted_file
     38    my $basename = basename($local_path, $from); 
     39    my $local_dir = dirname($local_path); 
     40    my $converted_file = File::Spec->catfile($self->conf->{dir}, $basename . $to)
    3841 
    39     if($status){ 
    40         move($local_path, $converted_file); 
    41         my $st = stat($converted_file); 
    42         $e->enclosure->length($st->size); 
    43         $e->enclosure->local_path($converted_file); 
    44         $e->enclosure->filename($basename . $self->conf->{to}); 
    45         $e->enclosure->type( Plagger::Util::mime_type_of($self->conf->{to}) ); 
     42    unless ( -e $converted_file ){ 
     43        my $status = convert($local_path); 
     44        unless ( $status ) { 
     45            $context->log(error => "Could not convert $local_path" ); 
     46            return; 
     47        } 
    4648    } 
    47     else { 
    48         $context->log(error => "Could not convert $local_path" ); 
    49     } 
     49 
     50    move( File::Spec->catfile( $local_dir, $basename . $to ), $converted_file ); 
     51    my $st = stat($converted_file); 
     52    $e->enclosure->length($st->size); 
     53    $e->enclosure->local_path($converted_file); 
     54    $e->enclosure->filename($basename . $to); 
     55    $e->enclosure->type( Plagger::Util::mime_type_of($to) ); 
    5056} 
    5157