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

Revision 361 (checked in by tokuhirom, 14 years ago)

added Subscription::HatenaGroup?

Line 
1 package Plagger::Plugin::Subscription::HatenaGroup;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 use URI;
6 use XML::Feed;
7
8 sub register {
9     my($self, $context) = @_;
10
11     $context->register_hook(
12         $self,
13         'subscription.load' => \&load,
14     );
15 }
16
17 sub load {
18     my($self, $context) = @_;
19
20     my $group = $self->conf->{group}
21         or $context->error('group is missing');
22
23     my $feed_uri = "http://$group.g.hatena.ne.jp/diarylist?mode=rss";
24
25     my $remote = XML::Feed->parse(URI->new($feed_uri)) or $context->error("feed parse error $feed_uri");
26     for my $r ($remote->entries) {
27         $context->log(info => "diary: ". $r->link);
28
29         my $feed = Plagger::Feed->new;
30         $feed->url($r->link . "rss");
31         $feed->link($r->link);
32         $feed->title($r->title);
33         $context->subscription->add($feed);
34     }
35 }
36
37 1;
38
39 __END__
40
41 =head1 NAME
42
43 Plagger::Plugin::Subscription::HatenaGroup - HatenaGroup Subscription via RSS
44
45 =head1 SYNOPSIS
46
47   - module: Subscription::HatenaGroup
48     config:
49       group: subtech
50
51 =head1 DESCRIPTION
52
53 Subscription from Hatena Group.
54
55 =head1 AUTHOR
56
57 Tokuhiro Matsuno
58
59 =head1 SEE ALSO
60
61 L<Plagger>, L<XML::Feed>
62
63 =cut
Note: See TracBrowser for help on using the browser.