Skip to content

Instantly share code, notes, and snippets.

@kga
Created Jun 13, 2009
Embed
What would you like to do?
#!/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