アグリゲートしてきた中にAmazonアソシエイトIDがあったら、それを自分のものに変えちゃいます。えぇえぇ、アサマシですわ。使用により生じた問題に対し、当方は一切責任を負いませんw
package Plagger::Plugin::Filter::AmazonAssociateIDShift;
use strict;
use base qw( Plagger::Plugin );
sub register {
my($self, $context) = @_;
$context->register_hook(
$self,
'update.entry.fixup' => \&update,
);
}
sub update {
my($self, $context, $args) = @_;
my $body = $self->filter($args->{entry}->body);
$args->{entry}->body($body);
}
sub filter {
my($self, $body) = @_;
if ($self->conf->{associate_id}) {
my $url_re = qr#(http://www.amazon.co.jp/exec/obidos/ASIN/[^/]+/)[0-9a-z]+-\d{2}#;
$body =~ s#$url_re#$1 . $self->conf->{associate_id}#ieg;
}
$body;
}
1;
__END__
=head1 NAME
Plagger::Plugin::Filter::AmazonAssociateIDShift - Shift from other's amazon associate id to your it
=head1 SYNOPSIS
- module: Filter::AmazonAssociateIDShift
config:
associate_id: your_associate_id
=head1 SEE ALSO
L<Plagger>, L<http://www.amazon.co.jp/>
=back