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; } } public class ListPlaylistInfo : IMpcCommand> { private readonly string _playlistName; public ListPlaylistInfo(string playlistName) { _playlistName = playlistName; } public string Value => string.Join(" ", "listplaylistinfo", $"\"{_playlistName}\""); public IEnumerable FormatResponse(IList> response) { var results = new List(); foreach (var line in response) { if (line.Key.Equals("file")) { results.Add(new MpdFile(line.Value)); } else { results.Last().AddTag(line.Key, 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; } } } } } }