Skip to content

Supporting types

Unstable API

There might be minor adjustments to these types as Mopidy and many of its extensions gets type hints added. Feel free to use these types in the if TYPE_CHECKING: blocks of Mopidy extensions, but expect to adjust your usage a bit with future Mopidy releases.

mopidy.types

Type Aliases:

Classes:

Attributes:

  • DurationMs

    A duration in milliseconds.

  • Percentage

    An integer in the range 0-100 representing a percentage.

  • ReleaseDate

    A date string on the form YYYY, YYYY-MM, or YYYY-MM-DD.

  • TracklistId

    A unique integer ID for a tracklist item.

  • Uri

    A URI string identifying a resource, e.g. a track or stream.

  • UriScheme

    The scheme part of a URI, e.g. spotify or file.

DurationMs module-attribute

DurationMs = NewType('DurationMs', int)

A duration in milliseconds.

Percentage module-attribute

Percentage = NewType('Percentage', int)

An integer in the range 0-100 representing a percentage.

ReleaseDate module-attribute

ReleaseDate = NewType('ReleaseDate', str)

A date string on the form YYYY, YYYY-MM, or YYYY-MM-DD.

TracklistId module-attribute

TracklistId = NewType('TracklistId', int)

A unique integer ID for a tracklist item.

Uri module-attribute

Uri = NewType('Uri', str)

A URI string identifying a resource, e.g. a track or stream.

UriScheme module-attribute

UriScheme = NewType('UriScheme', str)

The scheme part of a URI, e.g. spotify or file.

DistinctField

DistinctField = Literal[
    "uri",
    "track_name",
    "album",
    "artist",
    "albumartist",
    "composer",
    "performer",
    "track_no",
    "genre",
    "date",
    "comment",
    "disc_no",
    "musicbrainz_albumid",
    "musicbrainz_artistid",
    "musicbrainz_trackid",
]

Field name for get_distinct.

Query

Query[F] = dict[F, Iterable[QueryValue]]

A query mapping field names to lists of QueryValue.

QueryField

A superset of all field names that can be used in any query.

QueryValue

QueryValue = str | int

A single query value; either a string or an integer.

SearchField

SearchField = DistinctField | Literal['any']

Field name for search.

SearchQuery

A search query mapping SearchField names to lists of QueryValue.

TracklistField

TracklistField = Literal[
    "tlid", "uri", "name", "genre", "comment", "musicbrainz_id"
]

A field name that can be used in a tracklist query.

Date

Bases: DateOrYear

Deprecated alias for ReleaseDate.

DateOrYear

Bases: str

Deprecated alias for ReleaseDate.

PlaybackState

Bases: StrEnum

Enum of playback states.

Attributes:

  • PAUSED

    Constant representing the paused state.

  • PLAYING

    Constant representing the playing state.

  • STOPPED

    Constant representing the stopped state.

PAUSED class-attribute instance-attribute

PAUSED = 'paused'

Constant representing the paused state.

PLAYING class-attribute instance-attribute

PLAYING = 'playing'

Constant representing the playing state.

STOPPED class-attribute instance-attribute

STOPPED = 'stopped'

Constant representing the stopped state.

Year

Bases: DateOrYear

Deprecated alias for ReleaseDate.