User:Angeliki/Feedback Composition

From XPUB & Lens-Based wiki
< User:Angeliki
Revision as of 20:59, 27 March 2019 by Angeliki (talk | contribs) (Created page with "== Convert transcriptions to linkable html == <syntaxhighlight lang="python" line='line'> import pysrt, argparse ap = argparse.ArgumentParser("srttojs") ap.add_ar...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Convert transcriptions to linkable html

    import pysrt, argparse

    ap = argparse.ArgumentParser("srttojs")
    ap.add_argument("srt")
    args = ap.parse_args()

    srt= pysrt.open(args.srt)
    print("<div class='sub'>")
    for t in srt:
        print ('<div><a data-start="{1}" href="#">{0}</a> {2}</div>'.format(t.start, t.start.ordinal/1000.0, t.text))
    print ("</div>")