Subtitle

subliminal.subtitle.SUBTITLE_EXTENSIONS

Subtitle extensions

class subliminal.subtitle.Subtitle(language, hearing_impaired=False, page_link=None, encoding=None)[source]

Base class for subtitle.

Parameters
  • language (Language) – language of the subtitle.

  • hearing_impaired (bool) – whether or not the subtitle is hearing impaired.

  • page_link (str) – URL of the web page from which the subtitle can be downloaded.

  • encoding (str) – Text encoding of the subtitle.

provider_name = ''

Name of the provider that returns that class of subtitle

language = None

Language of the subtitle

hearing_impaired = None

Whether or not the subtitle is hearing impaired

URL of the web page from which the subtitle can be downloaded

content = None

Content as bytes

encoding = None

Encoding to decode with when accessing text

property id

Unique identifier of the subtitle

property text

Content as string

If encoding is None, the encoding is guessed with guess_encoding()

is_valid()[source]

Check if a text is a valid SubRip format.

Returns

whether or not the subtitle is valid.

Return type

bool

guess_encoding()[source]

Guess encoding using the language, falling back on chardet.

Returns

the guessed encoding.

Return type

str

get_matches(video)[source]

Get the matches against the video.

Parameters

video (Video) – the video to get the matches with.

Returns

matches of the subtitle.

Return type

set

subliminal.subtitle.get_subtitle_path(video_path, language=None, extension='.srt')[source]

Get the subtitle path using the video_path and language.

Parameters
  • video_path (str) – path to the video.

  • language (Language) – language of the subtitle to put in the path.

  • extension (str) – extension of the subtitle.

Returns

path of the subtitle.

Return type

str

subliminal.subtitle.guess_matches(video, guess, partial=False)[source]

Get matches between a video and a guess.

If a guess is partial, the absence information won’t be counted as a match.

Parameters
  • video (Video) – the video.

  • guess (dict) – the guess.

  • partial (bool) – whether or not the guess is partial.

Returns

matches between the video and the guess.

Return type

set

subliminal.subtitle.fix_line_ending(content)[source]

Fix line ending of content by changing it to .

param bytes content

content of the subtitle.

return

the content with fixed line endings.

rtype

bytes