Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • DatabaseCommands

Index

Constructors

constructor

Properties

Private protocol

protocol: MPDProtocol

Methods

count

  • count(filter: string | [string, string][]): Promise<SongCount>
  • Counts the number of songs and their total playtime in the database that match exactly. filter is either a filter expression as described here or an array of tuples containing a tag and the value that it should match. Note that tags are case sensitive and that the MPD documentation incorrectly lists all tags as lower-case. Use mpc.reflection.tagTypes() to get the correct list of tags supported by MPD.

    Parameters

    • filter: string | [string, string][]

    Returns Promise<SongCount>

countGrouped

  • countGrouped(filter: string | [string, string][], groupingTag: string): Promise<GroupedSongCount[]>
  • Counts the number of songs and their total playtime in the database that match exactly. filter is either a filter expression as described here or an array of tuples containing a tag and the value that it should match. The results are grouped by tag groupingTag (e.g. 'Artist', 'Album', 'Date', 'Genre') Note that tags are case sensitive and that the MPD documentation incorrectly lists all tags as lower-case. Use mpc.reflection.tagTypes() to get the correct list of tags supported by MPD.

    Parameters

    • filter: string | [string, string][]
    • groupingTag: string

    Returns Promise<GroupedSongCount[]>

find

  • find(filter: string | [string, string][], start?: undefined | number, end?: undefined | number, sort?: undefined | string): Promise<Song[]>
  • Finds songs in the database that match exactly. start and end can be used to query only a portion of the real response. sort sorts the result by the specified tag. The sort is descending if the tag is prefixed with a minus (‘-‘). Without sort, the order is undefined. Only the first tag value will be used, if multiple of the same type exist. To sort by “Artist”, “Album” or “AlbumArtist”, you should specify “ArtistSort”, “AlbumSort” or “AlbumArtistSort” instead. These will automatically fall back to the former if “*Sort” doesn’t exist. “AlbumArtist” falls back to just “Artist”. The type “Last-Modified” can sort by file modification time. filter is either a filter expression as described here or an array of tuples containing a tag or one of the special parameters listed below and the value that it should match. Supported special parameters are:

    • 'any' checks all tag values
    • 'file' checks the full path (relative to the music directory)
    • 'base' restricts the search to songs in the given directory (also relative to the music directory)
    • 'modified-since' compares the file's time stamp with the given value (ISO 8601 or UNIX time stamp) Note that tags are case sensitive and that the MPD documentation incorrectly lists all tags as lower-case. Use mpc.reflection.tagTypes() to get the correct list of tags supported by MPD.

    Parameters

    • filter: string | [string, string][]
    • Optional start: undefined | number
    • Optional end: undefined | number
    • Optional sort: undefined | string

    Returns Promise<Song[]>

findAdd

  • findAdd(filter: string | [string, string][], start?: undefined | number, end?: undefined | number, sort?: undefined | string): Promise<void>
  • Finds songs in the database that match exactly and adds them to the current playlist. Parameters have the same meaning as for find().

    Parameters

    • filter: string | [string, string][]
    • Optional start: undefined | number
    • Optional end: undefined | number
    • Optional sort: undefined | string

    Returns Promise<void>

list

  • list(type: string, filter?: string | [string, string][], groupingTags?: string[]): Promise<Map<string[], string[]>>
  • Lists unique tags values of the specified type. type can be any tag supported by MPD or 'file', but 'file' is deprecated. filter specifies a filter like the one in find(). groupingTags may be used to group the results by one or more tags. Note that tags are case sensitive and that the MPD documentation incorrectly lists all tags as lower-case. Use mpc.reflection.tagTypes() to get the correct list of tags supported by MPD.

    Parameters

    • type: string
    • Default value filter: string | [string, string][] = []
    • Default value groupingTags: string[] = []

    Returns Promise<Map<string[], string[]>>

listAll

  • listAll(uri?: undefined | string): Promise<string[]>
  • Lists all songs and directories in uri recursively. Do not use this command to manage a client-side copy of MPD's database. That is fragile and adds huge overhead. It will break with large databases. Instead, query MPD whenever you need something.

    Parameters

    • Optional uri: undefined | string

    Returns Promise<string[]>

listAllInfo

  • Same as listAll(), except it also returns metadata info. Do not use this command to manage a client-side copy of MPD's database. That is fragile and adds huge overhead. It will break with large databases. Instead, query MPD whenever you need something.

    Parameters

    • Optional uri: undefined | string

    Returns Promise<(Song | Playlist | Directory)[]>

listFiles

  • listFiles(uri?: undefined | string): Promise<(File | Directory)[]>
  • Lists the contents of the directory uri, including files are not recognized by MPD. uri can be a path relative to the music directory or an URI understood by one of the storage plugins. For example, "smb://SERVER" returns a list of all shares on the given SMB/CIFS server; "nfs://servername/path" obtains a directory listing from the NFS server.

    Parameters

    • Optional uri: undefined | string

    Returns Promise<(File | Directory)[]>

listInfo

  • Lists the contents of the directory uri. When listing the root directory, this currently returns the list of stored playlists. This behavior is deprecated; use listPlaylists() instead. This command may be used to list metadata of remote files (e.g. uri beginning with "http://" or "smb://"). Clients that are connected via UNIX domain socket may use this command to read the tags of an arbitrary local file (uri is an absolute path).

    Parameters

    • Optional uri: undefined | string

    Returns Promise<(Song | Playlist | Directory)[]>

readComments

  • readComments(uri: string): Promise<Map<string, string>>
  • Read "comments" (i.e. key-value pairs) from the file specified by uri. This uri can be a path relative to the music directory or an absolute path. This command may be used to list metadata of remote files (e.g. uri beginning with "http://" or "smb://"). Comments with suspicious characters (e.g. newlines) are ignored silently. The meaning of these depends on the codec, and not all decoder plugins support it. For example, on Ogg files, this lists the Vorbis comments.

    Parameters

    • uri: string

    Returns Promise<Map<string, string>>

rescan

  • rescan(uri?: undefined | string): Promise<number>
  • Same as update(), but also rescans unmodified files.

    Parameters

    • Optional uri: undefined | string

    Returns Promise<number>

search

  • search(filter: string | [string, string][], start?: undefined | number, end?: undefined | number, sort?: undefined | string): Promise<Song[]>
  • Searches for any song that matches. Parameters have the same meaning as for find(), except that the search is a case insensitive substring search.

    Parameters

    • filter: string | [string, string][]
    • Optional start: undefined | number
    • Optional end: undefined | number
    • Optional sort: undefined | string

    Returns Promise<Song[]>

searchAdd

  • searchAdd(filter: string | [string, string][], start?: undefined | number, end?: undefined | number, sort?: undefined | string): Promise<void>
  • Searches for any song that matches and adds them to the current playlist. Parameters have the same meaning as for find(), except that the search is a case insensitive substring search.

    Parameters

    • filter: string | [string, string][]
    • Optional start: undefined | number
    • Optional end: undefined | number
    • Optional sort: undefined | string

    Returns Promise<void>

searchAddPlaylist

  • searchAddPlaylist(name: string, filter: string | [string, string][], start?: undefined | number, end?: undefined | number, sort?: undefined | string): Promise<void>
  • Searches for any song that matches and adds them to the playlist named name. If a playlist by that name doesn't exist it is created. Parameters have the same meaning as for find(), except that the search is a case insensitive substring search.

    Parameters

    • name: string
    • filter: string | [string, string][]
    • Optional start: undefined | number
    • Optional end: undefined | number
    • Optional sort: undefined | string

    Returns Promise<void>

update

  • update(uri?: undefined | string): Promise<number>
  • Updates the music database: find new files, remove deleted files, update modified files. uri is a particular directory or song/file to update. If you do not specify it, everything is updated. Returns a positive number identifying the update job. You can read the current job id in the status response.

    Parameters

    • Optional uri: undefined | string

    Returns Promise<number>

Generated using TypeDoc