using System.Collections.Generic; using System.Linq; using LibMpc.Types; namespace LibMpc { public partial class Commands { public static class Playlists { /// /// https://www.musicpd.org/doc/protocol/queue.html /// public static class Current { } /// /// https://www.musicpd.org/doc/protocol/playlist_files.html /// public static class Stored { public class ListPlaylist : IMpcCommand> { private readonly string _playlistName; public ListPlaylist(string playlistName) { _playlistName = playlistName; } public string Value => string.Join(" ", "listplaylist", $"\"{_playlistName}\""); public IEnumerable FormatResponse(IList> response) { var results = response.Where(line => line.Key.Equals("file")).Select(line => new MpdFile(line.Value)); return results; } } /// /// 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; } } } } } }