get audio, padma link from json

This commit is contained in:
Sanj 2011-09-05 17:28:38 +05:30
parent b3029fc341
commit f4fd89fba6
3 changed files with 1617 additions and 828 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,21 @@
from ox.text import findRe from ox.text import findRe
import json
import codecs
def do(): def do():
f = open("ChronoArr_Srt.txt") f = codecs.open("ChronoArr_Srt.txt", mode="r", encoding="utf-8")
data = json.loads(open("radia.json").read())
txt = f.read() txt = f.read()
tapes = txt.split("***") tapes = txt.split("***")
indexHtml = '' indexHtml = u''
counter = 1 counter = 0
for t in tapes: for t in tapes:
if counter >= len(data):
break
meta = data[counter]
padmaId = meta['hid']
audioFile = meta['name'] + u'.wav'
fullTxt = t.strip() fullTxt = t.strip()
titleReg = r'Title: (.*?)\n' titleReg = r'Title: (.*?)\n'
timeReg = r'Time: (.*?)\n' timeReg = r'Time: (.*?)\n'
@ -15,12 +23,16 @@ def do():
outfile = "tapes/%d.html" % (counter,) outfile = "tapes/%d.html" % (counter,)
title = findRe(fullTxt, titleReg) title = findRe(fullTxt, titleReg)
print title print title
indexHtml += "<a target='_blank' href='%s'>%s</a><br />Time: %s<br/><br />\n" % (outfile, title, time,) indexHtml += "<a target='_blank' href='%s'>%s</a><br />Time: %s<br/>\n" % (outfile, title, time,)
out = open(outfile, "w") indexHtml += "<a target='_blank' href='http://pad.ma/%s'>View on Padma</a><br />\n" % (padmaId,)
out.write("<pre>%s</pre>" % (fullTxt,)) audioHtml = "<audio controls='controls' src='wav/%s'></audio><br /><br />\n\n" % (audioFile,)
print audioHtml
indexHtml += audioHtml
out = codecs.open(outfile, mode="w", encoding="utf-8")
out.write("<audio controls='controls' src='wav/%s'><br /><br /><pre>%s</pre>" % (audioFile, fullTxt,))
out.close() out.close()
counter += 1 counter += 1
indexFile = open("index.html", "w") indexFile = codecs.open("index.html", mode="w", encoding="utf-8")
indexFile.write(indexHtml) indexFile.write(indexHtml)
indexFile.close() indexFile.close()
f.close() f.close()

1034
radia.json Normal file

File diff suppressed because it is too large Load Diff