Changeset 1945
- Timestamp:
- 05/01/07 00:00:02
- Files:
-
- trunk/plagger (modified) (previous)
- trunk/plagger/deps/Filter-Delicious.yaml (modified) (1 diff)
- trunk/plagger/lib/Plagger/Plugin/Filter/Delicious.pm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plagger/deps/Filter-Delicious.yaml
r1362 r1945 2 2 author: Tatsuhiko Miyagawa, Taro Funaki 3 3 depends: 4 JSON::Syck: 0 trunk/plagger/lib/Plagger/Plugin/Filter/Delicious.pm
r1734 r1945 3 3 use base qw( Plagger::Plugin ); 4 4 5 use JSON::Syck; 5 6 use Digest::MD5 qw(md5_hex); 6 7 use Plagger::UserAgent; 7 use XML::Feed;8 8 9 9 sub register { … … 22 22 23 23 my $md5 = md5_hex($args->{entry}->permalink); 24 my $url = "http://del.icio.us/rss/url/$md5";24 my $url = "http://badges.del.icio.us/feeds/json/url/data?hash=$md5"; 25 25 26 26 $self->log(info => "Going to fetch $url"); … … 33 33 return; 34 34 } 35 36 my $feed = XML::Feed->parse(\$res->content); 37 38 unless ($feed) { 39 $context->log(warn => "Feed error $url: " . XML::Feed->errstr); 35 36 my $data = JSON::Syck::Load($res->content); 37 unless (ref $data eq 'ARRAY') { 38 $self->log(error => "json parse error: $data"); 40 39 return; 41 40 } 41 my $h = @{$data}[0]; 42 42 43 for my $entry ($feed->entries) { 44 my @tag = split / /, ($entry->category || ''); 45 @tag or next; 46 47 for my $tag (@tag) { 48 $args->{entry}->add_tag($tag); 49 } 43 for my $tag (keys %{$h->{top_tags}}) { 44 $args->{entry}->add_tag($tag); 45 $self->log(debug => "add tag $tag"); 50 46 } 51 47 52 my $delicious_users = $feed->entries; 53 if ($delicious_users >= 30 && $self->conf->{scrape_big_numbers}) { 54 my $url = "http://del.icio.us/url/$md5"; 55 $self->log(info => "users count is more than 30. Trying to scrape from $url."); 56 sleep $interval; 57 58 my $res = $ua->fetch($url); 59 60 if ($res->is_error) { 61 $context->log(warn => "Fetch error $url: " . $res->http_response->message); 62 return; 63 } 64 65 $delicious_users = 66 ( $res->content =~ m#<h4[^>]*>[^<>]*this url has been saved by\D+(\d+)#s )[0]; 67 } 48 my $delicious_users = $h->{total_posts} || 0; 68 49 $args->{entry}->meta->{delicious_rate} = rate_of_color($delicious_users); 69 50 $args->{entry}->meta->{delicious_users} = $delicious_users; … … 95 76 be likely to ban your IP. See http://del.icio.us/help/ for details.> 96 77 97 This plugin queries del.icio.us using its RSS feeds API to get the98 tagspeople added to the entries, and how many people bookmarked them.78 This plugin queries del.icio.us using its JSON API to get the tags 79 people added to the entries, and how many people bookmarked them. 99 80 100 81 Users count is stored in C<delicious_users> metadata of … … 107 88 =head1 SEE ALSO 108 89 109 L<Plagger>, L<http://del.icio.us/help/> 90 L<Plagger>, L<http://del.icio.us/help/>, L<http://del.icio.us/help/json/url> 110 91 111 92 =cut
