Changeset 1010

Show
Ignore:
Timestamp:
06/22/06 17:17:18
Author:
miyagawa
Message:

some RSS feeds contain multi enclosures, either way we parse them

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Plugin/Aggregator/Simple.pm

    r867 r1010  
    144144 
    145145        # enclosure support, to be added to XML::Feed 
    146         if ($remote->format =~ /^RSS / && $e->{entry}->{enclosure}) { 
    147             my $enclosure = Plagger::Enclosure->new; 
    148             $enclosure->url( URI->new($e->{entry}->{enclosure}->{url}) ); 
    149             $enclosure->length($e->{entry}->{enclosure}->{length}); 
    150             $enclosure->auto_set_type($e->{entry}->{enclosure}->{type}); 
    151             $entry->add_enclosure($enclosure); 
     146        if ($remote->format =~ /^RSS / and my $encls = $e->{entry}->{enclosure}) { 
     147            # some RSS feeds contain multiple enclosures, and we support them 
     148            $encls = [ $encls ] unless ref $encls eq 'ARRAY'; 
     149 
     150            for my $encl (@$encls) { 
     151                my $enclosure = Plagger::Enclosure->new; 
     152                $enclosure->url( URI->new($encl->{url}) ); 
     153                $enclosure->length($encl->{length}); 
     154                $enclosure->auto_set_type($encl->{type}); 
     155                $entry->add_enclosure($enclosure); 
     156            } 
    152157        } elsif ($remote->format eq 'Atom') { 
    153158            for my $link ( grep { $_->rel eq 'enclosure' } $e->{entry}->link ) {