root/misc/blogping

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

update blogping to use YAML config file

  • 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 use XXX;
26 XXX $site;
27
28 for my $ping (@ping) {
29     warn "pinging $ping\n";
30     my $result = XMLRPC::Lite->proxy($ping)->call("weblogUpdates.ping", $site->{name}, $site->{url})->result;
31     warn YAML::Dump $result;
32 }
33
34 END {
35     YAML::DumpFile($conf, $config) if $changed;
36 }
37
38 sub setup_default {
39     warn "Setting up the default site.\n";
40     $config->{default} = my $name = prompt("Short name:");
41     setup_site($name);
42 }
43
44 sub setup_site {
45     my $name = shift;
46     warn "Setting up config for site '$name'\n";
47     my $site;
48     $site->{name} = prompt("Blog name:");
49     $site->{url}  = prompt("Blog url:");
50     $changed++;
51     return $config->{$name} = $site;
52 }
Note: See TracBrowser for help on using the browser.