File: README.rst

package info (click to toggle)
python-webvtt 0.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 640 kB
  • sloc: python: 3,777; makefile: 29; sh: 6
file content (95 lines) | stat: -rw-r--r-- 2,407 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
webvtt-py
=========

|pypi| |pyversions| |license| |coverage| |build-status| |docs-status| |downloads|

``webvtt-py`` is a Python module for reading/writing WebVTT_ caption files. It also features caption segmentation useful when captioning `HLS videos`_.

Documentation is available at http://webvtt-py.readthedocs.io.

.. _`WebVTT`: http://dev.w3.org/html5/webvtt/
.. _`HLS videos`: https://tools.ietf.org/html/draft-pantos-http-live-streaming-19

Installation
------------

::

    $ pip install webvtt-py

Usage
-----

.. code-block:: python

  import webvtt

  for caption in webvtt.read('captions.vtt'):
      print(caption.start)
      print(caption.end)
      print(caption.text)

Segmenting for HLS
------------------

.. code-block:: python

  import webvtt

  webvtt.segment('captions.vtt', 'output/path')

Converting captions from other formats
--------------------------------------

Supported formats:

* SubRip (.srt)
* YouTube SBV (.sbv)

.. code-block:: python

  import webvtt

  webvtt = webvtt.from_srt('captions.srt')
  webvtt.save()

  # one liner if we just need to convert without editing
  webvtt.from_sbv('captions.sbv').save()

CLI
---
Caption segmentation is also available from the command line:

::

    $ webvtt segment captions.vtt --output output/path

License
-------

Licensed under the MIT License.

.. |pypi| image:: https://img.shields.io/pypi/v/webvtt-py.svg
    :target: https://pypi.python.org/pypi/webvtt-py

.. |pyversions| image:: https://img.shields.io/pypi/pyversions/webvtt-py.svg
    :alt: Supported Python versions
    :target: https://pypi.python.org/pypi/webvtt-py

.. |license| image:: https://img.shields.io/pypi/l/webvtt-py.svg
    :alt: MIT License
    :target: https://opensource.org/licenses/MIT

.. |coverage| image:: https://codecov.io/gh/glut23/webvtt-py/graph/badge.svg?branch=master
    :target: https://codecov.io/gh/glut23/webvtt-py

.. |build-status| image:: https://github.com/glut23/webvtt-py/actions/workflows/ci.yml/badge.svg?branch=master
    :target: https://github.com/glut23/webvtt-py/actions/workflows/ci.yml

.. |docs-status| image:: https://readthedocs.org/projects/webvtt-py/badge/?version=latest
    :target: http://webvtt-py.readthedocs.io/en/latest/?badge=latest
    :alt: Documentation Status

.. |downloads| image:: https://static.pepy.tech/badge/webvtt-py
    :target: https://pepy.tech/project/webvtt-py
    :alt: Downloads