root/trunk/plagger/lib/Plagger/Plugin/Filter/LivedoorClipUsersCount.pm

Revision 1707 (checked in by otsune, 14 years ago)

opps... fix POD

Line 
1 package Plagger::Plugin::Filter::LivedoorClipUsersCount;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 use XMLRPC::Lite;
6
7 sub register {
8     my ( $self, $context ) = @_;
9     $context->register_hook(
10         $self,
11         'update.feed.fixup' => \&update,
12     );
13 }
14
15 sub update {
16     my ( $self, $context, $args ) = @_;
17
18     my @permalink = map $_->permalink, $args->{feed}->entries;
19
20     $context->log( info => 'Requesting XMLRPC call to livedoorClip with '
21             . scalar(@permalink)
22             . ' link(s)' );
23
24     my $map = XMLRPC::Lite
25         ->proxy('http://rpc.clip.livedoor.com/count')
26         ->call( 'clip.getCount', @permalink )
27         ->result;
28
29     unless ($map) {
30         $context->log( warn => 'livedoorClip XMLRPC failed' );
31         return;
32     }
33
34     $context->log( info => 'XMLRPC request success.' );
35
36     for my $entry ( $args->{feed}->entries ) {
37         if ( defined( my $count = $map->{ $entry->permalink } ) ) {
38             $entry->meta->{livedoorclip_users} = $count;
39         }
40     }
41 }
42
43 1;
44 __END__
45
46 =head1 NAME
47
48 Plagger::Plugin::Filter::LivedoorClipUsersCount - Queries livedoorClip users count
49
50 =head1 SYNOPSIS
51
52   - module: Filter::LivedoorClipUsersCount
53
54 =head1 DESCRIPTION
55
56 This plugin queries livedoor Clip (L<http://clip.livedoor.com/>) how
57 many people clipped each of feed entries, using its XMLRPC API
58 C<clip.getCount>.
59
60 Users count is stored in C<livedoorclip_users> metadata of
61 Plagger::Entry so that other plugins or smartfeeds can make use of.
62
63 =head1 AUTHOR
64
65 Masafumi Otsune
66
67 =head1 SEE ALSO
68
69 L<Plagger>, L<http://wiki.livedoor.jp/staff_clip/d/%a5%af%a5%ea%a5%c3%a5%d7%b7%ef%bf%f4%bc%e8%c6%c0%20API>
70
71 =cut
Note: See TracBrowser for help on using the browser.