radiaSRT/gen_html.py

29 lines
777 B
Python
Raw Normal View History

2011-09-03 14:28:41 +00:00
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'
2011-09-03 14:35:29 +00:00
timeReg = r'Time: (.*?)\n'
2011-09-03 14:37:27 +00:00
time = findRe(fullTxt, timeReg)
2011-09-03 14:28:41 +00:00
outfile = "tapes/%d.html" % (counter,)
title = findRe(fullTxt, titleReg)
print title
2011-09-03 14:35:29 +00:00
indexHtml += "<a target='_blank' href='%s'>%s</a><br />Time: %s<br/><br />\n" % (outfile, title, time,)
2011-09-03 14:28:41 +00:00
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()