■
■ はてなダイアリーライター画像投稿対応版
YYYY-MM-DD.(jpg|gif|png)があったら、それを投稿するバージョン。なんてどうですか>id:hyukiさん。
hatena_diary_writer.pl.org Tue Aug 24 17:36:23 2004
- hatena_diary_writer.pl Tue Aug 24 18:00:57 2004
**************
24,34 ****
# Prototypes.
sub login();
sub logout();
! sub update_diary_entry($$$$$);
sub delete_diary_entry($);
sub create_it($$$);
sub delete_it($);
! sub post_it($$$$$);
sub get_timestamp();
sub print_debug(@);
sub print_message(@);
- 24,34 ----
# Prototypes.
sub login();
sub logout();
! sub update_diary_entry($$$$$$);
sub delete_diary_entry($);
sub create_it($$$);
sub delete_it($);
! sub post_it($$$$$$);
sub get_timestamp();
sub print_debug(@);
sub print_message(@);**************
152,157 ****
- 152,168 ----
# Read title and body.
my ($title, $body) = read_title_body($_);
- # Check image exist.
- my @imgexts = ('jpg', 'png', 'gif');
- my $imgfile = '';
- foreach my $ext(@imgexts) {
- my $tmpname = $year.'-'.$month.'-'.$day.'.'.$ext;
- if (-e $tmpname) {
- $imgfile = $tmpname;
- last;
- }
- }
if ($title eq $delete_title) {
# Delete entry.
print_message("Delete $year-$month-$day.");**************
160,166 ****
} else {
# Update entry.
print_message("Post $year-$month-$day : $title");
! update_diary_entry($year, $month, $day, $title, $body);
print_message("Post OK.");
}
- 171,177 ----
} else {
# Update entry.
print_message("Post $year-$month-$day : $title");
! update_diary_entry($year, $month, $day, $title, $body, $imgfile);
print_message("Post OK.");
}
**************
274,281 ****
}
# Update entry.
! sub update_diary_entry($$$$$) {
! my ($year, $month, $day, $title, $body) = @_;
my $create_retry = 0;
my $post_retry = 0;
my $ok = 0;
- 285,292 ----
}
# Update entry.
! sub update_diary_entry($$$$$$) {
! my ($year, $month, $day, $title, $body, $imgfile) = @_;
my $create_retry = 0;
my $post_retry = 0;
my $ok = 0;**************
301,307 ****
POST_RETRY:
while ($post_retry < 2) {
# Post.
! $ok = post_it($year, $month, $day, $title, $body);
if ($ok or not $cmd_opt{c}) {
last;
}
- 312,318 ----
POST_RETRY:
while ($post_retry < 2) {
# Post.
! $ok = post_it($year, $month, $day, $title, $body, $imgfile);
if ($ok or not $cmd_opt{c}) {
last;
}**************
425,432 ****
}
}
! sub post_it($$$$$) {
! my ($year, $month, $day, $title, $body) = @_;
print_debug("post_it: $year-$month-$day.");
- 436,443 ----
}
}
! sub post_it($$$$$$) {
! my ($year, $month, $day, $title, $body, $imgfile) = @_;
print_debug("post_it: $year-$month-$day.");
**************
448,453 ****
- 459,467 ----
# This entry must already exist.
body => $body,
date => "$year$month$day",
- image => [
- $imgfile,
- ]
]
)
);