Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 3, 2023. It is now read-only.

fifthleaf/sublib

Repository files navigation

Sublib

Python library for easier management and processing of subtitle files. Easily manage their content and conveniently use it in your own projects.

Features

  • Read files data
  • Convert subtitles formats
  • Process content separated into lines
  • Search for strings in data
  • Acquire specific lines
  • Detect used format

Installation

Download the latest version from PyPi

python -m pip install sublib

More

Testing

Perform the tests with pytest and pytest-mock

python -m pytest tests

More

Basic usage

First of all, import the package

import sublib

Each of the supported formats of subtitles is represent by its class

# Create a subtitle instance
subtitle = sublib.SubRip("subtitle.srt", "utf-8")

All subtitles classes have a few methods and attributes

# Get object content in a universal format
general = subtitle.get_general_format()

# Set a new object from this format
another_subtitle = sublib.MicroDVD()
another_subtitle.set_from_general_format(general)

# Print subtitle lines
print(another_subtitle.content)

More

Advanced usage

Please, take a look if you need more details

Contributing

Pull requests are welcome!

About

Python library for easier management and processing of subtitle files

Topics

Resources

Readme

License

GPL-3.0 license

Stars

Watchers

Forks

Packages

Contributors

Languages