あるウェブサイトから rel="me" というリンクを抽出して ActionStreams plugin の Other Profile に追加するスクリプト作った。ちょっといじれば tako3.com や fooo.name の情報から追加するものも作れるかと思います。
#!/usr/bin/perl -w
use strict;
use lib 'lib', '../../lib';
use MT::Bootstrap;
use MT;
use Web::Scraper;
use URI;
use Getopt::Long;
my ($uri, $author_id);
GetOptions(
'--uri=s' => \$uri,
'--author-id=s' => \$author_id,
);
die unless ($uri and $author_id);
package MT;
my %param;
sub param {
my $app = shift;
my $p = shift;
@_ ? $param{$p} = shift : $param{$p};
}
sub validate_magic { 1 }
my $user;
sub user {
unless($user) {
$user = MT->model('author')->load($author_id);
}
return $user;
}
sub uri {}
sub redirect {}
package main;
my $app = MT->new() or die MT->errstr;
my $scr = scraper {
process 'a[rel=~"me"]',
'profiles[]' => scraper {
process 'a', url => '@href';
};
result 'profiles';
};
my $profiles = $scr->scrape(URI->new($uri));
my $reg = $app->registry('profile_services');
my %services = map { $reg->{$_}->{url} => $_ }
grep {! $reg->{$_}->{ident_exact}} keys %$reg;
foreach my $profile (@$profiles) {
my ($ident, $type) = find_ident($profile->{url});
if ($type) {
add_profile($ident, $type);
}
}
sub find_ident {
my ($url) = @_;
my $ident;
my $type;
foreach my $url_pattern (keys %services) {
$ident = _find_ident($url_pattern, $url);
last if $ident and $type = $services{$url_pattern};
}
return $ident, $type;
}
sub _find_ident {
my ($url_pattern, $url) = @_;
$url =~ s{ \A http:// }{}xms;
$url =~ s{ / \z }{}xms;
my ($pre_ident, $post_ident) = split /\%s/, $url_pattern;
$pre_ident =~ s{ \A http:// }{}xms;
$post_ident =~ s{ / \z }{}xms;
if ($url =~ m{ \A (?:http://)? \Q$pre_ident\E (.*?) \Q$post_ident\E /? \z }xms) {
return $1;
}
## Grr.
$url =~ s{ \A www. }{}xms;
if ($url =~ m{ \A (?:http://)? \Q$pre_ident\E (.*?) \Q$post_ident\E /? \z }xms) {
return $1;
}
return;
}
sub add_profile {
my ($ident, $type) = @_;
my $app = MT->instance;
$app->param('author_id', $author_id);
$app->param('profile_type', $type);
$app->param('profile_id', $ident);
my @streams = keys %{ $app->registry('action_streams', $type) || {} };
foreach my $stream (@streams) {
my $param = join q{_}, 'stream', $type, $stream;
$app->param($param, 1);
}
use lib 'plugins/ActionStreams/lib';
use ActionStreams::Plugin;
use ActionStreams::Init;
my $ret = ActionStreams::Plugin::add_other_profile($app);
}

[this is good]
cool!
Nice! We should make the plugin do this, use the Google Social Graph API, or both.