using System.Collections.Generic;
using System.Linq;
namespace LibMpc
{
public partial class Commands
{
///
/// https://www.musicpd.org/doc/protocol/database.html
///
public class Database
{
// TODO: count
public class Find : IMpcCommand>>
{
private readonly ITag _tag;
private readonly string _searchText;
public Find(ITag tag, string searchText)
{
_tag = tag;
_searchText = searchText;
}
public string Value => string.Join(" ", "find", _tag.Value, _searchText);
public IDictionary>> FormatResponse(IList> response)
{
var results = new Dictionary>>
{
{ "files", new List>() }
};
foreach (var line in response)
{
if (line.Key.Equals("file"))
{
results["files"].Add(new Dictionary { { "file", line.Value } });
}
else
{
results["files"].Last().Add(line.Key, line.Value);
}
}
return results;
}
}
public class List : IMpcCommand
{
private readonly ITag _tag;
public List(ITag tag)
{
_tag = tag;
}
public string Value => string.Join(" ", "list", _tag);
public IDictionary FormatResponse(IList> response)
{
return response.ToDefaultDictionary();
}
}
// TODO: findadd
public class ListAll : IMpcCommand
{
private readonly string _path;
public ListAll(string path)
{
_path = path;
}
public string Value => string.Join(" ", "listall", _path);
public IDictionary FormatResponse(IList> response)
{
return response.ToDefaultDictionary();
}
}
// TODO: listallinfo
// TODO: listfiles
// TODO: lsinfo
// TODO: readcomments
// TODO: search
// TODO: searchadd
// TODO: searchaddpl
public class Update : IMpcCommand
{
// TODO: Extend command: < update [URI] >
public string Value => "update";
public IDictionary FormatResponse(IList> response)
{
return response.ToDefaultDictionary();
}
}
// TODO: rescan
}
}
}