upsies.utils.mediainfo.text

Subtitles information

Functions

upsies.utils.mediainfo.text.get_subtitles(content_path)[source]

Return sequence of Subtitle objects from all subtitle sources

This function combines all get_subtitles_* functions.

If content_path is a multi-disc release (i.e. a directory that contains multiple directories that each contain a VIDEO_TS or BDMV subdirectory), it returns the combined subtitles of all discs.

Parameters:

content_path – Path to release file or directory

upsies.utils.mediainfo.text.get_subtitles_from_bluray(content_path)[source]

Return sequence of Subtitle objects from BDMV subdirectory

If content_path is not a directory or does not contain a BDMV subdirectory, the returned sequence is empty.

Parameters:

content_path – Path directory that contains BDMV subdirectory

upsies.utils.mediainfo.text.get_subtitles_from_dvd(content_path)[source]

Return sequence of Subtitle objects from VIDEO_TS subdirectory

If content_path is not a directory or does not contain a VIDEO_TS subdirectory, the returned sequence is empty.

Parameters:

content_path – Path directory that contains VIDEO_TS subdirectory

upsies.utils.mediainfo.text.get_subtitles_from_idx_files(content_path)[source]

Return sequence of Subtitle objects from *.idx files

For .idx/.sub pairs, the .idx file can contain the language.

If content_path is a directory, it is searched recursively for *.idx files.

If content_path is not a directory, the returned sequence is empty.

Parameters:

content_path – Path to release file or directory

upsies.utils.mediainfo.text.get_subtitles_from_mediainfo(content_path)[source]

Return sequence of Subtitle objects from mediainfo output

Only the first video is used to find subtitles (see find_videos()).

Parameters:

content_path – Path to release file or directory

upsies.utils.mediainfo.text.get_subtitles_from_text_files(content_path)[source]

Return sequence of Subtitle objects from subtitle file names

For a video file named “foo.mkv”, the subtitle language can be in the file name, e.g. “foo.en.srt” or “foo.eng.ass”.

If content_path is a directory, it is searched recursively for subtitle files.

If content_path is not a directory, the returned sequence is empty.

Parameters:

content_path – Path to release file or directory

Classes

class upsies.utils.mediainfo.text.Subtitle(*, language, forced=False, format='')[source]

Bases: object

Dataclass that stores information about a subtitle track

Parameters:

If language is not a valid BCP47 code, it is set to “?”.

classmethod from_string(string)[source]

Extract language code and forced flag from string

property language

Language part of the language initialization argument, e.g. “en”, “es”, “zh”, etc.

property region

Region part of the language initialization argument, e.g. “UK”, “419”, “HANS”, etc.

property forced

Whether the subtitle track should always be played

property format

Subtitle format (e.g. “SRT”, “VobSub”, “PGS”)