diff --git a/LibMpc/Commands/Commands.Playlists.cs b/LibMpc/Commands/Commands.Playlists.cs
index 72df4aa..f4356f5 100644
--- a/LibMpc/Commands/Commands.Playlists.cs
+++ b/LibMpc/Commands/Commands.Playlists.cs
@@ -1,4 +1,8 @@
-namespace LibMpc
+using System.Collections.Generic;
+using System.Linq;
+using LibMpc.Types;
+
+namespace LibMpc
{
public partial class Commands
{
@@ -17,7 +21,32 @@
///
public static class Stored
{
-
+ ///
+ /// Prints a list of the playlist directory.
+ ///
+ public class ListPlaylists : IMpcCommand>
+ {
+ public string Value => "listplaylists";
+
+ public IEnumerable FormatResponse(IList> response)
+ {
+ var result = new List();
+
+ foreach (var line in response)
+ {
+ if (line.Key.Equals("playlist"))
+ {
+ result.Add(new MpdPlaylist(line.Value));
+ }
+ else if (line.Key.Equals("Last-Modified"))
+ {
+ result.Last().AddLastModified(line.Value);
+ }
+ }
+
+ return result;
+ }
+ }
}
}
}
diff --git a/LibMpc/Message/MpdMessage.cs b/LibMpc/Message/MpdMessage.cs
index 186136e..8fb6234 100644
--- a/LibMpc/Message/MpdMessage.cs
+++ b/LibMpc/Message/MpdMessage.cs
@@ -15,7 +15,7 @@ namespace LibMpc
[DebuggerDisplay("Request: {Request.Command.Value} | Response Status: {Response.State.Status}")]
public class MpdMessage : IMpdMessage
{
- private readonly Regex _linePattern = new Regex("^(?[A-Za-z_]*):[ ]{0,1}(?.*)$");
+ private readonly Regex _linePattern = new Regex("^(?[A-Za-z_-]*):[ ]{0,1}(?.*)$");
private readonly IList _rawResponse;
public MpdMessage(IMpcCommand command, bool connected, IReadOnlyCollection response)
diff --git a/LibMpc/Types/MpdPlaylist.cs b/LibMpc/Types/MpdPlaylist.cs
new file mode 100644
index 0000000..7485433
--- /dev/null
+++ b/LibMpc/Types/MpdPlaylist.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Globalization;
+
+namespace LibMpc.Types
+{
+ public class MpdPlaylist
+ {
+ public MpdPlaylist(string name)
+ {
+ name.CheckNotNull();
+
+ Name = name;
+ }
+
+ public string Name { get; }
+ public DateTime LastModified { get; private set; }
+
+ internal void AddLastModified(string lastModified)
+ {
+ LastModified = DateTime.Parse(lastModified, CultureInfo.InvariantCulture);
+ }
+ }
+}
diff --git a/LibMpcTest/Tests/PlaylistsCommandsTest.cs b/LibMpcTest/Tests/PlaylistsCommandsTest.cs
new file mode 100644
index 0000000..7f95242
--- /dev/null
+++ b/LibMpcTest/Tests/PlaylistsCommandsTest.cs
@@ -0,0 +1,22 @@
+using System.Threading.Tasks;
+using Newtonsoft.Json;
+using Xunit;
+using LibMpc;
+using System.Linq;
+
+namespace LibMpcTest
+{
+ public partial class LibMpcTest
+ {
+ [Fact]
+ public async Task ListPlaylistsTest()
+ {
+ var response = await Mpc.SendAsync(new Commands.Playlists.Stored.ListPlaylists());
+
+ TestOutput.WriteLine($"ListPlaylistsTest Result:");
+ TestOutput.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented));
+
+ Assert.True(response.Response.Body.Count().Equals(3));
+ }
+ }
+}