Created
October 9, 2021 10:23
-
-
Save geekman/6e6380aa76ee6de7f58c908845265c55 to your computer and use it in GitHub Desktop.
strip out SRT metadata, leaving only subtitle text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# strip out SRT timing information, leaving only the text | |
# separated by a single line | |
# | |
# 2021.10.09 darell tan | |
# | |
import sys | |
with open(sys.argv[1], 'r') as f: | |
collected = [] | |
for l in f: | |
l = l.strip() | |
if l == '': | |
if collected: print # seperator | |
del collected[:] | |
continue | |
if len(collected) >= 2: | |
print l | |
else: | |
# collect number & timespan here | |
collected.append(l) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment