Skip to content

Instantly share code, notes, and snippets.

@hathibelagal-dev
Last active December 12, 2025 01:15
Show Gist options
  • Select an option

  • Save hathibelagal-dev/84cb46af07cdf70a95c0bfe9c4f88c6d to your computer and use it in GitHub Desktop.

Select an option

Save hathibelagal-dev/84cb46af07cdf70a95c0bfe9c4f88c6d to your computer and use it in GitHub Desktop.
Parses timedtext files
import json
import sys
if len(sys.argv) != 2:
print("ERROR: Provide input file")
try:
with open(sys.argv[1]) as f:
data = f.read()
except:
print("ERROR: Couldn't read file")
try:
data = json.loads(data)
data = data["events"]
for item in data:
if "segs" in item:
segs = item["segs"]
for seg in segs:
if "utf8" in seg:
print(seg["utf8"], end="")
except Exception as e:
print(e)
print("ERROR: Couldn't process file")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment