| Plagger documentation | Contained in the Plagger distribution. |
Plagger::Plugin::Subscription::Odeo - Odeo Subscription via OPML
- module: Subscription::Odeo
config:
account: TatsuhikoMiyagawa
This plugin creates Subscription by fetching Odeo http://www.odeo.com/ OPML by HTTP.
We should probably better use rss.xml or pcast.xml they provide and
synchronizes enclosures as well, ala Bloglines Subscription plugin.
Tatsuhiko Miyagawa
| Plagger documentation | Contained in the Plagger distribution. |
package Plagger::Plugin::Subscription::Odeo; use strict; use base qw( Plagger::Plugin::Subscription::OPML ); use Plagger::UserAgent; use URI::Escape; use HTML::Entities; sub register { my($self, $context) = @_; $context->register_hook( $self, 'subscription.load' => \&load, ); } sub load { my($self, $context) = @_; my $account = $self->conf->{account} or $context->error("config 'account' is missing"); my $uri = URI->new("http://www.odeo.com/profile/$account/opml.xml"); $context->log(debug => "Fetch remote OPML from $uri"); my $response = Plagger::UserAgent->new->get($uri); unless ($response->is_success) { $context->error("Fetch $uri failed: ". $response->status_line); } my $xml = $response->content; # fix Odeo's bad OPML $xml =~ s{<outline text="(.*?)" type="link" url="(http://.*?)" count="(\d+)"/>}{ my($title, $url, $count) = ($1, $2, $3); $title = uri_unescape($title); $title =~ s/\r\n//g; $title =~ tr/\+/ /; $title = encode_html($title); $url = encode_html($url); qq(<outline text="$title" type="rss" xmlUrl="$url" count="$count"/>) }eg; $self->load_opml($context, \$xml); } sub encode_html { HTML::Entities::encode($_[0], q("<>&)); } 1; __END__