#!/usr/bin/perl =head1 NAME radio2mt - turn Radio UserLand posts into Moveable Type posts =head1 SYNOPSIS radio2mt filename > outputfile =head1 DESCRIPTION This script takes a Radio UserLand database that has been output to XML (using the Radio macro available at http://www.tmtm.com/radioShowAll.txt) and outputs a file suitable for importing into Moveable Type. =head1 AUTHOR Tony Bowden =head1 LICENSE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut use strict; use warnings; use File::Slurp; use XML::LibXML; use Time::Piece; my $filename = shift or die "Usage: $0 \n"; my $parser = XML::LibXML->new(); my $text = read_file($filename); $text = $1 if $text =~ m#(.*)#gs; my $doc = $parser->parse_string($text); foreach my $post (reverse $doc->findnodes('//post')); my $id = $post->findvalue('@id'); my $title = $post->findvalue("./ptitle"); my $date = $post->findvalue("./date"); my $body = $post->findvalue("./text"); my $tp = Time::Piece->strptime($date, "%d/%m/%Y; %H:%M:%S"); my $link = $post->findvalue("./plink"); my @cats = map $_->findvalue("."), $post->findnodes(".//category"); my $pr_ct = shift @cats; print "TITLE: $title\n" if $title; printf "DATE: %s\n", $tp->strftime("%m/%d/%Y %H:%M:%S"); print "PRIMARY CATEGORY: $pr_ct\n" if $pr_ct; print "CATEGORY: $_\n" foreach @cats; print "STATUS: publish\n"; print "-----\nBODY:\n$body\n-----\n"; print "--------\n"; }