root/misc/blogping

Revision 2975 (checked in by miyagawa, 7 years ago)

add

  • Property svn:executable set to *
Line 
1 #!/usr/bin/env 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.reader.livedoor.com/ping',
14     'http://blogsearch.google.com/ping/RPC2',
15     'http://feedpress.it/ping',
16 #    'http://ping.superfeedr.com/rpc',
17 );
18
19 our $changed;
20 our $config = eval { YAML::LoadFile($conf) || {} };
21 setup_default() unless $config->{default};
22
23 if (@ARGV and ($ARGV[0] eq '--list' || $ARGV[0] eq '-l')) {
24     my $default = $config->{default};
25     for my $name (keys %$config) {
26         next if $name eq 'default';
27         my $site = $config->{$name};
28         $name .= '*' if $name eq $default;
29         print $name, " " x (16-length($name)), "$site->{name} ($site->{url})\n";
30     }
31     exit;
32 }
33
34 my $name = $ARGV[0] || $config->{default};
35 my $site = $config->{$name} || setup_site($name);
36
37 for my $ping (@ping) {
38     warn "pinging $ping\n";
39     my $result = XMLRPC::Lite->proxy($ping)->call("weblogUpdates.ping", $site->{name}, $site->{url})->result;
40     warn YAML::Dump $result;
41 }
42
43 END {
44     YAML::DumpFile($conf, $config) if $changed;
45 }
46
47 sub setup_default {
48     warn "Setting up the default site.\n";
49     $config->{default} = my $name = prompt("Short name:");
50     setup_site($name);
51 }
52
53 sub setup_site {
54     my $name = shift;
55     warn "Setting up config for site '$name'\n";
56     my $site;
57     $site->{name} = prompt("Blog name:");
58     $site->{url}  = prompt("Blog url:");
59     $changed++;
60     return $config->{$name} = $site;
61 }
Note: See TracBrowser for help on using the browser.