How to use the pysubs2.make_time function in pysubs2

To help you get started, we’ve selected a few pysubs2 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 tkarabela / pysubs2 / tests / test_ssaevent.py View on Github external
def test_repr_comment():
    ev = SSAEvent(start=make_time(m=1, s=30), end=make_time(m=1, s=35), text="Hello\\Nworld!")
    ev.is_comment = True
    ref = ""
    assert repr(ev) == ref
github tkarabela / pysubs2 / tests / test_substation.py View on Github external
def build_ref():
    subs = SSAFile()
    subs.info["My Custom Info"] = "Some: Test, String."
    subs.styles["left"] = SSAStyle(alignment=7, bold=True)
    subs.styles["topleft"] = SSAStyle(alignment=4)
    subs.append(SSAEvent(start=0, end=make_time(m=1), text="An, example, subtitle."))
    subs.append(SSAEvent(start=0, end=make_time(m=1), type="Comment", text="You can't see this one."))
    subs.append(SSAEvent(start=make_time(m=1), end=make_time(m=2), text="Subtitle number\\Ntwo."))
    return subs
github tkarabela / pysubs2 / tests / test_subrip.py View on Github external
def test_read_position_styling():
    """position is ignored, italic is converted, color is ignored"""

    text = dedent("""\
    1
    00:00:10,500 --> 00:00:13,000  X1:63 X2:223 Y1:43 Y2:58
    <i>Elephant's Dream</i>

    2
    00:00:15,000 --&gt; 00:00:18,000  X1:53 X2:303 Y1:438 Y2:453
    <font color="cyan">At the left we can see...</font>
    """)

    ref = SSAFile()
    ref.append(SSAEvent(start=make_time(s=10.5), end=make_time(s=13), text="{\\i1}Elephant's Dream{\\i0}"))
    ref.append(SSAEvent(start=make_time(s=15), end=make_time(s=18), text="At the left we can see..."))

    subs = SSAFile.from_string(text)
    assert subs.equals(ref)
github tkarabela / pysubs2 / tests / test_ssaevent.py View on Github external
def test_repr_dialogue():
    ev = SSAEvent(start=make_time(m=1, s=30), end=make_time(m=1, s=35), text="Hello\\Nworld!")
    ref = ""
    assert repr(ev) == ref
github tkarabela / pysubs2 / tests / test_substation.py View on Github external
def build_ref():
    subs = SSAFile()
    subs.info["My Custom Info"] = "Some: Test, String."
    subs.styles["left"] = SSAStyle(alignment=7, bold=True)
    subs.styles["topleft"] = SSAStyle(alignment=4)
    subs.append(SSAEvent(start=0, end=make_time(m=1), text="An, example, subtitle."))
    subs.append(SSAEvent(start=0, end=make_time(m=1), type="Comment", text="You can't see this one."))
    subs.append(SSAEvent(start=make_time(m=1), end=make_time(m=2), text="Subtitle number\\Ntwo."))
    return subs
github tkarabela / pysubs2 / tests / test_subrip.py View on Github external
def test_read_bad_tags():
    """missing opening/closing tag, bad nesting, extra whitespace"""

    text = dedent("""\
    1
    00:00:10,500 --&gt; 00:00:13,000
    &lt; u&gt;<i><font color="red">Elephant's &lt; s&gt;Dream&lt; /  i &gt; Is Long And Badly Nested

    """)

    ref = SSAFile()
    ref.append(SSAEvent(start=make_time(s=10.5), end=make_time(s=13), text="{\\u1}{\\i1}Elephant's {\\s1}Dream{\\i0} Is Long{\\s0} And Badly Nested"))

    subs = SSAFile.from_string(text)
    assert subs.equals(ref)
</font></i>
github tkarabela / pysubs2 / tests / test_subrip.py View on Github external
def test_read_malformed():
    """no line number, no empty line, leading whitespace, bad timestamp format"""

    text = dedent("""\
    00:00:00.000 ->00:01:00.000
    An example subtitle.
         0:01:00,00 --> 0:02:00,00
         Subtitle number
    two.
    """)

    ref = SSAFile()
    ref.append(SSAEvent(start=0, end=make_time(m=1), text="An example subtitle."))
    ref.append(SSAEvent(start=make_time(m=1), end=make_time(m=2), text="Subtitle number\\Ntwo."))

    subs = SSAFile.from_string(text)
    assert subs.equals(ref)