Artwork Tasks Management

This module organizes the import process of artwork the MusicDB Database.

ArtworkManager Class

class musicdb.taskmanagement.artworkmanager.ArtworkManager(config, database)[source]

This class manages importing artwork. The class is derived from musicdb.taskmanagement.taskmanager.TaskManager.

Parameters
Raises

TypeError – When the arguments are not of the correct type.

ImportAlbumArtwork(task)[source]

This method imports an album artwork from one of the songs of the album.

The following key/value setup must be provided by the task:

  • "awsourcetype": Not Used (Will be determined automatically by musicdb.mdbapi.artwork.MusicDBArtwork.UpdateAlbumArtwork()).

  • "awsourcepath": A path to a song inside the music directory (usually also inside the album directory)

  • "albumpath": A path relative to the music directory, addressing an album that already exists in the database.

Returns

True on success

ImportArtwork(task)[source]

This method imports artwork from the upload directory or from an integrated or imported music file. Depending on the "awsourcetype" different import methods are called:

The path to the artwork source must be given in "awsourcepath".

If the artwork is being imported for an album or video is determined by the values of "videopath" or "albumpath". Only one of those values shall be set. The other one must the None.

The task must be in "startartworkimport" state, otherwise nothing happens but printing an error message. If post processing was successful, the task state gets updated to "importcomplete". When an error occurred, the state will become "invalidcontent" or "importfailed".

Parameters

task (dict) – the task object of an import-task

Returns

True on success, otherwise False

ImportArtworkFromUpload(task)[source]

This method performs the artwork import from an uploaded file. It loads the files into the Upload Directory and updates the corresponding music entries.

The following key/value setup must be provided by the task:

  • "awsourcetype": Must be "imagefile"

  • "awsourcepath": A path to a song inside the upload directory

  • "albumpath": A path relative to the music directory, addressing an album that already exists in the database.

This method expects that the state of the task is "importingartwork".

Parameters

task (dict) – The task dictionary

Returns

True on success.

ImportVideoArtwork(task)[source]
Returns

True on success

InitiateImport(sourcepath, targetpath)[source]

This method initiates importing an artwork for an album.

The addresses file can be an image or a music file. This file is used to determine the "awsourcetype". The following source types are possible and determined in the described way:

The sourcepath must be a path relative to the music directory or the upload directory. If the file does not exist in the music directory, it will then be checked in the upload directory.

The targetpath must be a path to an album or a video that already exists in the database. It determines if the artwork will be imported for an album or a video. The target type is determined by using musicdb.mdbapi.musicdirectory.MusicDirectory.AnalysePath().

Parameters
  • sourcepath (str) – Path to the artwork that shall be imported.

  • targetpath (str) – Path relative to the music directory

Returns

The task ID as string or None if something failed.

Raises
  • TypeError – When one of the parameters are of a wrong data type

  • ValueError – When one of the parameters has an unexpected value