Integration Tasks Management

This module organizes the integration of uploaded content into the Music Directory.

IntegrationManager Class

class musicdb.taskmanagement.integrationmanager.IntegrationManager(config, database)[source]

This class manages integration of content into the MusicDB Music Directory. It expects the data to integrate inside the upload directory.

This class is derived from musicdb.taskmanagement.taskmanager.TaskManager.

Parameters
Raises

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

InitiateIntegration(taskid, targetpath)[source]

This method initiates the integration of an uploaded file or directory. The targetpath will be the destination at that the uploaded content will be moved to. This path must be relative to the music directory.

If the content type of the uploaded content is "artwork", then 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().

Otherwise it is mandatory that a file addressed by targetpath does not yet exist inside the Music Directory. When a parent directory of targetpath does not exist it will be created.

The addressed task by taskid must be in the state "readyforintegration".

Parameters
  • taskid (str) – ID of the task that performed the upload

  • 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

IntegrateAlbumFile(task)[source]

This method copies a file form the upload directory into the music directory. It is expected that the file is part of an album. If the file already exists, False gets returned.

The file is copied form the location "preprocessedpath" if set. Otherwise it is copied form "uploadpath". The destination path is expected to be defined in "albumfilepath".

If the parent directory (artist or album directory) does not exist, it will be created.

Parameters

task (dict) – Data structure of a task that contains the keys mention in the method description

Returns

True on success, otherwise False

IntegrateUploadedFile(task, triggerimport=False)[source]

This method integrated the uploaded files into the music directory. The whole file tree will be created following the MusicDB naming scheme.

It is not guaranteed that after the integration all files and directory actually follow the MusicDB naming scheme. Files that have been integrated may violate that scheme. Adjusting the file and directory names is part of the import process. The integration process is for storing music files inside the music directory without any effort for the user.

The upload task must be in startintegration state. If not, nothing happens.

When triggerimport is true, the integration manager triggers the import by the importmanager This happens asynchronously inside the task management thread.

Parameters
  • task (dict) – dictionary of a task

  • triggerimport (bool) – Optional, default: False. If True the import process of the content into the Music Database will be triggered.

Returns

True on success, otherwise False

Raises
  • TypeError – When taskid is not of type str

  • ValueError – When taskid is not included in the Task Queue

IntegrateVideo(task)[source]

When an annotation needed for creating the video file path in the music directory is missing, False gets returned and an error message will be written into the log.