Changeset 2027

Show
Ignore:
Timestamp:
03/24/08 22:44:48
Author:
charsbar
Message:

CustomFeed?::MixiScraper?: split_bbs_feed

Files:

Legend:

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

    r2026 r2027  
    8686    for my $type (@{$self->conf->{feed_type} || ['FriendDiary']}) { 
    8787        $context->error("$type not found") unless $MAP->{$type}; 
    88         $self->aggregate_feed($context, $type, $args); 
     88        if ($type eq 'BBS' and $self->conf->{split_bbs_feed}) { 
     89            $self->aggregate_bbs_feed($context, $type, $args); 
     90        } 
     91        else { 
     92            $self->aggregate_feed($context, $type, $args); 
     93        } 
    8994    } 
    9095} 
     
    114119 
    115120    $context->update->add($feed); 
     121} 
     122 
     123sub aggregate_bbs_feed { 
     124    my($self, $context, $type, $args) = @_; 
     125 
     126    my $meth = $MAP->{$type}->{get_list}; 
     127    my @msgs = $self->{mixi}->$meth->parse; 
     128    my $items = $self->conf->{fetch_items} || 20; 
     129    $self->log(info => 'fetch ' . scalar(@msgs) . ' entries'); 
     130 
     131    my $i = 0; 
     132    $self->{blocked} = 0; 
     133    for my $msg (@msgs) { 
     134        next if $type eq 'FriendDiary' and $msg->{link}->query_param('url'); # external blog 
     135        last if $i++ >= $items; 
     136 
     137        my $feed = Plagger::Feed->new; 
     138        $feed->type('mixi'); 
     139        (my $subject = $msg->{subject}) =~ s/\(\d+\)$//; 
     140        (my $link = $msg->{link}) =~ s/&comment_count=\d*//; 
     141        $feed->title($subject); 
     142        $feed->description($MAP->{$type}->{title}.': '.$msg->{name}); 
     143        $feed->link($link); 
     144 
     145        $self->add_entry( $context, $type, $feed, $msg ); 
     146 
     147        $context->update->add($feed); 
     148    } 
    116149} 
    117150 
     
    273306mixi.jp site, which makes the output HTML very user-friendly. 
    274307 
     308=item split_bbs_feed 
     309 
     310With this option set, BBS feed will be split up. Defaults to 0. 
     311 
    275312=item feed_type 
    276313