Module Mpd.Music_database

val find : Client.t -> (Tags.search_tags * string) list -> ?⁠sort:Tags.t -> ?⁠window:(int * int) -> unit -> (Song.t list, Protocol.ack_error * int * string * string) Stdlib.result

Find songs in the db that match exactly the a list of pairs (tag, exact_pattern). The exact_pattern is a string and the tah can be any tag supported by MPD, or one of the special parameters:

  • 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)
val findadd : Client.t -> (Tags.search_tags * string) list -> Protocol.response

Find songs in the db that and adds them to current playlist. Parameters have the same meaning as for find.

Search for any song that contains WHAT. Parameters have the same meaning as for find, except that search is not case sensitive.

val searchadd : Client.t -> (Tags.search_tags * string) list -> Protocol.response

Search for any song that contains WHAT in tag TYPE and adds them to current playlist. Parameters have the same meaning as for findadd, except that search is not case sensitive.

val searchaddpl : Client.t -> string -> (Tags.search_tags * string) list -> Protocol.response

Search for any song that contains WHAT in tag TYPE 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 search is not case sensitive.

type song_count = {
songs : int;
playtime : float;
misc : string;
}

basic type for the response of the count command.

val count : Client.t -> (Tags.t * string) list -> ?⁠group:Tags.t -> unit -> (song_count list, string) Stdlib.result

Get a count of songs with filters. For examples: count group artist will return for each artist the number of sons, the total playtime and the name of the artist in misc. Counts the number of songs and their total playtime in the db matching TAG exactly. The group keyword may be used to group the results by a tag. The following prints per-artist counts: count group artist count genre metal date 2016 group artist

val list : Client.t -> Tags.t -> (Tags.t * string) list -> (string list, string) Stdlib.result

Get a list based on some filer. For example "list album artist "Elvis Presley"" will return a list of the album names of Elvis Presley that exists in the music database.

val update : Client.t -> string option -> Protocol.response

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. Prints "updating_db: JOBID" where JOBID is a positive number identifying the update job. You can read the current job id in the status response.

val rescan : Client.t -> string option -> Protocol.response

Same as update, but also rescans unmodified files.