The Advogato XMLRPC API

Since I still had a bunch of old Advogato entries I'd like to archive, post-process (to get rid of their weird HTML injection mishaps) and upload to my blogger account I drew up a quick pike script to mirror mine, or for that matter, any other Advogato blog. It was easy enough - good work on the API, guys! A kindly meant suggestion to you, by the way -- you may find that introducing a commenting system would lose you fewer writers to competing sites. In my case, that was what finally got me to switch over to Blogger. It's just not worth posting quality tech stuff, unless the reader base can easily talk back and thus further elevate the quality of a post.

Anyway, in case anyone else would want to mirror a log or a few as well, here it is:

#! /usr/bin/env pike

constant address = "http://www.advogato.org/XMLRPC";

int main( int argc, array(string) argv )
Protocols.XMLRPC.Client client = Protocols.XMLRPC.Client( address );
for( int i=1; i<argc; i++ )
mirror( argv[i], client );

int mirror( string user, Protocols.XMLRPC.Client client )
Calendar.TimeRange ctime, mtime;
int entries, i;
string html, filename;
[entries] = client["diary.len"]( user );
for( i=0; i<entries; i++ )
[[ctime, mtime]] = client["diary.getDates"]( user, i );
[html] = client["diary.get"]( user, i);
string filename = user + "." + i + ".txt";
Stdio.write_file( filename, html + "\n" + ctime->format_time() );
System.utime( filename, ctime->unix_time(), mtime->unix_time() );
return entries;
blog comments powered by Disqus