/// <summary> /// Returns a listing of all files in a music directory. Typically used to get list of albums for an artist, or list of songs for an album. /// </summary> /// <param name="id">A string which uniquely identifies the music folder. Obtained by calls to getIndexes or getMusicDirectory.</param> /// <returns>MusicFolder object containing info for the specified directory</returns> public static MusicFolder GetMusicDirectory(string id) { Dictionary <string, string> theParameters = new Dictionary <string, string> { { "id", id } }; Stream theStream = MakeGenericRequest("getMusicDirectory", theParameters); StreamReader sr = new StreamReader(theStream); string result = sr.ReadToEnd(); XmlDocument myXML = new XmlDocument(); myXML.LoadXml(result); MusicFolder theFolder = new MusicFolder("ArtistFolder", id); if (myXML.ChildNodes[1].Name == "subsonic-response") { if (myXML.ChildNodes[1].FirstChild.Name == "directory") { theFolder.Name = myXML.ChildNodes[1].FirstChild.Attributes["name"].Value; theFolder.Id = myXML.ChildNodes[1].FirstChild.Attributes["id"].Value; int i = 0; for (i = 0; i < myXML.ChildNodes[1].FirstChild.ChildNodes.Count; i++) { bool isDir = Boolean.Parse(myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["isDir"].Value); if (isDir) { try { theFolder.AddFolder(MusicFolder.FromXml(myXML.ChildNodes[1].FirstChild.ChildNodes[i])); } catch (Exception e) { //todo log } } else { try { theFolder.AddSong(Song.FromXml(myXML.ChildNodes[1].FirstChild.ChildNodes[i])); } catch (Exception) { //todo log } } } } } return(theFolder); }
/// <summary> /// Returns a listing of all files in a music directory. Typically used to get list of albums for an artist, or list of songs for an album. /// </summary> /// <param name="id">A string which uniquely identifies the music folder. Obtained by calls to getIndexes or getMusicDirectory.</param> /// <returns>MusicFolder object containing info for the specified directory</returns> public static MusicFolder GetMusicDirectory(string id) { Dictionary <string, string> theParameters = new Dictionary <string, string>(); theParameters.Add("id", id); Stream theStream = MakeGenericRequest("getMusicDirectory", theParameters); StreamReader sr = new StreamReader(theStream); string result = sr.ReadToEnd(); XmlDocument myXML = new XmlDocument(); myXML.LoadXml(result); MusicFolder theFolder = new MusicFolder("ArtistFolder", id); if (myXML.ChildNodes[1].Name == "subsonic-response") { if (myXML.ChildNodes[1].FirstChild.Name == "directory") { theFolder.Name = myXML.ChildNodes[1].FirstChild.Attributes["name"].Value; theFolder.id = myXML.ChildNodes[1].FirstChild.Attributes["id"].Value; int i = 0; for (i = 0; i < myXML.ChildNodes[1].FirstChild.ChildNodes.Count; i++) { bool isDir = bool.Parse(myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["isDir"].Value); string title = myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["title"].Value; string theId = myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["id"].Value; if (isDir) { theFolder.AddFolder(title, theId); } else { theFolder.AddSong(title, theId); } } } } return(theFolder); }
/// <summary> /// Returns a listing of all files in a music directory. Typically used to get list of albums for an artist, or list of songs for an album. /// </summary> /// <param name="id">A string which uniquely identifies the music folder. Obtained by calls to getIndexes or getMusicDirectory.</param> /// <returns>MusicFolder object containing info for the specified directory</returns> public static MusicFolder GetMusicDirectory(string id) { Dictionary<string, string> theParameters = new Dictionary<string, string> { {"id", id} }; Stream theStream = MakeGenericRequest("getMusicDirectory", theParameters); StreamReader sr = new StreamReader(theStream); string result = sr.ReadToEnd(); XmlDocument myXML = new XmlDocument(); myXML.LoadXml(result); MusicFolder theFolder = new MusicFolder("ArtistFolder", id); if (myXML.ChildNodes[1].Name == "subsonic-response") { if (myXML.ChildNodes[1].FirstChild.Name == "directory") { theFolder.Name = myXML.ChildNodes[1].FirstChild.Attributes["name"].Value; theFolder.Id = myXML.ChildNodes[1].FirstChild.Attributes["id"].Value; int i = 0; for (i = 0; i < myXML.ChildNodes[1].FirstChild.ChildNodes.Count; i++) { bool isDir = Boolean.Parse(myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["isDir"].Value); if (isDir) { try { theFolder.AddFolder(MusicFolder.FromXml(myXML.ChildNodes[1].FirstChild.ChildNodes[i])); } catch (Exception e) { //todo log } } else { try { theFolder.AddSong(Song.FromXml(myXML.ChildNodes[1].FirstChild.ChildNodes[i])); } catch (Exception) { //todo log } } } } } return theFolder; }
/// <summary> /// Returns a listing of all files in a music directory. Typically used to get list of albums for an artist, or list of songs for an album. /// </summary> /// <param name="id">A string which uniquely identifies the music folder. Obtained by calls to getIndexes or getMusicDirectory.</param> /// <returns>MusicFolder object containing info for the specified directory</returns> public static MusicFolder GetMusicDirectory(string id) { Dictionary<string, string> theParameters = new Dictionary<string, string>(); theParameters.Add("id", id); Stream theStream = MakeGenericRequest("getMusicDirectory", theParameters); StreamReader sr = new StreamReader(theStream); string result = sr.ReadToEnd(); XmlDocument myXML = new XmlDocument(); myXML.LoadXml(result); MusicFolder theFolder = new MusicFolder("ArtistFolder", id); if (myXML.ChildNodes[1].Name == "subsonic-response") { if (myXML.ChildNodes[1].FirstChild.Name == "directory") { theFolder.Name = myXML.ChildNodes[1].FirstChild.Attributes["name"].Value; theFolder.id = myXML.ChildNodes[1].FirstChild.Attributes["id"].Value; int i = 0; for (i = 0; i < myXML.ChildNodes[1].FirstChild.ChildNodes.Count; i++) { bool isDir = bool.Parse(myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["isDir"].Value); string title = myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["title"].Value; string theId = myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["id"].Value; if (isDir) theFolder.AddFolder(title, theId); else theFolder.AddSong(title, theId); } } } return theFolder; }