Last active
April 23, 2020 18:27
-
-
Save mgaitan/31942c5fc77dad468313bed7d0ce5eb1 to your computer and use it in GitHub Desktop.
Convert subtitles to plain 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
#!/usr/bin/env python | |
import sys | |
import re | |
import textwrap | |
def str2txt(srt): | |
lines = re.sub(r'^$\n|^[0-9].*\n|^\n','', srt, flags=re.MULTILINE | re.UNICODE) | |
print(textwrap.fill(lines, 70)) | |
if __name__ == '__main__': | |
str2txt(open(sys.argv[0]).read()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment