def test_start_seconds(start_seconds):
    parser_zero = GenericSubtitleParser(start_seconds=0)
    parser_zero.fit(BytesIO(fake_srt))
    parser = GenericSubtitleParser(start_seconds=start_seconds)
    parser.fit(BytesIO(fake_srt))
    expected = [sub for sub in parser_zero.subs_ if sub.start >= timedelta(seconds=start_seconds)]
    assert all(esub == psub for esub, psub in zip(expected, parser.subs_))
def test_max_seconds(max_seconds):
    parser = GenericSubtitleParser(max_subtitle_seconds=max_seconds)
    parser.fit(BytesIO(fake_srt))
    assert max(sub.end - sub.start for sub in parser.subs_) <= timedelta(seconds=max_seconds)
Exemple #3
0
def detected_encoding(fname):
    parser = GenericSubtitleParser()
    parser.fit(fname)
    return parser.detected_encoding_
def detected_encoding(fname):
    parser = GenericSubtitleParser(skip_ssa_info=True)
    parser.fit(fname)
    return parser.detected_encoding_