from ox.text import findRe import json import codecs def do(): f = codecs.open("ChronoArr_Srt.txt", mode="r", encoding="utf-8") data = json.loads(open("radia.json").read()) txt = f.read() tapes = txt.split("***") indexHtml = u'' counter = 0 for t in tapes: if counter >= len(data): break meta = data[counter] padmaId = meta['hid'] audioFile = meta['name'] + u'.wav' fullTxt = t.strip() titleReg = r'Title: (.*?)\n' timeReg = r'Time: (.*?)\n' time = findRe(fullTxt, timeReg) outfile = "tapes/%d.html" % (counter,) title = findRe(fullTxt, titleReg) print title indexHtml += "%s
Time: %s
\n" % (outfile, title, time,) indexHtml += "View on Padma
\n" % (padmaId,) audioHtml = "

\n\n" % (audioFile,) print audioHtml indexHtml += audioHtml out = codecs.open(outfile, mode="w", encoding="utf-8") out.write("

%s
" % (audioFile, fullTxt,)) out.close() counter += 1 indexFile = codecs.open("index.html", mode="w", encoding="utf-8") indexFile.write(indexHtml) indexFile.close() f.close()