In my quest to bring my eventbrite events into blog entries I wrote some python that parses the XML generated by the eventbrite API and uploads it via PyMT, a python binding for the movable type XMLRPC API.
It works great, but now I am having a problem with HTML being displayed raw in the body of the posting. See:
http://htink.org/htink/blog/2010/08/htink-workshop-arduino-led-motors-and-sensors-1.html
How can I take the HTML from the eventbrite feed and place it directly into a movable type blog entry via xmlrpc?
Thanks for any help, this is almost completed :)
-Eric
Reported on Movable Type 5

What it's done is it's escaped your HTML. Every < replaced with < for example. You can write a second Python script to load the entries and unescape them or you can do it with Perl. This Perl script should do it (though I claim no warranty since I just hacked it together):
use strict; use lib ('./lib', './extlib'); use MT; use MT::Entry; MT->instance();my @entries = MT::Entry->load();
foreach (@entries) {
my $text = $_->text();
$text =~ s/</</;
$text =~ s/>/>/;
$_->text($text);
$_->save();
}
Here is some python code to parse XML spat out by eventbrite and post an event to movable type, thanks for the help!
I had to modify the PyMT library by adding dateCreated to the appropriate class.
from xml.dom import minidom
from datetime import *
from PyMT import *
xmldoc = minidom.parse('eventbrite.rss')
events = xmldoc.firstChild
mt = PyMT("http://mt-install/mt/mt-xmlrpc.cgi", "user", "pass")
def postevent(eventNum):
myNum = (eventNum * 2) + 1
title = events.childNodes[myNum].getElementsByTagName('title')[0].firstChild.toxml("utf-8")
converted = datetime.strptime(events.childNodes[myNum].getElementsByTagName('start_date')[0].firstChild.toxml("utf-8"), "%Y-%m-%d %H:%M:%S")
description = events.childNodes[myNum].getElementsByTagName('description')[0].firstChild.toxml("utf-8")
description = description.replace("<", " description = description.replace(">", ">")
description = description.replace(""", "\"")
description = description.replace("&", "&")
url = events.childNodes[myNum].getElementsByTagName('url')[0].firstChild.toxml("utf-8")
mydesc = '\n\n'.join ([description, url])
mytime = converted.strftime("%Y-%m-%d %H:%M:%S")
mt.newPost(2, {'title':title, 'description':mydesc, 'categories':[4], 'dateCreated':mytime}, 1)
postevent(0)