MusicDBTags

This class handles the different tags for songs and albums. Details about the concept of tags can be found here in the musicdb.lib.db.musicdb documentation.

Example

database = MusicDatabase("./music.db")
config   = MusicDBConfig("./musicdb.ini")
tags     = MusicDBTags(config, database)

tags.CreateGenre("Metal")                   # Create a genre "Metal"
tags.CreateSubgenre("Dark Metal", "Metal")  # Create a subgenre of "Metal" and name it "Dark Metal"

MusicDBTags Class

class musicdb.mdbapi.tags.MusicDBTags(config, database)[source]
Parameters
  • config – MusicDB configuration object

  • database – MusicDB database

Raises

TypeError – when config or database not of type MusicDBConfig or MusicDatabase

CreateGenre(name)[source]

See musicdb.lib.db.musicdb.MusicDatabase.CreateTag()

CreateMood(name)[source]

See musicdb.lib.db.musicdb.MusicDatabase.CreateTag()

CreateSubgenre(name, parentname)[source]

The parent name gets translated to its genre id. As mentioned in the tag concept (see musicdb), only subgenre can have parents. And those parents must be of class genre.

For further details see musicdb.lib.db.musicdb.MusicDatabase.CreateTag()

DeleteGenre(name)[source]

See musicdb.lib.db.musicdb.MusicDatabase.DeleteTag()

DeleteMood(name)[source]

See musicdb.lib.db.musicdb.MusicDatabase.DeleteTag()

DeleteSubgenre(name)[source]

See musicdb.lib.db.musicdb.MusicDatabase.DeleteTag()

DeriveAlbumTags(albumid)[source]

This method derives album tags from its song tags. It looks for all songs of the album and their specific genre and sub genre tags. Tags with a confidence level greater or equal to 1.0 will be collected and set as genres for the album. The set genres have a confidence of the average appearance of the tag over all the album’s songs.

Parameters

albumid (int) – ID of the album that tags shall be updated

Returns

Nothing

GetAllGenres()[source]

See musicdb.lib.db.musicdb.MusicDatabase.GetAllTags()

GetAllMoods()[source]

See musicdb.lib.db.musicdb.MusicDatabase.GetAllTags()

GetAllSubgenres()[source]

See musicdb.lib.db.musicdb.MusicDatabase.GetAllTags()

ModifyGenre(tagname, newname=None, newicon=None, newcolor=None, newposx=None, newposy=None)[source]

See ModifyTag().

All arguments can also be None

Parameters
  • tagname (str) – Name of the tag that shall be modified

  • newname (str) – New name of the tag

  • newicon (str) – New icon for the tag - the icon-type gets detected automatically

  • newcolor (str) – New color for the tag

  • newposx (int) – New position

  • newposy (int) – New position

ModifyMood(tagname, newname=None, newicon=None, newcolor=None, newposx=None, newposy=None)[source]

See ModifyTag().

All arguments can also be None

Parameters
  • tagname (str) – Name of the tag that shall be modified

  • newname (str) – New name of the tag

  • newicon (str) – New icon for the tag - the icon-type gets detected automatically

  • newcolor (str) – New color for the tag

  • newposx (int) – New position

  • newposy (int) – New position

ModifySubgenre(tagname, newname=None, newparent=None, newicon=None, newcolor=None, newposx=None, newposy=None)[source]

See ModifyTag().

All arguments can also be None

Parameters
  • tagname (str) – Name of the tag that shall be modified

  • newname (str) – New name of the tag

  • newparent (str) – Name of the new parent tag

  • newicon (str) – New icon for the tag - the icon-type gets detected automatically

  • newcolor (str) – New color for the tag

  • newposx (int) – New position

  • newposy (int) – New position

ModifyTag(tagname, tagclass, newname, newparent, newicon, newcolor, newposx, newposy)[source]

See musicdb.lib.db.musicdb.MusicDatabase.ModifyTag()

The icontype gets determined by the newicon-value if not None.

The parentid gets determined by the newparent-name.

Returns

On success False: in case something fails

Return type

True

Raises

AssertionError – Whenever this method does not find wrong values but the database implementation does.