Sorauta-Capture-ScreenShot
view release on metacpan or search on metacpan
lib/Sorauta/Capture/ScreenShot.pm view on Meta::CPAN
return 1;
}
#==========================================
# èúob`Às
# req:
# res:
# result: ¬÷1A»êÈO0
#==========================================
sub execute_by_interval {
my $self = shift;
# Lv`æÌpXÌfBNgªAEgÈê
my($filename, $dir, $ext) = fileparse( $self->capture_file_path);
unless (-d $dir) {
die "was not exists directory of output capture file path";
}
# Lv`Às
if ($self->os =~ /^Win/i) {
# not implement now...
}
else {
my $cmd = 'screencapture -x '.$self->capture_file_path;
`$cmd`;
}
# send capture data to server
if (length($self->api_url)) {
my $ua = new LWP::UserAgent;
my $req = POST(
$self->api_url,
Content_Type => 'form-data',
Content => [
%{$self->api_attr},
]
);
my $res = $ua->request($req);
if ($res->is_success) {
print "[Sorauta::Capture::ScreenShot]send capture file ... success.", $/;
}
else {
print "[Sorauta::Capture::ScreenShot]send capture file ... failed: ", $res->status_line, $/;
return 0;
}
}
return 1;
}
1;
__END__
# Below is stub documentation for your module. You'd better edit it!
=head1 NAME
Sorauta::Capture::ScreenShot - capture your desktop and send data to server
=head1 SYNOPSIS
use Sorauta::Capture::ScreenShot;
my $OS = "Mac"; # or Win(but not implement now)
my $CAPTURE_FILE_PATH = "/Users/yuki/Desktop/capture.jpg";
my $INTERVAL_TIME = 0; # if you want to interval, set this var over 0
my $DEBUG = 0;
my $API_URL = "http://api_url/path/to";
my $API_ATTRS = {
file_name => [$CAPTURE_FILE_PATH],
test => 'fugapiyo',
};
# capture test
{
Sorauta::Capture::ScreenShot->new({
os => $OS,
capture_file_path => $CAPTURE_FILE_PATH,
interval_time => $INTERVAL_TIME,
debug => $DEBUG,
})->execute;
}
# capture and send api test
{
Sorauta::Capture::ScreenShot->new({
os => $OS,
capture_file_path => $CAPTURE_FILE_PATH,
interval_time => $INTERVAL_TIME,
debug => $DEBUG,
api_url => $API_URL,
api_attr => $API_ATTRS,
})->execute;
}
=head1 DESCRIPTION
capture your desktop and send data to server.
=head2 EXPORT
None by default.
=head1 SEE ALSO
Mention other useful documentation such as the documentation of
related modules or operating system documentation (such as man pages
in UNIX), or any relevant external documentation such as RFCs or
standards.
If you have a mailing list set up for your module, mention it here.
If you have a web site set up for your module, mention it here.
=head1 AUTHOR
Yuki ANAI, E<lt>yuki@apple.comE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2012 by Yuki ANAI
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.12.3 or,
at your option, any later version of Perl 5 you may have available.
=cut
( run in 1.665 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )