How to use the pycaption.SRTReader function in pycaption

To help you get started, we’ve selected a few pycaption examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pbs / pycaption / tests / test_srt.py View on Github external
def test_extra_empty_line(self):
        captions = SRTReader().read(SAMPLE_SRT_BLANK_LINES)
        self.assertEqual(2, len(captions.get_captions("en-US")))
github pbs / pycaption / tests / test_srt.py View on Github external
def test_numeric_captions(self):
        captions = SRTReader().read(SAMPLE_SRT_NUMERIC)
        self.assertEqual(7, len(captions.get_captions("en-US")))
github pbs / pycaption / tests / test_scc_conversion.py View on Github external
def _test_srt_to_scc_to_srt_conversion(self, srt_captions):
        captions_1 = SRTReader().read(srt_captions)
        scc_results = SCCWriter().write(captions_1)
        scc_captions = SCCReader().read(scc_results)
        srt_results = SRTWriter().write(scc_captions)
        captions_2 = SRTReader().read(srt_results)
        self.assertCaptionSetAlmostEquals(captions_1, captions_2,
                                          TOLERANCE_MICROSECONDS)
github pbs / pycaption / tests / test_srt_conversion.py View on Github external
def test_srt_to_webvtt_conversion(self):
        caption_set = SRTReader().read(SAMPLE_SRT)
        results = WebVTTWriter().write(caption_set)
        self.assertTrue(isinstance(results, six.text_type))
        self.assertWebVTTEquals(SAMPLE_WEBVTT_FROM_SRT, results)
github pbs / pycaption / tests / test_ensure_valid_input.py View on Github external
def test_srt_reader_only_supports_unicode_input(self):
        with self.assertRaises(InvalidInputError):
            SRTReader().read(b'')
github pbs / pycaption / tests / test_scc_conversion.py View on Github external
def _test_srt_to_scc_to_srt_conversion(self, srt_captions):
        captions_1 = SRTReader().read(srt_captions)
        scc_results = SCCWriter().write(captions_1)
        scc_captions = SCCReader().read(scc_results)
        srt_results = SRTWriter().write(scc_captions)
        captions_2 = SRTReader().read(srt_results)
        self.assertCaptionSetAlmostEquals(captions_1, captions_2,
                                          TOLERANCE_MICROSECONDS)
github pbs / pycaption / tests / test_srt.py View on Github external
def test_proper_timestamps(self):
        captions = SRTReader().read(SAMPLE_SRT)
        paragraph = captions.get_captions("en-US")[2]

        self.assertEqual(17000000, paragraph.start)
        self.assertEqual(18752000, paragraph.end)
github pbs / pycaption / tests / test_srt_conversion.py View on Github external
def test_srt_to_srt_conversion(self):
        caption_set = SRTReader().read(SAMPLE_SRT)
        results = SRTWriter().write(caption_set)
        self.assertTrue(isinstance(results, six.text_type))
        self.assertSRTEquals(SAMPLE_SRT, results)
github pbs / pycaption / tests / test_srt.py View on Github external
def test_detection(self):
        self.assertTrue(SRTReader().detect(SAMPLE_SRT))
github pbs / pycaption / tests / test_srt_conversion.py View on Github external
def test_srt_to_dfxp_conversion(self):
        caption_set = SRTReader().read(SAMPLE_SRT)
        results = DFXPWriter().write(caption_set)
        self.assertTrue(isinstance(results, six.text_type))
        self.assertDFXPEquals(
            SAMPLE_DFXP, results,
            ignore_styling=True, ignore_spans=True
        )