aeidon

Source: aeidon/__init__.py

Reading, writing and manipulating text-based subtitle files.

aeidon is a Python package that provides classes and functions for dealing with text-based subtitle files of many different formats. Functions exist for reading and writing subtitle files as well as manipulating subtitle data, i.e. positions (times or frames) and texts. Two examples of basic use of the aeidon package follow below.

Converting a file from the SubRip format to the MicroDVD format:

project = aeidon.Project()
project.open_main("/path/to/file.srt", "utf_8")
project.set_framerate(aeidon.framerates.FPS_23_976)
project.save_main(aeidon.files.new(aeidon.formats.MICRODVD,
                                   "/path/to/file.sub",
                                   "utf_8"))

Making all subtitles in a file appear two seconds earlier:

project = aeidon.Project()
project.open_main("/path/to/file.srt", "utf_8")
project.shift_positions(None, aeidon.as_seconds(-2))
project.save_main()

aeidon handles positions as either times (as strings of form HH:MM:SS.SSS), frames (as integers) or in some cases seconds (as floats). All these can be used with functions that edit subtitle data regardless of what the native position type of the file format used is.

aeidon handles two separate documents that comprise a project – a main and a translation document. These correspond to separate files, but the subtitles are common since positions are shared.

aeidon includes an undo/redo-system. Any subtitle data-editing methods of aeidon.Project (ones marked with the aeidon.deco.revertable() decorator) can be undone and redone. If using aeidon in a context where reverting actions is never needed, greater flexibility can be achieved by accessing the subtitles directly (via aeidon.Project.subtitles).

aeidon.CONFIG_HOME_DIR

Path to the user’s local configuration directory

aeidon.DATA_DIR

Path to the global data directory

aeidon.DATA_HOME_DIR

Path to the user’s local data directory

aeidon.LOCALE_DIR

Path to the global locale directory

aeidon.RE_ANY_TAG

Regular expression for markup tags of any format

aeidon.RUNNING_SPHINX

True if generating API documentation with sphinx

aeidon.align_methods

Enumerations for subtitle align methods

aeidon.documents

Enumerations for document types

aeidon.formats

Enumerations for subtitle file format types

aeidon.framerates

Enumerations for framerate types

aeidon.modes

Enumerations for position unit types

aeidon.newlines

Enumerations for newline character types

aeidon.players

Enumerations for video player application types

aeidon.registers

Enumerations for action action reversion register types

Functions

aeidon.as_frame(pos)

Return pos as type frame.

aeidon.as_seconds(pos)

Return pos as type seconds.

aeidon.as_time(pos)

Return pos as type time.

aeidon.is_frame(pos)

Return True if pos is of type frame.

aeidon.is_seconds(pos)

Return True if pos is of type seconds.

aeidon.is_time(pos)

Return True if pos is of type time.