upsies.utils.webdbs.base

Abstract base class for online databases

Classes

class upsies.utils.webdbs.base.WebDbApiBase(config=None)[source]

Bases: ABC

Base 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_config that is updated with the config argument from initialization.

abstract property default_config

Default user configuration as a dictionary

sanitize_query(query)[source]

Modify Query for specific DB

If get_id_from_text() finds an ID in Query.title, Query.id is set to that ID, which means all other query parameters are ignored.

abstractmethod get_id_from_text(text)[source]

Return ID found in text or None

abstractmethod async search(query)[source]

Search DB

Parameters:

queryQuery instance

Returns:

List of SearchResult instances

abstractmethod async cast(id)[source]

Return list of cast names

async countries(id)[source]

Return list of country names

abstractmethod async languages(id)[source]

Return list of spoken languages

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 genres(id)[source]

Return list of genres

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.

abstractmethod async rating(id)[source]

Return rating as a number or None

abstract property rating_min

Minimum rating() value

abstract property rating_max

Maximum rating() value

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.

abstractmethod async summary(id)[source]

Return short plot description

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

abstractmethod async url(id)[source]

Return URL for id

abstractmethod async year(id)[source]

Return release year or empty string

async gather(id, *methods)[source]

Fetch information concurrently

Parameters:
  • id – Valid ID for this DB

  • methods (sequence of str) – Names of coroutine methods of this class

Returns:

Dictionary that maps methods to return values