Skip to content
This repository

A Python library for subtitle files

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 examples
Octocat-spinner-32 ext
Octocat-spinner-32 pysubs
Octocat-spinner-32 testsuite
Octocat-spinner-32 .gitignore
Octocat-spinner-32 CHANGELOG
Octocat-spinner-32 MANIFEST.in
Octocat-spinner-32 README.md
Octocat-spinner-32 pysubs-cli.py
Octocat-spinner-32 setup.py
Octocat-spinner-32 test.py
README.md

PySubs is a subtitle framework for Python 3. It features native SubStation Alpha (ASS, SSA files) support and a CLI tool for batch subtitle manipulation like retiming or conversion.

For more information, head over to the Wiki. (Část dokumentace je k dispozici v češtině. / Parts of the documentation are also available in Czech.)

Installation

Python 3.x is required -- PySubs will not run on Python 2.x. If you don't have Python 3.x on your system, install it before installing PySubs. Windows and Mac installers are available from http://python.org/download/; on Linux, please see your distribution's repositories.

PySubs is available on PyPI: http://pypi.python.org/pypi/pysubs/. On Windows, you may use the MS installer. On other platforms, install from source -- download the archive, extract it, go to the pysubs-X.X.X directory and execute

python setup.py install

from your terminal. To run the test suite (optional), execute

python -m unittest discover -s testsuite

Under the hood

PySubs framework

>>> import pysubs
>>> subs = pysubs.load("subtitles.ass", encoding="utf-8")
>>> subs.styles["Default"].fontname = "Calibri"
>>> for line in subs:
...     line.text = "{\be1}" + line.text
>>> subs.save("subtitles_fancy.ass")

CLI tool

pysubs-cli.py --output-dir retimed --shift 1.3s *.srt

License

# ------------------------------------------------------------------------------
# Copyright (c) 2011 Tigr <tigr42@centrum.cz>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Something went wrong with that request. Please try again.