[sbm] del.icio.us to hatebu
del.icio.us に登録したエントリをはてブにシンクロするためのレシピ。1日1回動かすような用途を想定しています。del.icio.us に登録した順番ではてブに登録されるように del.icio.us の RSS のエントリーの順序を逆転させるためのフィルタ (Reverse) を用意しました。del.icio.us の RSS を入力としているので、登録エントリ数が多いと RSS から漏れてしまうエントリが発生するという問題があります。del.icio.us API で前回取得したエントリー以降を取得できれば完璧なのですが、とりあえず運用でカバーしています。(私は1日30エントリもブックマークしないので....)
global: # plugin_path: **** # assets_path: **** timezone: Asia/Tokyo log: level: info plugins: - module: Subscription::Config config: feed: - url: http://del.icio.us/rss/****** - module: Aggregator::Simple - module: Filter::Reverse # remove entries older than mtime of tmp file. - module: Filter::Rule rule: module: Fresh mtime: path: ****/plagger/cache/plagger-delicious2hatebu.tmp autoupdate: 1 - module: Filter::DeliciousFeedTags - module: Publish::HatenaBookmark config: username: ******* password: ******* interval: 8 post_body: 1
Filter/Reverse.pm
package Plagger::Plugin::Filter::Reverse; use strict; use base qw( Plagger::Plugin ); sub register { my($self, $context) = @_; $context->register_hook( $self, 'update.feed.fixup' => \&feed ); } sub feed { my($self, $context, $args) = @_; $context->log(debug => "reverse"); my @entries = $args->{feed}->entries; @entries = reverse(@entries); $args->{feed}->{entries} = \@entries; } 1;