From 27d50ef044ab66d77abdb9f5b94d7c568dad035f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 16 Dec 2015 10:30:07 +0000 Subject: mlib: wire up search/find/stats to the UI Not in any way a stable interface, yet, and still incomplete. This should emulate parts of the mpd protocol which should make it easier to debug and develop. --- bin/dtas-mlib | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/dtas-mlib b/bin/dtas-mlib index 16876a2..e85c950 100755 --- a/bin/dtas-mlib +++ b/bin/dtas-mlib @@ -39,9 +39,30 @@ case action = ARGV.shift when 'update', 'up' directory = ARGV.shift or abort "DIRECTORY required\n#{usage}" mlib(db, migrate = true).update(directory) +when 'stats' + s = mlib(db, true).stats + %w(artists albums songs db_playtime).each { |k| puts "#{k}: #{s[k.to_sym]}" } when 'dump' # mainly for debugging directory = ARGV.shift || '/' - mlib(db).dump(directory) + mlib(db).dump(directory, {}, lambda do |parent, node, comments| + puts "Path: #{parent[:dirname]}/#{node[:name]}" + puts "Length: #{node[:tlen]}" + return if comments.empty? + puts 'Comments:' + comments.each do |k,v| + if v.size == 1 + puts "\t#{k}: #{v[0]}" + else + v << '' + puts "\t#{k}:\n\t\t#{v.join("\t\t\n")}" + end + end + puts + end) +when 'find', 'search' + m = mlib(db) + cache = {} + m.__send__(action, *ARGV) { |node| puts m.path_of(node, cache) } else abort usage end -- cgit v1.2.3-24-ge0c7