Python library for easier management and processing of subtitle files.
Project description
Sublib
Python library for easier management and processing of subtitle files.
Installation
Currently, sublib supports releases of Python 3.6 onwards. To install the current release:
pip install --upgrade sublib
Getting Started
You have a few function at your disposal.
detect(file_name, file_encoding)
from sublib import detect
# This will detect subrip format
file_format = detect("subtitle.srt", "utf-8")
from_mpl(opened_file), to_mpl(general_lines)
from sublib import from_mpl, to_mpl
# This will read MPlayer2 file and convert to general list
with open("subtitle.txt", "rt", encoding="utf-8") as file:
general_list = from_mpl(file)
# This will read lines from general list and convert to MPlayer2 format
formated_lines = to_mpl(general_list)
from_srt(opened_file), to_srt(general_lines)
from sublib import from_srt, to_srt
# This will read SubRip file and convert to general list
with open("subtitle.srt", "rt", encoding="utf-8") as file:
general_list = from_srt(file)
# This will read lines from general list and convert to SubRip format
formated_lines = to_srt(general_list)
from_sub(opened_file), to_sub(general_lines)
from sublib import from_sub, to_sub
# This will read MicroDVD file and convert to general list
with open("subtitle.sub", "rt", encoding="utf-8") as file:
general_list = from_sub(file)
# This will read lines from general list and convert to MicroDVD format
formated_lines = to_sub(general_list)
from_tmp(opened_file), to_tmp(general_lines)
from sublib import from_tmp, to_tmp
# This will read TMPlayer file and convert to general list
with open("subtitle.txt", "rt", encoding="utf-8") as file:
general_list = from_tmp(file)
# This will read lines from general list and convert to TMPlayer format
formated_lines = to_tmp(general_list)
Supported formats
- as srt - SubRip (.srt)
- as sub - MicroDVD (.sub)
- as mpl - MPlayer2 (.txt)
- as tmp - TMPlayer (.txt)
Contributing
Pull requests are welcome.
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sublib-1.0.0.tar.gz
(18.5 kB
view hashes)
Built Distribution
sublib-1.0.0-py3-none-any.whl
(17.7 kB
view hashes)