upsies.utils.webdbs.common

Classes and functions that are used by all WebDbApiBase subclasses

Classes

class upsies.utils.webdbs.common.Person(name, *, url='', role='')[source]

Bases: str

str subclass with an url attribute

The optional role should only be used for actors and be the name of the character they portray.

class upsies.utils.webdbs.common.Query(title='', **kwargs)[source]

Bases: object

Search query for databases like IMDb

Parameters:
  • title (str) – Name of the movie or TV series

  • typeReleaseType enum or one of its value names

  • year (str or int) – Year of release

  • id (str) – Known ID for a specific DB

  • feeling_lucky (bool) –

    Whether a single search result should be autoselected

    This can be convenient if id is provided.

Raises:

ValueError – if an invalid argument is passed

property type

ReleaseType value

property title

Name of the movie or TV series

property title_normalized

Same as title but in stripped lower case with deduplicated spaces

property year

Year of release

property id

Known ID for a specific DB

property feeling_lucky

Whether an only search result should be autoselected

update(query, *, silent=False)[source]

Copy property values from other query

Parameters:
  • queryQuery instance to copy values from

  • silent (bool) – Whether to prevent any signal emissions

copy(**updates)[source]

Return new Query instance with updated attributes

Parameters:

updates – Updated attributes

classmethod from_string(query)[source]

Create instance from string

The returned Query is case-insensitive and has any superfluous whitespace removed.

Keyword arguments are extracted by looking for "year:YEAR", "type:TYPE" and "id:ID" in query where YEAR is a four-digit number, TYPE is something like “movie”, “film”, “tv”, etc and ID is a known ID for the DB this query is meant for.

classmethod from_release(info)[source]

Create instance from ReleaseInfo or ReleaseName instance

classmethod from_path(path)[source]

Create instance from file or directory name

path is passed to ReleaseInfo to get the arguments for instantiation.

classmethod from_any(obj)[source]

Try to guess correct from_… method

Raises:

TypeError – if obj is not supported

property signal

Signal instance

Available signals:

changed

Emitted after query parameters changed. Registered callbacks get the instance as a positional argument.

class upsies.utils.webdbs.common.SearchResult(*, id, type, url, year, cast=(), countries=(), directors='', genres=(), poster=None, summary='', title, title_english='', title_original='')[source]

Bases: object

Information about a search result

Keyword arguments are available as attributes.

Normal attributes:

Parameters:
  • id (str) – ID for the relevant DB

  • title (str) – Title of the movie or series

  • type (str) – ReleaseType value

  • url (str) – Web page of the search result

  • year (str) – Release year; for series this should be the year of the first airing of the first episode of the first season

These attributes are coroutine functions that return the value when called with no arguments:

Parameters:
  • cast (sequence of str) – Short list of actor names

  • countries (str) – List of country names of origin

  • genres (sequence of str) – Short sequence of genres, e.g. [“horror”, “comedy”]

  • directors (sequence of str) – Sequence of directors

  • summary – Short text that describes the movie or series

  • title_english (str) – English title of the movie or series

  • title_original (str) – Original title of the movie or series

The values of coroutine functions can be supplied via a coroutine function or as a plain object (str, list, etc).