Exemple #1
0
def srt_to_txt(srt_path, txt_path):
    """
    将srt字幕文件转换成纯文本txt文件
    去掉时间码、index等信息
    """
    txt_file = codecs.open(txt_path, 'w+', encoding='utf-8')
    srt_file = codecs.open(srt_path, encoding='utf-8')

    for sub in pysrt.stream(srt_file):
        txt_file.write(sub.text + '\n')

    srt_file.close()
    txt_file.close()
Exemple #2
0
 def __attrs_post_init__(self):
     self.file = codecs.open(str(self.path), encoding=self.encoding)
     self.stream = pysrt.stream(self.file)
Exemple #3
0
 def test_blank_lines(self):
     items = list(
         pysrt.stream(['\n'] * 20, error_handling=SubRipFile.ERROR_RAISE))
     self.assertEqual(len(items), 0)
Exemple #4
0
 def test_blank_lines(self):
     items = list(pysrt.stream([u'\n'] * 20, error_handling=SubRipFile.ERROR_RAISE))
     self.assertEquals(len(items), 0)