Skip to content

Web Methods Library

Accalia de Elementia edited this page Jun 22, 2012 · 4 revisions

Back to Web Methods

Queue Methods

These methods inspect and manipulate the music library.

Contents

Library Listing Methods ------------------- These methods query the music library for information. They do not alter the status of the queue or playback. ##libraryList [Back to top][top]

libraryList()

Get the contents of the root directory of the music library. This will include names of saved playlists and subdirectories.

libraryList(path)

Get the contents of directory path in the music library. This will include names of subdirectories.

Example Usage

code

xml = XMLRPC.libraryList()
json = JSONRPC2('libraryList', [])

common example code

code

xml = XMLRPC.libraryList('Misc/')
json = JSONRPC2('libraryList', ['Misc/'])

common example code

result

[
    {
        "album": "Frieden",
        "artist": "Extrabreit",
        "track": "12/13",
        "title": "Sch\u00f6nes Lied",
        "disc": null,
        "file": "Misc/lied.mp3",
        "time": 195,
        "id": 23
    },
    {
        "directory": "Misc/Queen"
    },
    {
        "playlist": "Rockout Workout"
    },
    ...
]
##libraryListAll [Back to top][top]

libraryListAll()

Get a list of all songs in the music library. This can be very long, use with caution.

Example Usage

code

xml = XMLRPC.libraryListAll()
json = JSONRPC2('libraryListAll', [])

common example code

result

[
    {
        "album": "Frieden",
        "artist": "Extrabreit",
        "track": "12/13",
        "title": "Sch\u00f6nes Lied",
        "disc": null,
        "file": "Misc/lied.mp3",
        "time": 195,
        "id": 23
    },
    {
        ...
    },
    ...
]
##libraryStats [Back to top][top]

libraryStats()

Get some statistics about the music library.

  • artists: Number of unique metadata artists in the music library
  • albums: Number of unique metadata albums in the music library
  • songs: Number of music files in the music library
  • uptime: Seconds since mpd started.
  • playtime: Seconds spent playing since mpd started.
  • db_update: Time since last library update in seconds sing the Unix epoch
  • db_playtime: Total playtime of all songs in library in seconds

Example Usage

code

xml = XMLRPC.libraryStats()
json = JSONRPC2('libraryStats', [])

common example code

result

{
    "uptime": 531832,
    "db_update": 1338564705,
    "artists": 804,
    "playtime": 5572,
    "albums": 685,
    "db_playtime": 1315316,
    "songs": 6770
}
Library Search Methods ---------------------- These methods search the music library and fetch information about songs found.

The searching is performed against metadata from the songs. Not all codecs can encode all types of metadata. The following types of metadata are currently recognized:

  • artist - The name of the artist.
  • album - The name of the album from which the song is taken.
  • title - The title of the song.
  • track - The track number of the song.
  • name - The name of an audio stream.
  • genre - Keywords that place the song in one or more aesthetic brackets.
  • date - The date the song was recorded or released.
  • composer - The composer of the song.
  • performer - The principal soloist or performer.
  • disc - The disc number in an album set.
  • filename - The file name/path of the song in the music library.
  • any - Match any of the above types.
##libraryFind [Back to top][top]

libraryFind(type, needle)

Get a list of songs where needle exactly, case sensitive, matches metadata type

Example Usage

code

xml = XMLRPC.libraryFind('artist', 'Extrabreit')
json = JSONRPC2('libraryFind', ['artist', 'Extrabreit'])

common example code

result

[
    {
        "album": "Frieden",
        "artist": "Extrabreit",
        "track": "12/13",
        "title": "Sch\u00f6nes Lied",
        "disc": null,
        "file": "Misc/lied.mp3",
        "time": 195,
        "id": 23
    },
    {
        ...
    },
    ...
]
##librarySearch [Back to top][top]

librarySearch(type, needle)

Get a list of songs where metadata type contains, case insensitive, needle.

Example Usage

code

xml = XMLRPC.librarySearch('title', 'lied')
json = JSONRPC2('librarySearch', ['title', 'lied'])

common example code

result

[
    {
        "album": "Frieden",
        "artist": "Extrabreit",
        "track": "12/13",
        "title": "Sch\u00f6nes Lied",
        "disc": null,
        "file": "Misc/lied.mp3",
        "time": 195,
        "id": 23
    },
    {
        ...
    },
    ...
]
Library Status methods ---------------------- These methods report on the status of the music ##libraryUpdate [Back to top][top]

libraryUpdate()

Look for changes in the music library, return the job id of the update operation.

libraryUpdate(path)

Look for changes in the music library under directory path, return the job id of the update operation.

Example Usage

code

xml = XMLRPC.libraryUpdate()
json = JSONRPC2('libraryUpdate', [])

common example code

code

xml = XMLRPC.libraryUpdate('Misc/')
json = JSONRPC2('libraryUpdate', ['Misc/'])

common example code

result

"1"
##libraryRescan [Back to top][top]

libraryRescan()

Rescan music library, refreshing metadata from music files. Return the job id of the rescan operation.

libraryRescan(path)

Rescan music library under directory path, refreshing metadata from music files. Return job id of the rescan operation.

Example Usage

code

xml = XMLRPC.libraryRescan()
json = JSONRPC2('libraryRescan', [])

common example code

code

xml = XMLRPC.libraryRescan('Misc/')
json = JSONRPC2('libraryRescan', ['Misc/'])

common example code

result

"2"

Clone this wiki locally