Module: MPD::Plugins::Database

Included in:
MPD
Defined in:
lib/ruby-mpd/plugins/database.rb

Overview

Commands for interacting with the music database.

Changes: listallinfo -> songs

Instance Method Summary collapse

Instance Method Details

#count(type, what) ⇒ Hash

Counts the number of songs and their total playtime in the db matching, matching the searched tag exactly.

Returns:

  • (Hash)

    a hash with songs and playtime keys.



11
12
13
# File 'lib/ruby-mpd/plugins/database.rb', line 11

def count(type, what)
  send_command :count, type, what
end

#find(type, what) ⇒ Array<MPD::Song>

Finds songs in the database that are EXACTLY matched by the what argument.

Parameters:

  • type (Symbol)

    Can be any tag supported by MPD, or one of the two special parameters: :file to search by full path (relative to database root), and :any to match against all available tags.

Returns:



22
23
24
# File 'lib/ruby-mpd/plugins/database.rb', line 22

def find(type, what)
  build_songs_list send_command(:find, type, what)
end

#list(type, arg = nil) ⇒ Array<String>

List all tags of the specified type. Type can be any tag supported by MPD or :file. If type is ‘album’ then arg can be a specific artist to list the albums for

Returns:

  • (Array<String>)


33
34
35
# File 'lib/ruby-mpd/plugins/database.rb', line 33

def list(type, arg = nil)
  send_command :list, type, arg
end

#rescan(path = nil) ⇒ Integer

Same as #update, but also rescans unmodified files.

Returns:

  • (Integer)

    Update job ID



73
74
75
# File 'lib/ruby-mpd/plugins/database.rb', line 73

def rescan(path = nil)
  send_command :rescan, path
end

#search(type, what) ⇒ Array<MPD::Song>

Searches for any song that contains what in the type field. Searches are NOT case sensitive.

Parameters:

  • type (Symbol)

    Can be any tag supported by MPD, or one of the two special parameters: :file to search by full path (relative to database root), and :any to match against all available tags.

Returns:



54
55
56
# File 'lib/ruby-mpd/plugins/database.rb', line 54

def search(type, what)
  build_songs_list(send_command(:search, type, what))
end

#songs(path = nil) ⇒ Array<MPD::Song>

List all of the songs in the database starting at path. If path isn’t specified, the root of the database is used

Returns:



43
44
45
# File 'lib/ruby-mpd/plugins/database.rb', line 43

def songs(path = nil)
  build_songs_list send_command(:listallinfo, path)
end

#update(path = nil) ⇒ Integer

Tell the server to update the database. Optionally, specify the path to update.

Returns:

  • (Integer)

    Update job ID



66
67
68
# File 'lib/ruby-mpd/plugins/database.rb', line 66

def update(path = nil)
  send_command :update, path
end