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 therequired_hash
is not present inVideo
‘s hashes attribute.Parameters: video ( Video
) – the video to checkReturns: 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 unavailableRaise: ProviderError
if something unexpected occured- languages (set of
-
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 thequery()
method may vary depending on the amount of information available in the videoParameters: - 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 unavailableRaise: ProviderError
if something unexpected occured- video (
-
download_subtitle
(subtitle)¶ Download the subtitle
Parameters: subtitle ( Subtitle
) – subtitle to downloadReturns: the subtitle text Return type: string Raise: ProviderNotAvailable
if the provider is unavailableRaise: InvalidSubtitle
if the downloaded subtitle is invalidRaise: ProviderError
if something unexpected occured
-