Skip to main content

A minimalistic (100LOC) library to read SRT files into a workable format.

Project description

Module parsrt

A minimalistic (100LOC) library to read SRT files into a workable format.

Simply provides a way to convert SRT strings into Sub objects (via the parse functions) and vice versa (via the Sub class' str function). By avoiding regex it gets speeds around 50% faster than the fastest python SRT/Subtitle library I could find (cdown/srt). Install via: pip install parsrt

Functions

parse_file(path, encoding='ascii') : Reads a file and converts the contents into an Sub object array.

Args:
    path: The path the SRT file is located at.
    encoding: The encodding of the file (same as with open()).

Returns:
    An Sub object array.

parse_str(srt) : Converts a string into an Sub object array.

Args:
    srt: A valid SRT string.

Returns:
    An Sub object array.

Raises:
    ValueError: Invalid SRT string.

Classes

Sub(index, time, text) : Subtitle info object.

Attributes:
    index: An SRT index value.
    time: A tuple containing the start and end timestamps as timedelta objects.
    text: A string value containing the subtitle's text.

Project details


Release history Release notifications | RSS feed

This version

1.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

parsrt-1.2.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

parsrt-1.2-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file parsrt-1.2.tar.gz.

File metadata

  • Download URL: parsrt-1.2.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0

File hashes

Hashes for parsrt-1.2.tar.gz
Algorithm Hash digest
SHA256 01b111211d96d4e5e6852343a5b7a9837fddd5b5726cc5b8b5b749acbb1e5f8e
MD5 6f80d0ed98de2ae28e92c878f94d6aee
BLAKE2b-256 1adac0120170ae62d0303827d649145dbcf0e674340b4518daadb2f3c76873a7

See more details on using hashes here.

File details

Details for the file parsrt-1.2-py3-none-any.whl.

File metadata

  • Download URL: parsrt-1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0

File hashes

Hashes for parsrt-1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1589d04a544fdc46f9fffad3923e47c619cfb0418e493927ad1e4888580fa3a7
MD5 3fbdb9f907b674b4bcdd45fd56e5f550
BLAKE2b-256 e14f5795443c2e9e45ba27d71975ebc63c7c545ce5f920442b9bd5ee5afaf59e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page