Track object Documentation

sima.lib.track.SEPARATOR = '\x1f'

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

class sima.lib.track.Track(file=None, duration=0, pos=- 1, **kwargs)[source]

Track object. Instantiate with Player replies.

Parameters
  • file (str) – media file, defaults to None

  • duration (int) – duration in second, defaults to 0

  • pos (int) – position in queue, defaults to -1

  • title|artist|album|albumartist (str) – defaults to “”

  • musicbrainz_{artistid|albumartistid|albumid|trackid} (str) – MusicBrainz IDs, defaults to None

property Album

Get the sima.lib.meta.Album associated to this track

property Artist

Get the sima.lib.meta.Artist associated to this track

property file

file is an immutable attribute that’s used for the hash method

property genres

Fetches Genres for the track Multivalue genre are dealt with:

  • when genre tag is multivalued

  • when single tag uses coma or semi-colon separator

property length

Get a fancy duration as %H:%M:%S (use duration to get duration in second only)

Meta object Documentation

Generic class and helper function

class sima.lib.meta.Meta(**kwargs)[source]

A generic Class to handle tracks metadata such as artist, album, albumartist names and their associated MusicBrainz’s ID.

Using generic kwargs in constructor for convenience but the actual signature is:

>>> Meta(name, mbid=None, **kwargs)
Parameters
  • name (str) – set name attribute

  • mbid (str) – set MusicBrainz ID

add_alias(other)[source]

Add alternative name to aliases attibute.

other can be a sima.lib.meta.Meta object in which case aliases are merged.

Parameters

other (str) – Alias to add, could be any object with __str__ method.

property aliases
property aliases_sz
property mbid
property name
property name_sz
property names

aliases + name

property names_sz
use_mbid = True

Class attribute to disable use of MusicBrainz IDs

sima.lib.meta.is_uuid4(uuid)[source]

Controls MusicBrainz UUID4 format

Parameters

uuid (str) – String representing the UUID

Returns

boolean

Derived objects

class sima.lib.meta.Artist(name, mbid=None, musicbrainz_artistid=None, albumartist=None)[source]

Bases: sima.lib.meta.Meta

Artist object deriving from Meta.

Parameters
  • name (str) – Artist name

  • mbid (str) – Musicbrainz artist ID

  • artist (str) – Overrides “name” argument

  • albumartist (str) – use “name” if not set

  • musicbrainz_artistid (str) – Overrides “mbid” argument

Example

>>> trk = {'artist':'Art Name',
>>>        'albumartist': 'Alb Art Name',           # optional
>>>        'musicbrainz_artistid': '<UUID4>',       # optional
>>>       }
>>> artobj0 = Artist(**trk)
>>> artobj1 = Artist(name='Tool')
class sima.lib.meta.Album(**kwargs)[source]

Bases: sima.lib.meta.Meta

Album object

Exceptions

class sima.lib.meta.MetaException[source]

Generic Meta Exception