Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix save SRT to not include cue tags #56 #65

Merged
merged 2 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, thanks to `@lilaboc <https://github.com/lilaboc>`_ (#56)

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())
Loading