I often have to convert HTML documents to the Kindle format, so I wrote a simple Python script to automate generation of the opf and ncx files. I post it here as it might be of use to others.
http://pastebin.com/i4Ug9uys
Any comments or requests are of course welcome.