root/trunk/plagger/lib/Plagger/Plugin/Subscription/Bloglines.pm

Revision 6 (checked in by miyagawa, 14 years ago)

mark_read config bug

  • Property svn:keywords set to Id Revision
Line 
1 package Plagger::Plugin::Subscription::Bloglines;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 our $VERSION = '0.10';
6 use WebService::Bloglines;
7
8 sub register {
9     my($self, $context) = @_;
10     $context->register_hook(
11         $self,
12         'subscription.load'    => \&load,
13         'subscription.aggregate'   => \&aggregate,
14     );
15 }
16
17 sub load {
18     my($self, $context) = @_;
19     $self->{bloglines} = WebService::Bloglines->new(
20         username => $self->conf->{username},
21         password => $self->conf->{password},
22     );
23
24     my $count = $self->{bloglines}->notify();
25     $context->log(debug => "You have $count unread item(s) on Bloglines.");
26     $self->{bloglines_new} = $count;
27 }
28
29 sub aggregate {
30     my($self, $context) = @_;
31
32     return unless $self->{bloglines_new};
33
34     my @updates = $self->{bloglines}->getitems(0, $self->conf->{mark_read});
35     $context->log(debug => scalar(@updates) . " feed(s) updated.");
36
37     for my $update (@updates) {
38         my $feed = Plagger::Feed->new($update->feed);
39         $feed->stash->{bloglines_id} = $update->feed->{bloglines}->{siteid};
40
41         for my $item ( $update->items ) {
42             $feed->add_entry( Plagger::Entry->new($item) );
43         }
44
45         $context->update->add($feed);
46     }
47 }
48
49 1;
50
Note: See TracBrowser for help on using the browser.