root/trunk/plagger/lib/Plagger/Plugin/Subscription/2chThreadList.pm

Revision 587 (checked in by youpy, 14 years ago)

Add Plugin::Subscription::2chThreadList

Line 
1 package Plagger::Plugin::Subscription::2chThreadList;
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 $threadlist_uri = $self->conf->{url}
21         or $context->error('ThreadList url is missing');
22
23     my $remote = XML::Feed->parse(URI->new($threadlist_uri)) or $context->error("feed parse error $threadlist_uri");
24     for my $r ($remote->entries) {
25         $context->log(info => "thread: ". $r->link);
26
27         my $feed = Plagger::Feed->new;
28         $feed->url($r->link);
29         $feed->link($r->link);
30         $feed->title($r->title);
31         $context->subscription->add($feed);
32     }
33 }
34
35 1;
Note: See TracBrowser for help on using the browser.