だめだ、すげー重い。

backtick id lifespan autorefresh command

で autorefresh に 0 以外を指定するとその秒数毎に command が実行されるのだけど、実行されてる間 screen が固まるw

plagger でやるなら Notify::Pipe or Notify::File とかでなんかファイルに書き出しておいて

backtick id 0 0 tail -f そのファイル

かなー。

by typester / at 2006-03-06T16:05:00 / plagger · screen / Comment

plagger で backtick

plagger のみで backtick れるじゃんと、miyagawaさんにつっこまれたのでやってみた。

まず Plugin::Notify::Stdout を書いた。

package Plagger::Plugin::Notify::Stdout;
use strict;
use warnings;
use base qw/Plagger::Plugin/;

sub register {
    my ( $self, $c ) = @_;
    $c->register_hook(
        $self,
        'publish.feed'     => \&update,
        'publish.finalize' => \&finalize,
    );
    $self->{count} = 0;
}

sub update {
    my ( $self, $c, $args ) = @_;

    $self->{count} += $args->{feed}->count if $args->{feed}->count;
}

sub finalize {
    my ( $self, $c, $args ) = @_;

    if (defined $self->{count}) {
        $self->conf->{format}
            ? printf $self->conf->{format}, $self->{count}
            : print $self->{count};
        print "\n";
    }
}

ので下記のように backtick.yaml を作る

global:
  timezone: Asia/Tokyo
  log:
    level: error

plugins:
  - module: Subscription::Config
    config:
      feed: "https://username:password@mail.google.com/mail/feed/atom/!!Plagger" # !!Plagger はラベル名

  - module: Plagger::Plugin::Aggregator::Simple

  - module: Notify::Stdout
    config:
      format: "Plagger(%d) "

で、あとは .screenrc で

backtick 3 0 60 ${HOME}/plagger/plagger -c ${HOME}/.plagger/config/backtick.yaml

とか書いておけば 60 秒ごとに plagger が実行され、hardstatus とか caption とかで %3` とかけばそこにに plagger の出力が出る。

3 ていうのは backtick で指定した最初の数字 (僕がすでに0 1 2とIDを使ってるので3ってこと)

by typester / at 2006-03-06T15:45:00 / plagger · screen / Comment

Gmail の Atom フィードは https + basic 認証

と教えてもらった。!!!

さっき書いたの超意味ない。

#!/usr/bin/perl

use strict;
use warnings;
use Carp;
use LWP::UserAgent;
use MIME::Base64;

our $VERSION = '0.02';

# ---- Configurations ----------------
my $username = 'username';
my $password = 'base64::cGFzc3dvcmQ=';
my $label    = '!!Plagger';

my $interval = 60;
# ------------------------------------

if ( my ($crypt, $pass) = $password =~ /^(\w+)::(.+)$/ ) {
    $password = $crypt eq 'base64' ? decode_base64($pass) : undef;

    croak qq/Invalid password crypt type, "$crypt"/ unless $password;
}

my $ua = LWP::UserAgent->new;

my $feed_request =
    HTTP::Request->new( GET => "https://mail.google.com/mail/feed/atom/$label" );
$feed_request->headers->authorization_basic( $username, $password );

$|=1;
while (1) {
    my $res = $ua->request( $feed_request );

    my ($unread) = $res->content =~ m!<fullcount>(\d+)</fullcount>!m;
    print "Plagger($unread) \n" if defined $unread;

    sleep $interval;
}

これでOKだ。

by typester / at 2006-03-06T15:04:00 / plagger · screen / Comment

plagger_backtick.pl

つくた。

plagger backtick

こんな感じ。

#!/usr/bin/perl

use strict;
use warnings;
use Carp;
use WWW::Mechanize;
use HTTP::Cookies;
use MIME::Base64;

our $VERSION = '0.01';

# ---- Configurations ----------------
my $username = 'username';
my $password = 'base64::cGFzc3dvcmQ=';
my $label    = '!!Plagger';

my $interval = 60;
# ------------------------------------

if ( my ($crypt, $pass) = $password =~ /^(\w+)::(.+)$/ ) {
    $password = $crypt eq 'base64' ? decode_base64($pass) : undef;

    croak qq/Invalid password crypt type, "$crypt"/ unless $password;
}

my $mech = WWW::Mechanize->new( cookie_jar => HTTP::Cookies->new, );
$mech->agent_alias('Windows IE 6');

$|=1;
while (1) {
    $mech->get('http://mail.google.com/');
    if ( $mech->content =~ /ServiceLoginAuth/ ) {
        $mech->submit_form(
            fields => {
                Email  => $username,
                Passwd => $password,
            }
        );

        my ($redirect_url) = $mech->content =~ /url=(.*?)"/;
        $mech->get($redirect_url);
    }
    $mech->get("http://mail.google.com/mail/feed/atom/$label");

    my ($unread) = $mech->content =~ m!<fullcount>(\d+)</fullcount>!m;
    print "Plagger($unread) \n" if defined $unread;

    sleep $interval;
}

これ作ってて見つけたんだけど、Gmail の Atom フィードって URL に Label 名つけるとそれで絞り込めるのね。便利!!

by typester / at 2006-03-06T14:08:00 / plagger · screen / Comment

Gmail で読むということ

plagger つかって Gmail でフィードを読んでると、Bloglines 使ってたときより圧倒的に速く読み終わる。

けど、Bloglines のが読みやすい。この謎さ。

by typester / at 2006-03-06T11:32:00 / life · plagger / Comment

出社。

by typester / at 2006-03-06T09:54:00 / life / Comment

うおー、なんか筒井康隆の番組がGyaoに。

筒井ファン必見ですなー。なんか放送期限切れてるのも見れるな。。

by typester / at 2006-03-06T03:45:00 / life / Comment

退社。

by typester / at 2006-03-06T03:09:00 / life / Comment

livedoor FeedFetcher

って何だろう、同時に 20 回くらい同じフィードに対してリクエストくるんだけど。

by typester / at 2006-03-06T00:43:00 / life / Comment