You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
445 B
Python

import re, sys, csv
# From [itertools recipes](https://docs.python.org/3/library/itertools.html#itertools-recipes)
def grouper (iterable, n):
args = [iter(iterable)] * n
return zip(*args)
w = csv.writer(sys.stdout)
w.writerow(["url","start", "text"])
text = sys.stdin.read()
items = list(re.split(f"((https?://\S+?)#t=(\S+))", text))
for url, baseurl, timecode, text in grouper(items[1:], 4):
w.writerow((baseurl, timecode, text))