While reading assorted Perl themed blogs, I came across David Precious’s code for backing up Google calendar, contacts and reader subscriptions. Since I use all of these myself, partly to sync with my Android phone, I thought making local copies of them would be a good idea, particularly if I deleted some by mistake – easy to do when trialling a new tool or syncing something the wrong way.
Unfortunately, his tools worked for everything but Contacts – the bit I was most interested in. Further investigation showed that Google had changed the way they provided for you to export your contacts, and the old link no longer existed (but they had put up a page describing what and why). Fortunately, WWW::Contacts came to the rescue, with a working way to get at the data via the API. In retooling his script to use this, I ended up rewriting it to use my preferred command line/documentation parser, to give a consistent interface (as recommended in ‘Perl Best Practices‘, which I’ve been dipping into a lot at work), this lead to me splitting each backup into a separate function so you can choose to back up all three or just one.
The script is up at my Github page; feel free to fork, submit patches or just download and use!
On a related note, the work into this, partly to look at using App::Addex to manage my contacts data (which I’ve wanted to do since RBS blogged about it in his last year’s advent calendar), made me realise what a poor contacts system the Google Contacts is, especially for addresses – the API and the CSV export has fields for address lines 1 and 2, post code etc, but the interface, and the data, is all stored in the first address line, line breaks and all, making it painful to parse into a more useful format (such as the excel spreadsheet I used to bulk order my Christmas cards from Moonpig this year) – a project for another time perhaps, unless Google improve the way Contacts stores/manages the address data.