Changeset 335

Show
Ignore:
Timestamp:
03/06/06 10:35:28
Author:
miyagawa
Message:

Subscriptoin::Bloglines: when it encounters bad XML, falls back to loop mode. Fixes #100

Files:

Legend:

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

    r334 r335  
    5555        username => $self->conf->{username}, 
    5656        password => $self->conf->{password}, 
    57         use_liberal => 1, 
     57#        use_liberal => 1, 
    5858    ); 
    5959} 
     
    109109       $mark_read = 1 unless defined $mark_read; 
    110110 
    111     my @updates = $self->{bloglines}->getitems(0, $mark_read); 
     111    my @updates; 
     112 
     113    # catch bad XML feed by Bloglines 
     114    eval { 
     115        @updates = $self->{bloglines}->getitems(0, $mark_read); 
     116    }; 
     117 
     118    if ($@) { 
     119        $context->log(warn => "Bloglines Sync API returned bad XML. fallbacks to loop mode"); 
     120        my @feeds = $self->{bloglines}->listsubs()->feeds; 
     121        for my $feed (@feeds) { 
     122            if ($feed->{BloglinesUnread}) { 
     123                $context->log(debug => "Fetch $feed->{BloglinesSubId}"); 
     124                push @updates, eval { $self->{bloglines}->getitems($feed->{BloglinesSubId}, $mark_read) }; 
     125            } 
     126        } 
     127    } 
     128 
    112129    $context->log(info => scalar(@updates) . " feed(s) updated."); 
    113130