Changeset 1769

Show
Ignore:
Timestamp:
10/16/06 17:01:16
Author:
miyagawa
Message:
  • Moved Photocast/MediaRSS/Hatena specific parsing methods to Namespace::* plugins. w00t!
  • Added Bundle::Defaults plugin that loads bunch of "default" plugins
Files:

Legend:

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

    r1741 r1769  
    286286    my $self = shift; 
    287287 
     288    $self->autoload_plugin({ module => 'Bundle::Defaults' }); 
     289 
    288290    $self->run_hook('plugin.init'); 
    289291    $self->run_hook('subscription.load'); 
    290  
    291     unless ( $self->is_loaded(qr/^Aggregator::/) ) { 
    292         $self->load_plugin({ module => 'Aggregator::Simple' }); 
    293     } 
    294     $self->autoload_plugin({ module => 'Summary::Auto' }); 
    295     $self->autoload_plugin({ module => 'Summary::Simple' }); 
    296292 
    297293    for my $feed ($self->subscription->feeds) { 
  • trunk/plagger/lib/Plagger/Plugin/Aggregator/Simple.pm

    r1741 r1769  
    174174        } 
    175175 
    176         # TODO: move MediaRSS, Hatena, iTunes and those specific parser to be subclassed 
    177         $self->handle_media_rss($entry, $e); 
    178         $self->handle_hatena_image($entry, $e); 
    179         $self->handle_apple_photocast($entry, $e); 
    180  
    181176        my $args = { 
    182177            entry      => $entry, 
     
    192187    $context->log(info => "Aggregate $url success: " . $feed->count . " entries."); 
    193188    $context->update->add($feed); 
    194 } 
    195  
    196 sub handle_media_rss { 
    197     my($self, $entry, $e) = @_; 
    198  
    199     my $media_ns = "http://search.yahoo.com/mrss"; 
    200     my $media = $e->{entry}->{$media_ns}->{group} || $e->{entry}; 
    201     my $content = $media->{$media_ns}->{content} || []; 
    202     $content = [ $content ] unless ref $content && ref $content eq 'ARRAY'; 
    203  
    204     for my $media_content (@{$content}) { 
    205         my $enclosure = Plagger::Enclosure->new; 
    206         $enclosure->url( URI->new($media_content->{url}) ); 
    207         $enclosure->auto_set_type($media_content->{type}); 
    208         $entry->add_enclosure($enclosure); 
    209     } 
    210  
    211     if (my $thumbnail = $media->{$media_ns}->{thumbnail}) { 
    212         $entry->icon({ 
    213             url   => $thumbnail->{url}, 
    214             width => $thumbnail->{width}, 
    215             height => $thumbnail->{height}, 
    216         }); 
    217     } 
    218 } 
    219  
    220 sub handle_hatena_image { 
    221     my($self, $entry, $e) = @_; 
    222  
    223     # Hatena Image extensions 
    224     my $hatena = $e->{entry}->{"http://www.hatena.ne.jp/info/xmlns#"} || {}; 
    225     if ($hatena->{imageurl}) { 
    226         my $enclosure = Plagger::Enclosure->new; 
    227         $enclosure->url($hatena->{imageurl}); 
    228         $enclosure->auto_set_type; 
    229         $entry->add_enclosure($enclosure); 
    230     } 
    231  
    232     if ($hatena->{imageurlsmall}) { 
    233         $entry->icon({ url   => $hatena->{imageurlsmall} }); 
    234     } 
    235 } 
    236  
    237 sub handle_apple_photocast { 
    238     my($self, $entry, $e) = @_; 
    239  
    240     my $apple = $e->{entry}->{"http://www.apple.com/ilife/wallpapers"} || {}; 
    241     if ($apple->{image}) { 
    242         my $enclosure = Plagger::Enclosure->new; 
    243         $enclosure->url( URI->new($apple->{image}) ); 
    244         $enclosure->auto_set_type; 
    245         $entry->add_enclosure($enclosure); 
    246     } 
    247     if ($apple->{thumbnail}) { 
    248         $entry->icon({ url => $apple->{thumbnail} }); 
    249     } 
    250189} 
    251190