diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0c02a3e..330ebda 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,11 @@ History ======= +0.5.1 [Unreleased] +------------------ + +* Fixed save SRT to not include cue tags + 0.5.0 (15-05-2024) ------------------ diff --git a/tests/test_webvtt.py b/tests/test_webvtt.py index ccdc5d1..613887e 100644 --- a/tests/test_webvtt.py +++ b/tests/test_webvtt.py @@ -108,6 +108,30 @@ def test_write_captions_in_srt(self): ''').strip() ) + def test_write_captions_in_srt_no_cuetags(self): + """https://github.com/glut23/webvtt-py/issues/56""" + out = io.StringIO() + vtt = webvtt.read(PATH_TO_SAMPLES / 'cue_tags.vtt') + vtt.write(out, format='srt') + + out.seek(0) + self.assertEqual( + out.read(), + textwrap.dedent(''' + 1 + 00:00:16,500 --> 00:00:18,500 + When the moon hits your eye + + 2 + 00:00:18,500 --> 00:00:20,500 + Like a big-a pizza pie + + 3 + 00:00:20,500 --> 00:00:21,500 + That's amore + ''').strip() + ) + def test_write_captions_in_unsupported_format(self): self.assertRaises( ValueError, diff --git a/webvtt/srt.py b/webvtt/srt.py index 0e0637d..e2257ca 100644 --- a/webvtt/srt.py +++ b/webvtt/srt.py @@ -142,7 +142,7 @@ def write( '{} --> {}'.format(*map(lambda x: x.replace('.', ','), (caption.start, caption.end)) ), - *caption.lines, + *caption.text.splitlines(), '' ]) f.write('\n'.join(output).rstrip())