Seacolor Labs. このページをアンテナに追加 RSSフィード

2006-06-17

[] Subscription::SoftAntenna 19:27  Subscription::SoftAntenna - Seacolor Labs. を含むブックマーク はてなブックマーク -  Subscription::SoftAntenna - Seacolor Labs.  Subscription::SoftAntenna - Seacolor Labs. のブックマークコメント

試しにSubscriptionでSoftAntennaを作っているのだけれど、これがなぜだか上手くいかないわけです。

package Plagger::Plugin::Subscription::SoftAntenna;
use strict;
use base qw( Plagger::Plugin );

use Plagger::UserAgent;
use Plagger::Util;
use Encode;
use URI;

sub register {
    my($self, $context) = @_;

    $context->register_hook(
        $self,
        'subscription.load' => \&load,
    );
}

sub load {
    my($self, $context) = @_;

    my $url = URI->new("http://www.softantenna.com/index.html");

    $context->log(debug => "GET $url");

    my $agent = Plagger::UserAgent->new;
    my $res = $agent->fetch($url, $self);

    if ($res->http_response->is_error) {
        $context->log(error => "GET $url failed: " . $res->status_line);
        return;
    }

    my $content = Plagger::Util::decode_content($res);
    my $title   = Plagger::Util::extract_title($content);

    my $feed = Plagger::Feed->new;
    $feed->url($url) or $context->error("URL is missing");
    $feed->title(decode('iso 2022-jp', $title));
    $feed->link($url);

    while ($content =~ m!<li class=saitem><strong><a href="(https?://[^"]*)">(.*?)</a>[^\n]+\n<span class=small>(.*?)</span>\n!g) {
        my($link, $title, $body) = ($1, $2, $3);

        my $entry = Plagger::Entry->new;
        $entry->title(decode('iso 2022-jp', $title));
        $entry->link($link);
        $entry->body(decode('iso 2022-jp', $body));

        $feed->add_entry($entry);
    }

    $context->subscription->add($feed);
}

1;

実行すると、

Plagger [info] plugin Plagger::Plugin::Subscription::SoftAntenna loaded.
Plagger [info] plugin Plagger::Plugin::Publish::Feed loaded.
Plagger::Plugin::Subscription::SoftAntenna [debug] GET http://www.softantenna.co
m/index.html
Plagger::Cache [debug] Cache HIT: Subscription-SoftAntenna|http://www.softantenn
a.com/index.html
Plagger [info] plugin Plagger::Plugin::Aggregator::Simple loaded.
Plagger::Plugin::Aggregator::Simple [info] Fetch http://www.softantenna.com/inde
x.html
Plagger::Cache [debug] Cache HIT: Aggregator-Simple|http://www.softantenna.com/i
ndex.html
Plagger::Plugin::Aggregator::Simple [debug] 200: http://www.softantenna.com/inde
x.html
Plagger [error] http://www.softantenna.com/index.html is not aggregated by any a
ggregator

となってしまう。

なぜにAggregator::Simpleがエラー起こしてるんだろう……?