An attempt to expand all tabs

This commit is contained in:
Ian 2011-02-25 22:02:23 -05:00
parent 2b297c0ab9
commit e3ecea348e

View File

@ -36,159 +36,159 @@ namespace SubsonicAPI
public string name; public string name;
public string id; public string id;
public string lastModified; public string lastModified;
public string lastAccessed; public string lastAccessed;
public SubsonicItemType itemType; public SubsonicItemType itemType;
public SubsonicItem parent; public SubsonicItem parent;
private List<SubsonicItem> _children; private List<SubsonicItem> _children;
public List<SubsonicItem> children public List<SubsonicItem> children
{ {
get get
{ {
if (_children == null) if (_children == null)
{ {
if (this.itemType == SubsonicItemType.Song) if (this.itemType == SubsonicItemType.Song)
_children = null; _children = null;
else else
_children = Subsonic.GetItemChildren(this, ""); _children = Subsonic.GetItemChildren(this, "");
} }
return _children; return _children;
} }
set set
{ {
_children = value; _children = value;
} }
} }
public SubsonicItem() public SubsonicItem()
{ {
this.name = ""; this.name = "";
this.id = ""; this.id = "";
this.lastAccessed = DateTime.Now.ToString(); this.lastAccessed = DateTime.Now.ToString();
} }
public SubsonicItem(string name, string id) public SubsonicItem(string name, string id)
{ {
this.name = name; this.name = name;
this.id = name; this.id = name;
this.lastAccessed = DateTime.Now.ToString(); this.lastAccessed = DateTime.Now.ToString();
} }
public SubsonicItem(string name, string id, SubsonicItemType itemType, SubsonicItem parent) public SubsonicItem(string name, string id, SubsonicItemType itemType, SubsonicItem parent)
{ {
this.name = name; this.name = name;
this.id = id; this.id = id;
this.itemType = itemType; this.itemType = itemType;
this.parent = parent; this.parent = parent;
this.lastAccessed = DateTime.Now.ToString(); this.lastAccessed = DateTime.Now.ToString();
} }
public override string ToString() public override string ToString()
{ {
return name; return name;
} }
public SubsonicItem FindItemById(string id) public SubsonicItem FindItemById(string id)
{ {
SubsonicItem foundItem = null; SubsonicItem foundItem = null;
// If the current item is the item we are looking for, return it // If the current item is the item we are looking for, return it
if (this.id == id) if (this.id == id)
foundItem = this; foundItem = this;
// Otherwise, we check the children if they exist // Otherwise, we check the children if they exist
else if (_children != null) else if (_children != null)
{ {
foreach(SubsonicItem child in _children) foreach(SubsonicItem child in _children)
{ {
// If this child is the item we are looking for, return it // If this child is the item we are looking for, return it
if (child.id == id) if (child.id == id)
{ {
foundItem = child; foundItem = child;
break; break;
} }
else else
{ {
foundItem = child.FindItemById(id); foundItem = child.FindItemById(id);
if (foundItem != null) if (foundItem != null)
break; break;
} }
} }
} }
return foundItem; return foundItem;
} }
public SubsonicItem GetChildByName(string childName) public SubsonicItem GetChildByName(string childName)
{ {
SubsonicItem theItem = null; SubsonicItem theItem = null;
if (_children != null) if (_children != null)
{ {
theItem = _children.Find( theItem = _children.Find(
delegate(SubsonicItem itm) delegate(SubsonicItem itm)
{ {
return itm.name == childName ; return itm.name == childName ;
} }
); );
} }
return theItem; return theItem;
} }
} }
public class Song : SubsonicItem public class Song : SubsonicItem
{ {
public string artist; public string artist;
public string album; public string album;
public string title; public string title;
public Song() public Song()
{ {
this.artist = ""; this.artist = "";
this.title = ""; this.title = "";
this.album = ""; this.album = "";
this.name = ""; this.name = "";
this.id = ""; this.id = "";
this.itemType = SubsonicItem.SubsonicItemType.Song; this.itemType = SubsonicItem.SubsonicItemType.Song;
this.parent = null; this.parent = null;
this.lastAccessed = DateTime.Now.ToString(); this.lastAccessed = DateTime.Now.ToString();
} }
public Song(string title,string artist, string album, string id) public Song(string title,string artist, string album, string id)
{ {
this.artist = artist; this.artist = artist;
this.title = title; this.title = title;
this.album = album; this.album = album;
this.name = title; this.name = title;
this.id = id; this.id = id;
this.itemType = SubsonicItem.SubsonicItemType.Song; this.itemType = SubsonicItem.SubsonicItemType.Song;
this.parent = null; this.parent = null;
this.lastAccessed = DateTime.Now.ToString(); this.lastAccessed = DateTime.Now.ToString();
} }
public Song(string title, string artist, string album, string id, SubsonicItem parent) public Song(string title, string artist, string album, string id, SubsonicItem parent)
{ {
this.artist = artist; this.artist = artist;
this.title = title; this.title = title;
this.album = album; this.album = album;
this.name = title; this.name = title;
this.id = id; this.id = id;
this.itemType = SubsonicItem.SubsonicItemType.Song; this.itemType = SubsonicItem.SubsonicItemType.Song;
this.parent = parent; this.parent = parent;
this.lastAccessed = DateTime.Now.ToString(); this.lastAccessed = DateTime.Now.ToString();
} }
public Stream getStream() public Stream getStream()
{ {
return Subsonic.StreamSong(this.id); return Subsonic.StreamSong(this.id);
} }
public override string ToString() public override string ToString()
{ {
return artist + " - " + title; return artist + " - " + title;
} }
} }
#endregion Classes #endregion Classes
@ -198,22 +198,22 @@ namespace SubsonicAPI
/// </summary> /// </summary>
public static class Subsonic public static class Subsonic
{ {
private static SubsonicItem _MyLibrary; private static SubsonicItem _MyLibrary;
/// <summary> /// <summary>
/// Public Property that can be used for auto-retrieving children /// Public Property that can be used for auto-retrieving children
/// </summary> /// </summary>
public static SubsonicItem MyLibrary public static SubsonicItem MyLibrary
{ {
get get
{ {
return _MyLibrary; return _MyLibrary;
} }
set set
{ {
_MyLibrary = value; _MyLibrary = value;
} }
} }
// Should be set from application layer when the application is loaded // Should be set from application layer when the application is loaded
public static string appName; public static string appName;
@ -225,9 +225,9 @@ namespace SubsonicAPI
static string server; static string server;
static string authHeader; static string authHeader;
// Used for generating direct URLS // Used for generating direct URLS
static string encPass; static string encPass;
static string username; static string username;
/// <summary> /// <summary>
/// Takes parameters for server, username and password to generate an auth header /// Takes parameters for server, username and password to generate an auth header
@ -245,11 +245,11 @@ namespace SubsonicAPI
authHeader = user + ":" + password; authHeader = user + ":" + password;
authHeader = Convert.ToBase64String(Encoding.Default.GetBytes(authHeader)); authHeader = Convert.ToBase64String(Encoding.Default.GetBytes(authHeader));
// Store user and encoded password for alternate authentication // Store user and encoded password for alternate authentication
username = user; username = user;
Byte[] passwordBytes = Encoding.Default.GetBytes(password); Byte[] passwordBytes = Encoding.Default.GetBytes(password);
for (int i = 0; i < passwordBytes.Length; i++) for (int i = 0; i < passwordBytes.Length; i++)
encPass += passwordBytes[i].ToString("x2"); encPass += passwordBytes[i].ToString("x2");
Stream theStream = MakeGenericRequest("ping", null); Stream theStream = MakeGenericRequest("ping", null);
@ -259,7 +259,7 @@ namespace SubsonicAPI
/// TODO: Parse the result and determine if logged in or not /// TODO: Parse the result and determine if logged in or not
_MyLibrary = new SubsonicItem("LibraryRoot", "-1", SubsonicItem.SubsonicItemType.Library, null); _MyLibrary = new SubsonicItem("LibraryRoot", "-1", SubsonicItem.SubsonicItemType.Library, null);
return result; return result;
} }
@ -319,16 +319,16 @@ namespace SubsonicAPI
return requestURL; return requestURL;
} }
/// <summary> /// <summary>
/// Creates a URL for a command with username and encoded pass in the URL /// Creates a URL for a command with username and encoded pass in the URL
/// </summary> /// </summary>
/// <param name="method"></param> /// <param name="method"></param>
/// <param name="parameters"></param> /// <param name="parameters"></param>
/// <returns>URL for streaming a song or retrieving the results of a call</returns> /// <returns>URL for streaming a song or retrieving the results of a call</returns>
public static string BuildDirectURL(string method, Dictionary<string, string> parameters) public static string BuildDirectURL(string method, Dictionary<string, string> parameters)
{ {
string callURL = "http://" + server + "/rest/" + method + "?v=" + apiVersion + "&c=" + appName string callURL = "http://" + server + "/rest/" + method + "?v=" + apiVersion + "&c=" + appName
+ "&u=" + username + "&p=enc:" + encPass; + "&u=" + username + "&p=enc:" + encPass;
if (parameters != null) if (parameters != null)
{ {
foreach (KeyValuePair<string, string> parameter in parameters) foreach (KeyValuePair<string, string> parameter in parameters)
@ -337,39 +337,39 @@ namespace SubsonicAPI
} }
} }
return callURL; return callURL;
} }
/// <summary> /// <summary>
/// Returns a list of SubsonicItems that fall inside the parent object /// Returns a list of SubsonicItems that fall inside the parent object
/// </summary> /// </summary>
/// <param name="parent"> /// <param name="parent">
/// A <see cref="SubsonicItem"/> /// A <see cref="SubsonicItem"/>
/// </param> /// </param>
/// <param name="ifModifiedSince"> /// <param name="ifModifiedSince">
/// A <see cref="System.String"/> /// A <see cref="System.String"/>
/// </param> /// </param>
/// <returns> /// <returns>
/// A <see cref="List<SubsonicItem>"/> /// A <see cref="List<SubsonicItem>"/>
/// </returns> /// </returns>
public static List<SubsonicItem> GetItemChildren(SubsonicItem parent, string ifModifiedSince) public static List<SubsonicItem> GetItemChildren(SubsonicItem parent, string ifModifiedSince)
{ {
Dictionary<string, string> parameters = new Dictionary<string, string>(); Dictionary<string, string> parameters = new Dictionary<string, string>();
// Generate the proper request for the parent type // Generate the proper request for the parent type
string requestType, musicFolderId; string requestType, musicFolderId;
if (parent.itemType == SubsonicItem.SubsonicItemType.Library) if (parent.itemType == SubsonicItem.SubsonicItemType.Library)
{ {
requestType = "getIndexes"; requestType = "getIndexes";
if (parent.id != "-1") if (parent.id != "-1")
parameters.Add("musicFolderId", parent.id); parameters.Add("musicFolderId", parent.id);
} }
else else
{ {
requestType = "getMusicDirectory"; requestType = "getMusicDirectory";
parameters.Add("id", parent.id); parameters.Add("id", parent.id);
} }
// Load the parameters if provided // Load the parameters if provided
if (!string.IsNullOrEmpty(ifModifiedSince)) if (!string.IsNullOrEmpty(ifModifiedSince))
parameters.Add("ifModifiedSince", ifModifiedSince); parameters.Add("ifModifiedSince", ifModifiedSince);
@ -383,50 +383,50 @@ namespace SubsonicAPI
XmlDocument myXML = new XmlDocument(); XmlDocument myXML = new XmlDocument();
myXML.LoadXml(result); myXML.LoadXml(result);
List<SubsonicItem> children = new List<SubsonicItem>(); List<SubsonicItem> children = new List<SubsonicItem>();
// Parse the artist // Parse the artist
if (parent.itemType == SubsonicItem.SubsonicItemType.Library) if (parent.itemType == SubsonicItem.SubsonicItemType.Library)
{ {
if (myXML.ChildNodes[1].Name == "subsonic-response") if (myXML.ChildNodes[1].Name == "subsonic-response")
{ {
if (myXML.ChildNodes[1].FirstChild.Name == "indexes") if (myXML.ChildNodes[1].FirstChild.Name == "indexes")
{ {
for (int i = 0; i < myXML.ChildNodes[1].FirstChild.ChildNodes.Count; i++) for (int i = 0; i < myXML.ChildNodes[1].FirstChild.ChildNodes.Count; i++)
{ {
for (int j = 0; j < myXML.ChildNodes[1].FirstChild.ChildNodes[i].ChildNodes.Count; j++) for (int j = 0; j < myXML.ChildNodes[1].FirstChild.ChildNodes[i].ChildNodes.Count; j++)
{ {
string artist = myXML.ChildNodes[1].FirstChild.ChildNodes[i].ChildNodes[j].Attributes["name"].Value; string artist = myXML.ChildNodes[1].FirstChild.ChildNodes[i].ChildNodes[j].Attributes["name"].Value;
string id = myXML.ChildNodes[1].FirstChild.ChildNodes[i].ChildNodes[j].Attributes["id"].Value; string id = myXML.ChildNodes[1].FirstChild.ChildNodes[i].ChildNodes[j].Attributes["id"].Value;
children.Add(new SubsonicItem(artist, id, SubsonicItem.SubsonicItemType.Folder, parent)); children.Add(new SubsonicItem(artist, id, SubsonicItem.SubsonicItemType.Folder, parent));
} }
} }
} }
} }
} }
// Parse the directory // Parse the directory
else if (parent.itemType == SubsonicItem.SubsonicItemType.Folder) else if (parent.itemType == SubsonicItem.SubsonicItemType.Folder)
{ {
if (myXML.ChildNodes[1].Name == "subsonic-response") if (myXML.ChildNodes[1].Name == "subsonic-response")
{ {
if (myXML.ChildNodes[1].FirstChild.Name == "directory") if (myXML.ChildNodes[1].FirstChild.Name == "directory")
{ {
for (int i = 0; i < myXML.ChildNodes[1].FirstChild.ChildNodes.Count; i++) for (int i = 0; i < myXML.ChildNodes[1].FirstChild.ChildNodes.Count; i++)
{ {
bool isDir = bool.Parse(myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["isDir"].Value); 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 title = myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["title"].Value;
string id = myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["id"].Value; string id = myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["id"].Value;
SubsonicItem theItem = new SubsonicItem(title, id, (isDir ? SubsonicItem.SubsonicItemType.Folder : SubsonicItem.SubsonicItemType.Song), parent); SubsonicItem theItem = new SubsonicItem(title, id, (isDir ? SubsonicItem.SubsonicItemType.Folder : SubsonicItem.SubsonicItemType.Song), parent);
children.Add(theItem); children.Add(theItem);
} }
} }
} }
} }
return children; return children;
} }
/// <summary> /// <summary>
/// Returns an indexed structure of all artists. /// Returns an indexed structure of all artists.
@ -436,7 +436,7 @@ namespace SubsonicAPI
/// <returns>Dictionary, Key = Artist and Value = id</returns> /// <returns>Dictionary, Key = Artist and Value = id</returns>
public static List<SubsonicItem> GetIndexes(string musicFolderId, string ifModifiedSince) public static List<SubsonicItem> GetIndexes(string musicFolderId, string ifModifiedSince)
{ {
// Load the parameters if provided // Load the parameters if provided
Dictionary<string, string> parameters = new Dictionary<string, string>(); Dictionary<string, string> parameters = new Dictionary<string, string>();
if (!string.IsNullOrEmpty(musicFolderId)) if (!string.IsNullOrEmpty(musicFolderId))
parameters.Add("musicFolderId", musicFolderId); parameters.Add("musicFolderId", musicFolderId);
@ -456,7 +456,7 @@ namespace SubsonicAPI
// Parse the XML document into a List // Parse the XML document into a List
List<SubsonicItem> artists = new List<SubsonicItem>(); List<SubsonicItem> artists = new List<SubsonicItem>();
if (myXML.ChildNodes[1].Name == "subsonic-response") if (myXML.ChildNodes[1].Name == "subsonic-response")
{ {
if (myXML.ChildNodes[1].FirstChild.Name == "indexes") if (myXML.ChildNodes[1].FirstChild.Name == "indexes")
{ {
@ -478,15 +478,15 @@ namespace SubsonicAPI
return artists; return artists;
} }
public static List<SubsonicItem> GetIndexes(string musicFolderId) public static List<SubsonicItem> GetIndexes(string musicFolderId)
{ {
return GetIndexes(musicFolderId, ""); return GetIndexes(musicFolderId, "");
} }
public static List<SubsonicItem> GetIndexes() public static List<SubsonicItem> GetIndexes()
{ {
return GetIndexes("", ""); return GetIndexes("", "");
} }
/// <summary> /// <summary>
/// Streams a given music file. (Renamed from request name "stream") /// Streams a given music file. (Renamed from request name "stream")
@ -511,10 +511,10 @@ namespace SubsonicAPI
return theStream; return theStream;
} }
public static Stream StreamSong(string id) public static Stream StreamSong(string id)
{ {
return StreamSong(id, null); return StreamSong(id, null);
} }
/// <summary> /// <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. /// 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.
@ -540,7 +540,7 @@ namespace SubsonicAPI
{ {
if (myXML.ChildNodes[1].FirstChild.Name == "directory") if (myXML.ChildNodes[1].FirstChild.Name == "directory")
{ {
SubsonicItem theParent = new SubsonicItem(); SubsonicItem theParent = new SubsonicItem();
theParent.name = myXML.ChildNodes[1].FirstChild.Attributes["name"].Value; theParent.name = myXML.ChildNodes[1].FirstChild.Attributes["name"].Value;
theParent.id = myXML.ChildNodes[1].FirstChild.Attributes["id"].Value; theParent.id = myXML.ChildNodes[1].FirstChild.Attributes["id"].Value;
@ -551,8 +551,8 @@ namespace SubsonicAPI
string title = myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["title"].Value; string title = myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["title"].Value;
string theId = myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["id"].Value; string theId = myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["id"].Value;
SubsonicItem theItem = new SubsonicItem(title, theId, (isDir ? SubsonicItem.SubsonicItemType.Folder : SubsonicItem.SubsonicItemType.Song), theParent); SubsonicItem theItem = new SubsonicItem(title, theId, (isDir ? SubsonicItem.SubsonicItemType.Folder : SubsonicItem.SubsonicItemType.Song), theParent);
theContents.Add(theItem); theContents.Add(theItem);
} }
} }
} }
@ -560,47 +560,47 @@ namespace SubsonicAPI
return theContents; return theContents;
} }
/// <summary> /// <summary>
/// Returns what is currently being played by all users. Takes no extra parameters. /// Returns what is currently being played by all users. Takes no extra parameters.
/// </summary> /// </summary>
public static List<SubsonicItem> GetNowPlaying() public static List<SubsonicItem> GetNowPlaying()
{ {
List<SubsonicItem> nowPlaying = new List<SubsonicItem>(); List<SubsonicItem> nowPlaying = new List<SubsonicItem>();
Dictionary<string, string> theParameters = new Dictionary<string, string>(); Dictionary<string, string> theParameters = new Dictionary<string, string>();
Stream theStream = MakeGenericRequest("getNowPlaying", theParameters); Stream theStream = MakeGenericRequest("getNowPlaying", theParameters);
StreamReader sr = new StreamReader(theStream); StreamReader sr = new StreamReader(theStream);
string result = sr.ReadToEnd(); string result = sr.ReadToEnd();
/// TODO: Parse result to list /// TODO: Parse result to list
return nowPlaying; return nowPlaying;
} }
/// <summary> /// <summary>
/// Performs a search valid for the current version of the subsonic server /// Performs a search valid for the current version of the subsonic server
/// If version is >= 1.4.0 search2 /// If version is >= 1.4.0 search2
/// Else search /// Else search
/// </summary> /// </summary>
/// <param name="query">The Term you want to search for</param> /// <param name="query">The Term you want to search for</param>
/// <returns>A List of SubsonicItem objects</returns> /// <returns>A List of SubsonicItem objects</returns>
public static List<SubsonicItem> Search(string query) public static List<SubsonicItem> Search(string query)
{ {
Dictionary<string, string> parameters = new Dictionary<string, string>(); Dictionary<string, string> parameters = new Dictionary<string, string>();
Version apiV = new Version(apiVersion); Version apiV = new Version(apiVersion);
Version Search2Min = new Version("1.4.0"); Version Search2Min = new Version("1.4.0");
string request = ""; string request = "";
// Use search for the server version // Use search for the server version
if (apiV >= Search2Min) if (apiV >= Search2Min)
{ {
request = "search2"; request = "search2";
parameters.Add("query", query); parameters.Add("query", query);
} }
else else
{ {
request = "search"; request = "search";
parameters.Add("any", query); parameters.Add("any", query);
} }
// Make the request // Make the request
Stream theStream = MakeGenericRequest(request, parameters); Stream theStream = MakeGenericRequest(request, parameters);
@ -612,10 +612,10 @@ namespace SubsonicAPI
XmlDocument myXML = new XmlDocument(); XmlDocument myXML = new XmlDocument();
myXML.LoadXml(result); myXML.LoadXml(result);
List<SubsonicItem> searchResults = new List<SubsonicItem>(); List<SubsonicItem> searchResults = new List<SubsonicItem>();
// Parse the artist // Parse the artist
if (myXML.ChildNodes[1].Name == "subsonic-response") if (myXML.ChildNodes[1].Name == "subsonic-response")
{ {
if (myXML.ChildNodes[1].FirstChild.Name == "searchResult") if (myXML.ChildNodes[1].FirstChild.Name == "searchResult")
{ {
@ -624,69 +624,69 @@ namespace SubsonicAPI
bool isDir = bool.Parse(myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["isDir"].Value); 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 title = myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["title"].Value;
string theId = myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["id"].Value; string theId = myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["id"].Value;
string artist = ""; string artist = "";
string album = ""; string album = "";
if (!isDir) if (!isDir)
{ {
artist = myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["artist"].Value; artist = myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["artist"].Value;
album = myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["album"].Value; album = myXML.ChildNodes[1].FirstChild.ChildNodes[i].Attributes["album"].Value;
} }
SubsonicItem theItem; SubsonicItem theItem;
if (isDir) if (isDir)
theItem = new SubsonicItem(title, theId, SubsonicItem.SubsonicItemType.Folder, null); theItem = new SubsonicItem(title, theId, SubsonicItem.SubsonicItemType.Folder, null);
else else
theItem = new Song(title, artist, album, theId); theItem = new Song(title, artist, album, theId);
searchResults.Add(theItem); searchResults.Add(theItem);
} }
} }
} }
return searchResults; return searchResults;
} }
/// <summary> /// <summary>
/// Returns a list of all playlists on server /// Returns a list of all playlists on server
/// </summary> /// </summary>
public static List<SubsonicItem> GetPlaylists() public static List<SubsonicItem> GetPlaylists()
{ {
List<SubsonicItem> playlists = new List<SubsonicItem>(); List<SubsonicItem> playlists = new List<SubsonicItem>();
Dictionary<string, string> theParameters = new Dictionary<string, string>(); Dictionary<string, string> theParameters = new Dictionary<string, string>();
Stream theStream = MakeGenericRequest("getPlaylists", theParameters); Stream theStream = MakeGenericRequest("getPlaylists", theParameters);
StreamReader sr = new StreamReader(theStream); StreamReader sr = new StreamReader(theStream);
string result = sr.ReadToEnd(); string result = sr.ReadToEnd();
/// TODO: Parse result into list /// TODO: Parse result into list
return playlists; return playlists;
} }
/// <summary> /// <summary>
/// Returns a list of all SubsonicItems in playlist of given ID /// Returns a list of all SubsonicItems in playlist of given ID
/// </summary> /// </summary>
/// <param name="playlistId"> /// <param name="playlistId">
/// ID of playlist to be fetched [retreive from GetPlaylists()] /// ID of playlist to be fetched [retreive from GetPlaylists()]
/// </param> /// </param>
/// <returns> /// <returns>
/// Returns list of SubsonicItems /// Returns list of SubsonicItems
/// </returns> /// </returns>
public static List<SubsonicItem> GetPlaylist(string playlistId) public static List<SubsonicItem> GetPlaylist(string playlistId)
{ {
List<SubsonicItem> playlist = new List<SubsonicItem>(); List<SubsonicItem> playlist = new List<SubsonicItem>();
Dictionary<string, string> theParameters = new Dictionary<string, string>(); Dictionary<string, string> theParameters = new Dictionary<string, string>();
theParameters.Add("id", playlistId); theParameters.Add("id", playlistId);
Stream theStream = MakeGenericRequest("getPlaylist", theParameters); Stream theStream = MakeGenericRequest("getPlaylist", theParameters);
StreamReader sr = new StreamReader(theStream); StreamReader sr = new StreamReader(theStream);
string result = sr.ReadToEnd(); string result = sr.ReadToEnd();
/// TODO: Parse result into list /// TODO: Parse result into list
return playlist; return playlist;
} }