ダメポ

id:kazuhooku さんに先のエントリーで提示した patch に

     my $content = Jcode::convert($self->{response}->content, $self->{ocode});
+print $content,"\n";
     return $self->parse_externalAPINotify($content);


+print $content,"\n";

標準出力へのデバッグプリントを含めてしまった・・・ orz


償います。償います。償わせてください・・・

WWW::CybozuOffice6

パッチを取り込んでいただけると幸せなのでトラバってみます。
今更なネタですみません。

--- lib/WWW/CybozuOffice6.pm.org        2006-08-25 14:29:04.429690184 +0900
+++ lib/WWW/CybozuOffice6.pm            2006-08-25 15:44:06.187475288 +0900
@@ -12,7 +12,7 @@
 use 5.006;
 use strict;
 use warnings;
-use fields qw(url user pass ua response ocode);
+use fields qw(url user id pass ua response ocode);
 use vars qw($VERSION);

 use Carp;
@@ -57,6 +57,11 @@
     return $self->_accessor('user', @_);
 }

+sub id (\$@) {
+    my $self = shift;
+    return $self->_accessor('id', @_);
+}
+
 sub password (\$@) {
     my $self = shift;
     return $self->_accessor('pass', @_);
@@ -94,6 +99,7 @@
     }
     # parse and return the result
     my $content = Jcode::convert($self->{response}->content, $self->{ocode});
+print $content,"\n";
     return $self->parse_externalAPINotify($content);
 }

@@ -153,14 +159,15 @@
 sub _request (\$$) {
     my ($self, $page) = @_;
     croak 'url not set' unless defined($self->{url});
-    croak 'user not set' unless defined($self->{user});
+    croak 'user/id not set' unless defined $self->{user} or defined $self->{id};
     croak 'password not set' unless defined($self->{pass});
     $self->{response} =
        $self->{ua}->post($self->{url} . '?page=' . uri_escape($page),
                          { _System => 'login',
                            _Login => '1',
                            GuideNavi => '1',
-                           _Account => $self->{user},
+                           defined $self->{user} ? (_Account => $self->{user}) : (),
+                           defined $self->{id} ? (_Id => $self->{id}) : (),
                            Password => $self->{pass} });
     return $self->{response}->is_success;
 }

# うちで使ってるサイボウズはアカウントがプルダウンの選択式でした。色々あるんですね。

mizzyさんの技を盗むの巻

MEncoder::Command

package MEncoder::Command;

use strict;
use base qw(Class::Accessor::Fast Class::ErrorHandler);
use IPC::Run qw(start);

our $VERSION = '0.01';

__PACKAGE__->mk_accessors qw(
    input_file output_file mencoder options
);

my %option = (
    video_codec => '-ovc',
    audio_codec => '-oac',
);

sub new {
    my $class = shift;
    my $self = {
        mencoder    => shift || 'mencoder',
        options     => { audio_codec => [], video_codec => [] },
        input_file  => '',
        output_file => '',
    };
    bless $self, $class;
}

sub encode_options {
    my ($self, %args) = @_;
    for (keys %args) {
        next unless (exists $option{$_});
        push @{ $self->options->{$_} },
            (! @{ $self->options->{$_} } ? $option{$_} : qw{}),
            @{ $args{$_} };
    }
}

sub video_options { shift->encode_options(video_codec => [ @_ ]) }
sub audio_options { shift->encode_options(audio_codec => [ @_ ]) }

sub execute {
    my $self = shift;
    my ($in, $out, $err);
    my $h = eval {
        start [
            $self->mencoder,
            $self->input_file,
            @{ $self->options->{video_codec} },
            @{ $self->options->{audio_codec} },
            '-o', $self->output_file,
        ], \$in, \$out, \$err;
    };
    if ($@) {
        $self->error($@);
        return;
    }
    else {
        finish $h or do {
            $self->error($err);
            return;
        };
    }
    return 1;
}

*exec = \&execute;

1;

__END__

=head1 SYNOPSIS

    use MEncoder::Command;

    my $mencoder = MEncoder::Command->new;

    $mencoder->input_file('./test.amc');

    $mencoder->output_file('./test.avi');

    $mencoder->encode_options(
        video_codec => [qw/ lavc /],
        audio_codec => [qw/ mp3lame -lameopts preset=standard /],
    );

    # or
    # $mencoder->video_options('lavc');
    # $mencoder->audio_options(qw/ mp3lame -lameopts preset=standard /);

    $mencoder->exec;

=cut

mizzyさんのコードまるパクリな上に、微妙にインターフェース変えてあって、、厄介なこと、この上なし。

はい、次行ってみよー。