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

getISRCs(self) Returns the ISRCs associated with this track. | source code

addISRC(self, isrc) Add a ISRC 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`, `getRating`, `getRelationTargetTypes`, `getRelationTargets`, `getRelations`, `getTag`, `getTags`, `setId`, `setRating` Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties
| title The track's title.
| artist The track's main artist.
| duration The duration in milliseconds.
| puids The list of associated PUIDs.
| isrcs The list of associated ISRCs
| releases The releases on which this track appears.
Inherited from `Entity`: `id`, `rating`, `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: object.__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

See Also: The MusicBrainz Style Guidelines

### 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:
  - `artist` - an Artist object

### 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

### getISRCs(self)

source code

Returns the ISRCs associated with this track.

Returns:
  a list of strings, each containing one ISRC

### addISRC(self, isrc)

source code

Add a ISRC to this track.

Parameters:
  - `isrc` - a string containing an ISRC

### 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:
  - `release` - a Release object

Property Details

### title

The track's title.

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

### artist

The track's main artist.

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

### duration

The duration in milliseconds.

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

### puids

The list of associated PUIDs.

Get Method:
  getPuids(self) - Returns the PUIDs associated with this track.

### isrcs

The list of associated ISRCs

Get Method:
  getISRCs(self) - Returns the ISRCs associated with this track.

### releases

The releases on which this track appears.

Get Method:
  getReleases(self) - Returns the list of releases this track appears on.