Package musicbrainz2 :: Module model :: Class Track
[frames] | no frames]

Class Track

source code

object --+    
         |    
    Entity --+
             |
            Track

Represents a track.

This class represents a track which may appear on one or more releases. A track may be associated with exactly one artist (the main artist).

Using getReleases, you can find out on which releases this track appears. To get the track number, too, use the Release.getTracksOffset method.


Note: Currently, the MusicBrainz server doesn't support tracks to be on more than one release.

See Also: Release, Artist

Instance Methods
 
__init__(self, id_=None, title=None)
Constructor.
source code
 
getTitle(self)
Returns the track's title.
source code
 
setTitle(self, title)
Sets the track's title.
source code
 
getArtist(self)
Returns the main artist of this track.
source code
 
setArtist(self, artist)
Sets this track's main artist.
source code
 
getDuration(self)
Returns the duration of this track in milliseconds.
source code
 
setDuration(self, duration)
Sets the duration of this track in milliseconds.
source code
 
getDurationSplit(self)
Returns the duration as a (minutes, seconds) tuple.
source code
 
getPuids(self)
Returns the PUIDs associated with this track.
source code
 
addPuid(self, puid)
Add a PUID to this track.
source code
 
getReleases(self)
Returns the list of releases this track appears on.
source code
 
addRelease(self, release)
Add a release on which this track appears.
source code

Inherited from Entity: addRelation, addTag, getId, getRelationTargetTypes, getRelationTargets, getRelations, getTag, getTags, setId

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties
  title
The track's title.
  artist
The track's main artist.
  duration
The duration in milliseconds.
  puids
The list of associated PUIDs.
  releases
The releases on which this track appears.

Inherited from Entity: id, tags

Inherited from object: __class__

Method Details

__init__(self, id_=None, title=None)
(Constructor)

source code 
Constructor.
Parameters:
  • id_ - a string containing an absolute URI
  • title - a string containing the title
Overrides: Entity.__init__

getTitle(self)

source code 

Returns the track's title.

The style and format of this attribute is specified by the style guide.
Returns:
a string containing the title, or None

setTitle(self, title)

source code 
Sets the track's title.
Parameters:
  • title - a string containing the title

See Also: getTitle

getArtist(self)

source code 
Returns the main artist of this track.
Returns:
an Artist object, or None

setArtist(self, artist)

source code 
Sets this track's main artist.
Parameters:

getDuration(self)

source code 
Returns the duration of this track in milliseconds.
Returns:
an int containing the duration in milliseconds, or None

setDuration(self, duration)

source code 
Sets the duration of this track in milliseconds.
Parameters:
  • duration - an int containing the duration in milliseconds

getDurationSplit(self)

source code 

Returns the duration as a (minutes, seconds) tuple.

If no duration is set, (0, 0) is returned. Seconds are rounded towards the ceiling if at least 500 milliseconds are left.
Returns:
a (minutes, seconds) tuple, both entries being ints

getPuids(self)

source code 

Returns the PUIDs associated with this track.

Please note that a PUID may be associated with more than one track.
Returns:
a list of strings, each containing one PUID

addPuid(self, puid)

source code 
Add a PUID to this track.
Parameters:
  • puid - a string containing a PUID

getReleases(self)

source code 
Returns the list of releases this track appears on.
Returns:
a list of Release objects

addRelease(self, release)

source code 
Add a release on which this track appears.
Parameters:

Property Details

title

The track's title.
Get Method:
musicbrainz2.model.Track.getTitle(self) - Returns the track's title.
Set Method:
musicbrainz2.model.Track.setTitle(self, title) - Sets the track's title.

artist

The track's main artist.
Get Method:
musicbrainz2.model.Track.getArtist(self) - Returns the main artist of this track.
Set Method:
musicbrainz2.model.Track.setArtist(self, artist) - Sets this track's main artist.

duration

The duration in milliseconds.
Get Method:
musicbrainz2.model.Track.getDuration(self) - Returns the duration of this track in milliseconds.
Set Method:
musicbrainz2.model.Track.setDuration(self, duration) - Sets the duration of this track in milliseconds.

puids

The list of associated PUIDs.
Get Method:
musicbrainz2.model.Track.getPuids(self) - Returns the PUIDs associated with this track.

releases

The releases on which this track appears.
Get Method:
musicbrainz2.model.Track.getReleases(self) - Returns the list of releases this track appears on.