radiaSRT/gen_html.py
2011-09-03 19:58:41 +05:30

27 lines
677 B
Python

from ox.text import findRe
def do():
f = open("ChronoArr_Srt.txt")
txt = f.read()
tapes = txt.split("***")
indexHtml = ''
counter = 1
for t in tapes:
fullTxt = t.strip()
titleReg = r'Title: (.*?)\n'
outfile = "tapes/%d.html" % (counter,)
title = findRe(fullTxt, titleReg)
print title
indexHtml += "<a target='_blank' href='%s'>%s</a><br />\n" % (outfile, title,)
out = open(outfile, "w")
out.write("<pre>%s</pre>" % (fullTxt,))
out.close()
counter += 1
indexFile = open("index.html", "w")
indexFile.write(indexHtml)
indexFile.close()
f.close()