media.subtitles#

Description#

Plugin to get video subtitles from OpenSubtitles.

Configuration#

media.subtitles:
  # [Required]
  # Your OpenSubtitles username
  username:

  # [Required]
  # Your OpenSubtitles password
  password:

  # [Optional]
  # Preferred language name, ISO639 code or OpenSubtitles
  # language ID to be used for the subtitles. Also supports an (ordered)
  # list of preferred languages
  # language:

Dependencies#

pip

pip install webvtt-py python-opensubtitles

Debian

apt install python3-webvtt

Actions#

Module reference#

class platypush.plugins.media.subtitles.MediaSubtitlesPlugin(username, password, language=None, **kwargs)[source]#

Bases: Plugin

Plugin to get video subtitles from OpenSubtitles.

__init__(username, password, language=None, **kwargs)[source]#
Parameters:
  • username (str) – Your OpenSubtitles username

  • password (str) – Your OpenSubtitles password

  • language (str or list[str]) – Preferred language name, ISO639 code or OpenSubtitles language ID to be used for the subtitles. Also supports an (ordered) list of preferred languages

download(link, media_resource=None, path=None, convert_to_vtt=False)[source]#

Downloads a subtitle link (.srt/.vtt file or gzip/zip OpenSubtitles archive link) to the specified directory

Parameters:
  • link (str) – Local subtitles file or OpenSubtitles gzip download link

  • path (str) – Path where the subtitle file will be downloaded (default: temporary file under /tmp)

  • media_resource (str) – Name of the media resource. If set and if it’s a media local file then the subtitles will be saved in the same folder

  • convert_to_vtt (bool) – If set to True, then the downloaded subtitles will be converted to VTT format (default: no conversion)

Returns:

dict.

Format:

{
    "filename": "/path/to/subtitle/file.srt"
}
get_subtitles(resource, language=None)[source]#

Get the subtitles data for a video resource

Parameters:
  • resource (str) – Media file, torrent or URL to the media resource

  • language (str) – Language name or code (default: configured preferred language). Choose ‘all’ for all the languages

search(resource, language=None)[source]#

Alias for get_subtitles().

Parameters:
  • resource (str) – Media file, torrent or URL to the media resource

  • language (str) – Language name or code (default: configured preferred language). Choose ‘all’ for all the languages

to_vtt(filename)[source]#

Get the VTT content given an SRT file. Will return the original content if the file is already in VTT format.