-
-
Save Deflated-Criossant/6340bedb6524e8ec3791 to your computer and use it in GitHub Desktop.
Revisions
-
adammw created this gist
Apr 12, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ # Usage: python tt2srt.py source.xml output.srt from xml.dom.minidom import parse import sys i=1 dom = parse(sys.argv[1]) out = open(sys.argv[2], 'w') body = dom.getElementsByTagName("body")[0] paras = body.getElementsByTagName("p") for para in paras: out.write(str(i) + "\n") out.write(para.attributes['begin'].value.replace('.',',') + ' --> ' + para.attributes['end'].value.replace('.',',') + "\n") for child in para.childNodes: if child.nodeName == 'br': out.write("\n") elif child.nodeName == '#text': out.write(unicode(child.data).encode('utf=8')) out.write("\n\n") i += 1