Created
June 13, 2009 12:44
-
-
Save kga/129229 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# original code by id:antipop | |
# http://subtech.g.hatena.ne.jp/antipop/20071121/1195652375 | |
use strict; | |
use warnings; | |
use Config::Pit; | |
use File::Temp; | |
use IPC::Run qw/run/; | |
use WebService::Hatena::Fotolife; | |
my $config = pit_get('hatena.ne.jp', require => { | |
'username' => 'your hatena id', | |
'password' => 'your password on hatena', | |
}); | |
my $filename = File::Temp->new( UNLINK => 1, SUFFIX => '.png' ); | |
if (run(['screencapture', '-i', scalar $filename])) { | |
my $hatena = WebService::Hatena::Fotolife->new; | |
$hatena->username($config->{username}); | |
$hatena->password($config->{password}); | |
my ($date) = $hatena->createEntry( | |
title => $ARGV[0] || '', | |
filename => scalar $filename, | |
folder => $ARGV[1] || 'gyazo', | |
) =~ /(\d{14})$/; | |
my $url = sprintf "http://f.hatena.ne.jp/%s/%s", $config->{username}, $date; | |
run(['echo', $url], '|', [qw(pbcopy)]); | |
print "Successfully uploaded: $url\n"; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment