Providers

class subliminal.providers.Provider(**kwargs)

Base class for providers

If any configuration is possible for the provider, like credentials, it must take place during instantiation

Parameters:**kwargs – configuration
Raise:ProviderConfigurationError if there is a configuration error
languages = set([])

Supported BabelFish languages

video_types = (<class 'subliminal.video.Episode'>, <class 'subliminal.video.Movie'>)

Supported video types

required_hash = None

Required hash, if any

initialize()

Initialize the provider

Must be called when starting to work with the provider. This is the place for network initialization or login operations.

Raise:ProviderNotAvailable if the provider is unavailable
terminate()

Terminate the provider

Must be called when done with the provider. This is the place for network shutdown or logout operations.

Raise:ProviderNotAvailable if the provider is unavailable
classmethod check(video)

Check if the video can be processed

The video is considered invalid if not an instance of video_types or if the required_hash is not present in Video‘s hashes attribute.

Parameters:video (Video) – the video to check
Returns:True if the video and languages are valid, False otherwise
Return type:bool
query(languages, *args, **kwargs)

Query the provider for subtitles

This method arguments match as much as possible the actual parameters for querying the provider

Parameters:
  • languages (set of babelfish.Language) – languages to search for
  • *args – other required arguments
  • **kwargs – other optional arguments
Returns:

the subtitles

Return type:

list of Subtitle

Raise:

ProviderNotAvailable if the provider is unavailable

Raise:

ProviderError if something unexpected occured

list_subtitles(video, languages)

List subtitles for the video with the given languages

This is a proxy for the query() method. The parameters passed to the query() method may vary depending on the amount of information available in the video

Parameters:
  • video (Video) – video to list subtitles for
  • languages (set of babelfish.Language) – languages to search for
Returns:

the subtitles

Return type:

list of Subtitle

Raise:

ProviderNotAvailable if the provider is unavailable

Raise:

ProviderError if something unexpected occured

download_subtitle(subtitle)

Download the subtitle

Parameters:subtitle (Subtitle) – subtitle to download
Returns:the subtitle text
Return type:string
Raise:ProviderNotAvailable if the provider is unavailable
Raise:InvalidSubtitle if the downloaded subtitle is invalid
Raise:ProviderError if something unexpected occured