diff options
| author | yuzu-eva <cafebabe@disroot.org> | 2025-05-08 14:01:37 +0200 |
|---|---|---|
| committer | yuzu-eva <cafebabe@disroot.org> | 2025-05-08 14:01:37 +0200 |
| commit | ef7c1605a027b52bbff1b01ea693b60f53fa3a71 (patch) | |
| tree | 1089334258aefbd459d18cf6968e78f1194739b0 /add-chapters | |
initial commit
Diffstat (limited to 'add-chapters')
| -rwxr-xr-x | add-chapters | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/add-chapters b/add-chapters new file mode 100755 index 0000000..3cac63d --- /dev/null +++ b/add-chapters @@ -0,0 +1,42 @@ +#!/usr/bin/env python3 + +import re + +chapters = list() + +with open('chapters.txt', 'r') as f: + for line in f: + x = re.match(r"(\d):(\d{2}):(\d{2}) (.*)", line) + hrs = int(x.group(1)) + mins = int(x.group(2)) + secs = int(x.group(3)) + title = x.group(4) + + minutes = (hrs * 60) + mins + seconds = secs + (minutes * 60) + timestamp = (seconds * 1000) + chap = { + "title": title, + "startTime": timestamp + } + chapters.append(chap) + +text = "" + +for i in range(len(chapters)-1): + chap = chapters[i] + title = chap['title'] + start = chap['startTime'] + end = chapters[i+1]['startTime']-1 + text += f""" +[CHAPTER] +TIMEBASE=1/1000 +START={start} +END={end} +title={title} +""" + + +with open("FFMETADATAFILE", "a") as myfile: + myfile.write(text) + |
