root/misc/blogping

Revision 2060 (checked in by miyagawa, 13 years ago)

oops, removed debug bits

  • Property svn:executable set to *
Line 
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use ExtUtils::MakeMaker;
5 use XMLRPC::Lite;
6 use YAML;
7
8 my $conf = "$ENV{HOME}/.blogping";
9
10 my @ping = (
11     'http://ping.feedburner.com/',
12     'http://www.bloglines.com/ping',
13     'http://rpc.technorati.jp/rpc/ping',
14     'http://rpc.reader.livedoor.com/ping',
15     'http://blogsearch.google.com/ping/RPC2',
16 );
17
18 our $changed;
19 our $config = eval { YAML::LoadFile($conf) || {} };
20 setup_default() unless $config->{default};
21
22 my $name = $ARGV[0] || $config->{default};
23 my $site = $config->{$name} || setup_site($name);
24
25 for my $ping (@ping) {
26     warn "pinging $ping\n";
27     my $result = XMLRPC::Lite->proxy($ping)->call("weblogUpdates.ping", $site->{name}, $site->{url})->result;
28     warn YAML::Dump $result;
29 }
30
31 END {
32     YAML::DumpFile($conf, $config) if $changed;
33 }
34
35 sub setup_default {
36     warn "Setting up the default site.\n";
37     $config->{default} = my $name = prompt("Short name:");
38     setup_site($name);
39 }
40
41 sub setup_site {
42     my $name = shift;
43     warn "Setting up config for site '$name'\n";
44     my $site;
45     $site->{name} = prompt("Blog name:");
46     $site->{url}  = prompt("Blog url:");
47     $changed++;
48     return $config->{$name} = $site;
49 }
Note: See TracBrowser for help on using the browser.