upsies.utils.webdbs.base
Abstract base class for online databases
Classes
- class upsies.utils.webdbs.base.WebDbApiBase(config=None)[source]
Bases:
ABCBase class for all web DB APIs
Not all DBs provide all information. Methods that take an id argument may return an empty string, an empty tuple or None.
- abstract property name
Unique name of this DB
- abstract property label
User-facing name of this DB
- property no_results_info
Hints for the user to find something
This should be displayed if there are no search results.
- property config
User configuration
This is a deep copy of
default_configthat is updated with the config argument from initialization.
- abstract property default_config
Default user configuration as a dictionary
- sanitize_query(query)[source]
Modify
Queryfor specific DBIf
get_id_from_text()finds an ID inQuery.title,Query.idis set to that ID, which means all other query parameters are ignored.
- abstractmethod async search(query)[source]
Search DB
- Parameters:
query –
Queryinstance- Returns:
List of
SearchResultinstances
- abstractmethod async creators(id)[source]
Return list of creator names (usually empty for movies and episodes)
- abstractmethod async directors(id)[source]
Return list of director names (usually empty for series)
- abstractmethod async poster_url(id, season=None)[source]
Return URL of poster image or empty string
- Parameters:
season –
Return poster for specific season
If this is not supported by the concrete implementation, default to the URL for the main poster.
- async poster(id, season=None)[source]
Return poster image as binary data or None
- Parameters:
season –
Return poster for specific season
If this is not supported by the concrete implementation, default to the main poster.
- async runtimes(id)[source]
Return mapping of runtimes
Keys are descriptive strings (e.g. “Director’s Cut”, “Ultimate Cut”, etc) and values are the runtime in minutes (:class:int).
The key of the default cut is
default.
- async title_original(id)[source]
Return original title
See also
title_english().
- async title_english(id, *, default_to_original=False)[source]
Return English title (AKA) or empty string
If the English title is too similar to the original title, return an empty string.
Titles are considered too similar if they are equal or either one contains the other after normalization.
Titles are normalized by casefolding, removing whitespace, translating roman numerals to arabic, etc.
For example, if the original title is “Föö & Bár II” and the English title is “The Foo and Bar 2”, the titles are too similar.
- Parameters:
default_to_original – Instead of defaulting to an empty string if no appropriate English title is found, default to the original title
- abstractmethod async type(id)[source]
Return
ReleaseType