Module: MPD::Plugins::Database
- Included in:
- MPD
- Defined in:
- lib/ruby-mpd/plugins/database.rb
Overview
Commands for interacting with the music database.
Instance Method Summary collapse
-
#albums(artist = nil) ⇒ Array<String>
Lists all of the albums in the database.
-
#artists ⇒ Array<String>
Lists all of the artists in the database.
-
#count(type, what) ⇒ Hash
Counts the number of songs and their total playtime in the db matching, matching the searched tag exactly.
-
#directories(path = nil) ⇒ Array<String>
List all of the directories in the database, starting at path.
-
#files(path = nil) ⇒ Hash<String>
List all of the files in the database, starting at path.
-
#list(type, arg = nil) ⇒ Array<String>
List all tags of the specified type.
-
#rescan(path = nil) ⇒ Integer
Same as #update, but also rescans unmodified files.
-
#search(type, what, options = {}) ⇒ Array<MPD::Song>, true
Searches for any song that contains
whatin thetypefield. -
#songs(path = nil) ⇒ Array<MPD::Song>
List all of the songs in the database starting at path.
-
#songs_by_artist(artist) ⇒ Array<MPD::Song>
List all of the songs by an artist.
-
#update(path = nil) ⇒ Integer
Tell the server to update the database.
Instance Method Details
#albums(artist = nil) ⇒ Array<String>
Lists all of the albums in the database. The optional argument is for specifying an artist to list the albums for
99 100 101 |
# File 'lib/ruby-mpd/plugins/database.rb', line 99 def albums(artist = nil) list :album, artist end |
#artists ⇒ Array<String>
Lists all of the artists in the database.
106 107 108 |
# File 'lib/ruby-mpd/plugins/database.rb', line 106 def artists list :artist end |
#count(type, what) ⇒ Hash
Counts the number of songs and their total playtime in the db matching, matching the searched tag exactly.
If you need a count on the entire database, look at #stats.
12 13 14 |
# File 'lib/ruby-mpd/plugins/database.rb', line 12 def count(type, what) send_command :count, type, what end |
#directories(path = nil) ⇒ Array<String>
List all of the directories in the database, starting at path. If path isn’t specified, the root of the database is used.
89 90 91 92 |
# File 'lib/ruby-mpd/plugins/database.rb', line 89 def directories(path = nil) response = send_command(:listall, path) return response[:directory] end |
#files(path = nil) ⇒ Hash<String>
List all of the files in the database, starting at path. If path isn’t specified, the root of the database is used.
29 30 31 |
# File 'lib/ruby-mpd/plugins/database.rb', line 29 def files(path = nil) send_command :listall, path 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
21 22 23 |
# File 'lib/ruby-mpd/plugins/database.rb', line 21 def list(type, arg = nil) send_command :list, type, arg end |
#rescan(path = nil) ⇒ Integer
Same as #update, but also rescans unmodified files.
79 80 81 |
# File 'lib/ruby-mpd/plugins/database.rb', line 79 def rescan(path = nil) send_command :rescan, path end |
#search(type, what, options = {}) ⇒ Array<MPD::Song>, true
Searches for any song that contains what in the type field. Searches are case insensitive by default, however you can enable it using the third argument.
Options:
-
add: Add the search results to the queue.
-
case_sensitive: Make the query case sensitive.
58 59 60 61 62 63 64 65 66 |
# File 'lib/ruby-mpd/plugins/database.rb', line 58 def search(type, what, = {}) if [:add] command = [:case_sensitive] ? :findadd : :searchadd else command = [:case_sensitive] ? :find : :search end build_songs_list send_command(command, 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
37 38 39 |
# File 'lib/ruby-mpd/plugins/database.rb', line 37 def songs(path = nil) build_songs_list send_command(:listallinfo, path) end |
#songs_by_artist(artist) ⇒ Array<MPD::Song>
List all of the songs by an artist.
113 114 115 |
# File 'lib/ruby-mpd/plugins/database.rb', line 113 def songs_by_artist(artist) search :artist, artist end |
#update(path = nil) ⇒ Integer
Tell the server to update the database. Optionally, specify the path to update.
72 73 74 |
# File 'lib/ruby-mpd/plugins/database.rb', line 72 def update(path = nil) send_command :update, path end |