Skip to content

Commit

Permalink
Fix save SRT to not include cue tags #56
Browse files Browse the repository at this point in the history
  • Loading branch information
glut23 committed May 17, 2024
1 parent 14e1ab8 commit 1ee4049
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
History
=======

0.5.1 [Unreleased]
------------------

* Fixed save SRT to not include cue tags

0.5.0 (15-05-2024)
------------------

Expand Down
24 changes: 24 additions & 0 deletions tests/test_webvtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion webvtt/srt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

0 comments on commit 1ee4049

Please sign in to comment.