These immutable data models are used for all data transfer within the Mopidy backends and between the backends and the MPD frontend. All fields are optional and immutable. In other words, they can only be set through the class constructor during instance creation.
If you want to modify a model, use the copy() method. It accepts keyword arguments for the parts of the model you want to change, and copies the rest of the data from the model you call it on. Example:
>>> from mopidy.models import Track
>>> track1 = Track(name='Christmas Carol', length=171)
>>> track1
Track(artists=[], length=171, name='Christmas Carol')
>>> track2 = track1.copy(length=37)
>>> track2
Track(artists=[], length=37, name='Christmas Carol')
>>> track1
Track(artists=[], length=171, name='Christmas Carol')
Parameters: |
|
---|
A set of album artists. Read-only.
The album release date. Read-only.
The album image URIs. Read-only.
The MusicBrainz ID of the album. Read-only.
The album name. Read-only.
The number of discs in the album. Read-only.
The number of tracks in the album. Read-only.
The album URI. Read-only.
Parameters: |
|
---|
The MusicBrainz ID of the artist. Read-only.
The artist name. Read-only.
The artist URI. Read-only.
Superclass for immutable objects whose fields can only be modified via the constructor.
Parameters: | kwargs (any) – kwargs to set as fields on the object |
---|
Copy the model with field updated to new value.
Examples:
# Returns a track with a new name
Track(name='foo').copy(name='bar')
# Return an album with a new number of tracks
Album(num_tracks=2).copy(num_tracks=5)
Parameters: | values (dict) – the model fields to modify |
---|---|
Return type: | new instance of the model being copied |
Automatically serialize Mopidy models to JSON.
Usage:
>>> import json
>>> json.dumps({'a_track': Track(name='name')}, cls=ModelJSONEncoder)
'{"a_track": {"__model__": "Track", "name": "name"}}'
Parameters: |
|
---|
The playlist modification time in UTC. Read-only.
datetime.datetime, or None if unknown.
The playlist name. Read-only.
The playlist’s tracks. Read-only.
The playlist URI. Read-only.
A tracklist track. Wraps a regular track and it’s tracklist ID.
The use of TlTrack allows the same track to appear multiple times in the tracklist.
This class also accepts it’s parameters as positional arguments. Both arguments must be provided, and they must appear in the order they are listed here.
This class also supports iteration, so your extract its values like this:
(tlid, track) = tl_track
Parameters: |
|
---|
The tracklist ID. Read-only.
The track. Read-only.
Parameters: |
|
---|
A set of track artists. Read-only.
The track’s bitrate in kbit/s. Read-only.
The track comment. Read-only.
A set of track composers. Read-only.
The track release date. Read-only.
The disc number in the album. Read-only.
The track genre. Read-only.
Integer representing when the track was last modified, exact meaning depends on source of track. For local files this is the mtime, for other backends it could be a timestamp or simply a version counter.
The track length in milliseconds. Read-only.
The MusicBrainz ID of the track. Read-only.
The track name. Read-only.
A set of track performers`. Read-only.
The track number in the album. Read-only.
The track URI. Read-only.