paracusia v0.2.1 Paracusia.MpdClient.Database

Functions related to the music database.

See also: https://musicpd.org/doc/protocol/database.html

Summary

Functions

Returns the total playtime and number of songs that match the given filters

Same as count/1, but results are grouped with the additional parameter group

Returns all songs that match the given filters

Adds all songs that match the given filters to the queue

Returns unique tag values that match the given query

Lists all songs and directories in uri

Same as list_all/1, except it also returns metadata info

Returns the contents of the directory uri, including files are not recognized by MPD

Returns the contents of the directory uri

Returns “comments” (i.e., key-value pairs) from the file specified by uri

Same as update/0, but also rescans unmodified files

Same as update/1, but also rescans unmodified files

Case-insensitive version of find/1

Case-insensitive version of find_add/1

Performs a case-insensitive search with the given filters and adds matching songs to the given playlist

Updates the entire music database and returns the job id

Same as update/0, but only the given URI (directory or file) is updated

Functions

count(filters)

Returns the total playtime and number of songs that match the given filters.

Example

Paracusia.MpdClient.Database.count(albumartist: "Rammstein", album: "Mutter")
{:ok, %{"playtime" => 3048, "songs" => 11}}
count_grouped(group, filters \\ [])

Same as count/1, but results are grouped with the additional parameter group.

Examples

# Show the number of songs and total playlength of each album by "Rammstein":
Paracusia.MpdClient.Database.count_grouped(:album, albumartist: "Rammstein")
{:ok,
  [%{"Album" => "Mutter", "playtime" => 3048, "songs" => 11},
   %{"Album" => "Reise, Reise", "playtime" => 3385, "songs" => 14}]}
find(filters)

Returns all songs that match the given filters.

Examples

# Return all songs by "Rammstein" in the album "Mutter":
Paracusia.MpdClient.Database.find(albumartist: "Rammstein", album: "Mutter")
{:ok,
  [%{"Album" => "Mutter", "AlbumArtist" => "Rammstein",
      "Date" => "2001", "Time" => "280", "Title" => "Mein Herz brennt",
      "file" => "flac/rammstein_-_mutter/rammstein_mein_herz_brennt.flac", …},
    %{"Album" => "Mutter", "AlbumArtist" => "Rammstein",
      "Date" => "2001", "Time" => "217", "Title" => "Links 2-3-4",
      "file" => "flac/rammstein_-_mutter_(2001)/02._rammstein_links_2_3_4.flac", …},
    …
    ]
}
find_add(filters)

Adds all songs that match the given filters to the queue.

Example

# Add album "Mutter" by "Rammstein":
Paracusia.MpdClient.Database.find_add(albumartist: "Rammstein", album: "Mutter")
:ok
list(tag, filters \\ [])

Returns unique tag values that match the given query.

tag specifies which tag values should be returned. filter allows to specify a list of tag-value pairs to filter the results.

Examples

# Return all albums released by Rammstein in 2001:
Paracusia.MpdClient.Database.list(:album, albumartist: "Rammstein", date: 2001)
{:ok, ["Mutter"]}
list_all(uri)

Lists all songs and directories in uri.

Usage of this command is discouraged by the author of MPD.

list_all_info(uri \\ "")
list_all_info(String.t) ::
  {:ok, [map]} |
  Paracusia.MpdTypes.mpd_error

Same as list_all/1, except it also returns metadata info.

Usage of this command is discouraged by the author of MPD.

list_files(uri \\ "")
list_files(String.t) ::
  {:ok, [map]} |
  Paracusia.MpdTypes.mpd_error

Returns 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.

lsinfo(uri \\ "")
lsinfo(String.t) :: {:ok, [map]} | Paracusia.MpdTypes.mpd_error

Returns the contents of the directory uri.

When listing the root directory, this currently returns the list of stored playlists. This behavior is deprecated; use Paracusia.MpdClient.Playlists.list_all/0 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 (the URI is an absolute path).

read_comments(uri)
read_comments(String.t) ::
  {:ok, map} |
  Paracusia.MpdTypes.mpd_error

Returns “comments” (i.e., key-value pairs) from the file specified by uri.

uri can be a path relative to the music directory or an absolute path. May also be used to list metadata of remote files (e.g. URI beginning with “http://“ or “smb://“). The meaning of the returned key-value pairs depends on the codec, and not all decoder plugins support it.

rescan()
rescan :: {:ok, pos_integer} | Paracusia.MpdTypes.mpd_error

Same as update/0, but also rescans unmodified files.

rescan(uri)
rescan(String.t) ::
  {:ok, pos_integer} |
  Paracusia.MpdTypes.mpd_error

Same as update/1, but also rescans unmodified files.

search(filters)

Case-insensitive version of find/1.

search_add(filters)

Case-insensitive version of find_add/1.

search_add_playlist(playlist, filters)

Performs a case-insensitive search with the given filters and adds matching songs to the given playlist.

Example

Paracusia.MpdClient.Database.searchaddpl("Mutter by Rammstein", albumartist: "Rammstein", album: "Mutter")
:ok
update()
update :: {:ok, pos_integer} | Paracusia.MpdTypes.mpd_error

Updates the entire music database and returns the job id.

Find new files, remove deleted files and update modified files. The returned id is used to identify the update job. The current job id can be read from Paracusia.MpdClient.Status.status/0 (updating_db).

update(uri)
update(String.t) ::
  {:ok, pos_integer} |
  Paracusia.MpdTypes.mpd_error

Same as update/0, but only the given URI (directory or file) is updated.