Skip to content

Instantly share code, notes, and snippets.

@hiiwave
Forked from mgaitan/srt2txt.py
Created August 8, 2018 02:52
Show Gist options
  • Save hiiwave/ddeacf3c78485c5fe742f4c67e08655b to your computer and use it in GitHub Desktop.
Save hiiwave/ddeacf3c78485c5fe742f4c67e08655b to your computer and use it in GitHub Desktop.
Convert subtitles to plain text
#!/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