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

Class Disc

source code

object --+
         |
        Disc

Represents an Audio CD.

This class represents an Audio CD. A disc can have an ID (the MusicBrainz DiscID), which is calculated from the CD's table of contents (TOC). There may also be data from the TOC like the length of the disc in sectors, as well as position and length of the tracks.

Note that different TOCs, maybe due to different pressings, lead to different DiscIDs. Conversely, if two different discs have the same TOC, they also have the same DiscID (which is unlikely but not impossible). DiscIDs are always 28 characters long and look like this: 'J68I_CDcUFdCRCIbHSEbTBCbooA-'. Sometimes they are also referred to as CDIndex IDs.

The MusicBrainz web service only returns the DiscID and the number of sectors. The DiscID calculation function musicbrainz2.disc.readDisc, however, can retrieve the other attributes of Disc from an Audio CD in the disc drive.

Instance Methods
 
__init__(self, id_=None)
Constructor.
source code
 
getId(self)
Returns the MusicBrainz DiscID.
source code
 
setId(self, id_)
Sets the MusicBrainz DiscId.
source code
 
getSectors(self)
Returns the length of the disc in sectors.
source code
 
setSectors(self, sectors)
Sets the length of the disc in sectors.
source code
 
getFirstTrackNum(self)
Returns the number of the first track on this disc.
source code
 
setFirstTrackNum(self, trackNum)
Sets the number of the first track on this disc.
source code
 
getLastTrackNum(self)
Returns the number of the last track on this disc.
source code
 
setLastTrackNum(self, trackNum)
Sets the number of the last track on this disc.
source code
 
getTracks(self)
Returns the sector offset and length of this disc.
source code
 
addTrack(self, track)
Adds a track to the list.
source code

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

Properties
  id
The MusicBrainz DiscID.
  sectors
The length of the disc in sectors.
  firstTrackNum
The number of the first track on this disc.
  lastTrackNum
The number of the last track on this disc.
  tracks
Sector offset and length of all tracks.

Inherited from object: __class__

Method Details

__init__(self, id_=None)
(Constructor)

source code 

Constructor.

Parameters:
  • id_ - a string containing a 28-character DiscID
Overrides: object.__init__

getId(self)

source code 

Returns the MusicBrainz DiscID.

Returns:
a string containing a 28-character DiscID

setId(self, id_)

source code 

Sets the MusicBrainz DiscId.

Parameters:
  • id_ - a string containing a 28-character DiscID

getSectors(self)

source code 

Returns the length of the disc in sectors.

Returns:
the length in sectors as an integer, or None

setSectors(self, sectors)

source code 

Sets the length of the disc in sectors.

Parameters:
  • sectors - the length in sectors as an integer

getFirstTrackNum(self)

source code 

Returns the number of the first track on this disc.

Returns:
an int containing the track number, or None

setFirstTrackNum(self, trackNum)

source code 

Sets the number of the first track on this disc.

Parameters:
  • trackNum - an int containing the track number, or None

getLastTrackNum(self)

source code 

Returns the number of the last track on this disc.

Returns:
an int containing the track number, or None

setLastTrackNum(self, trackNum)

source code 

Sets the number of the last track on this disc.

Parameters:
  • trackNum - an int containing the track number, or None

getTracks(self)

source code 

Returns the sector offset and length of this disc.

This method returns a list of tuples containing the track offset and length in sectors for all tracks on this disc. The track offset is measured from the beginning of the disc, the length is relative to the track's offset. Note that the leadout track is not included.

Returns:
a list of (offset, length) tuples (values are ints)

addTrack(self, track)

source code 

Adds a track to the list.

This method adds an (offset, length) tuple to the list of tracks. The leadout track must not be added. The total length of the disc can be set using setSectors.

Parameters:
  • track - an (offset, length) tuple (values are ints)

See Also: getTracks


Property Details

id

The MusicBrainz DiscID.

Get Method:
getId(self) - Returns the MusicBrainz DiscID.
Set Method:
setId(self, id_) - Sets the MusicBrainz DiscId.

sectors

The length of the disc in sectors.

Get Method:
getSectors(self) - Returns the length of the disc in sectors.
Set Method:
setSectors(self, sectors) - Sets the length of the disc in sectors.

firstTrackNum

The number of the first track on this disc.

Get Method:
getFirstTrackNum(self) - Returns the number of the first track on this disc.
Set Method:
setFirstTrackNum(self, trackNum) - Sets the number of the first track on this disc.

lastTrackNum

The number of the last track on this disc.

Get Method:
getLastTrackNum(self) - Returns the number of the last track on this disc.
Set Method:
setLastTrackNum(self, trackNum) - Sets the number of the last track on this disc.

tracks

Sector offset and length of all tracks.

Get Method:
getTracks(self) - Returns the sector offset and length of this disc.