- Updated. (Changelog-date: November 11th, 2014)

- Improved HTTPServer
- Ordered methods in SpotifyWebApiCass
- Added various models for the new endpoints
This commit is contained in:
Johnny @PC 2014-12-04 18:18:11 +01:00
parent 1476c4b866
commit cbd248a2fe
17 changed files with 275 additions and 73 deletions

View File

@ -7,7 +7,7 @@
<ProjectGuid>{EBBE35E2-7B91-4D7D-B8FC-3A0472F5119D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SpotifyAPI.SpotifyLocalAPI</RootNamespace>
<RootNamespace>SpotifyAPI</RootNamespace>
<AssemblyName>SpotifyAPI</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
@ -65,9 +65,11 @@
<Compile Include="SpotifyWebAPI\ClientCredentialsAuth.cs" />
<Compile Include="SpotifyWebAPI\ImplicitGrantAuth.cs" />
<Compile Include="SpotifyWebAPI\Models\BasicModel.cs" />
<Compile Include="SpotifyWebAPI\Models\FeaturedPlaylists.cs" />
<Compile Include="SpotifyWebAPI\Models\FullAlbum.cs" />
<Compile Include="SpotifyWebAPI\Models\FullArtist.cs" />
<Compile Include="SpotifyWebAPI\Models\FullTrack.cs" />
<Compile Include="SpotifyWebAPI\Models\NewAlbumReleases.cs" />
<Compile Include="SpotifyWebAPI\Models\SearchItem.cs" />
<Compile Include="SpotifyWebAPI\Models\PrivateProfile.cs" />
<Compile Include="SpotifyWebAPI\Models\GeneralModels.cs" />

View File

@ -58,13 +58,7 @@ namespace SpotifyAPI.SpotifyWebAPI
}
public void StopHttpServer()
{
try
{
httpThread.Abort();
}catch(ThreadAbortException e)
{
}
httpServer.Dispose();
httpServer = null;
}
}

View File

@ -10,11 +10,11 @@ namespace SpotifyAPI.SpotifyWebAPI.Models
public abstract class BasicModel
{
[JsonProperty("error")]
public Error Error { get; set; }
public Error ErrorResponse { get; set; }
public Boolean HasError()
{
return Error != null;
return ErrorResponse != null;
}
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace SpotifyAPI.SpotifyWebAPI.Models
{
public class FeaturedPlaylists : BasicModel
{
[JsonProperty("message")]
public String Message { get; set; }
[JsonProperty("playlists")]
public Paging<SimplePlaylist> Playlists { get; set; }
}
}

View File

@ -15,6 +15,8 @@ namespace SpotifyAPI.SpotifyWebAPI.Models
public List<SimpleArtist> Artists { get; set; }
[JsonProperty("available_markets")]
public List<String> AvailableMarkets { get; set; }
[JsonProperty("copyrights")]
public List<Copyright> Copyrights { get; set; }
[JsonProperty("external_ids")]
public Dictionary<String, String> ExternalIds { get; set; }
[JsonProperty("external_urls")]

View File

@ -11,6 +11,8 @@ namespace SpotifyAPI.SpotifyWebAPI.Models
{
[JsonProperty("external_urls")]
public Dictionary<String, String> ExternalUrls { get; set; }
[JsonProperty("followers")]
public Followers Followers { get; set; }
[JsonProperty("genres")]
public List<String> Genres { get; set; }
[JsonProperty("href")]

View File

@ -14,8 +14,8 @@ namespace SpotifyAPI.SpotifyWebAPI.Models
/// </summary>
[JsonProperty("album")]
public SimpleAlbum Album { get; set; }
[JsonProperty("artist")]
public SimpleArtist Artist { get; set; }
[JsonProperty("artists")]
public List<SimpleArtist> Artists { get; set; }
[JsonProperty("available_markets")]
public List<String> AvailableMarkets { get; set; }
[JsonProperty("disc_number")]

View File

@ -16,6 +16,12 @@ namespace SpotifyAPI.SpotifyWebAPI.Models
[JsonProperty("height")]
public int Height { get; set; }
}
public class ErrorResponse
{
[JsonProperty("error")]
public Error Error { get; set; }
}
public class Error
{
[JsonProperty("status")]
@ -46,13 +52,31 @@ namespace SpotifyAPI.SpotifyWebAPI.Models
[JsonProperty("track")]
public FullTrack Track { get; set; }
}
internal class CreatePlaylistArgs
public class CreatePlaylistArgs
{
[JsonProperty("name")]
public String Name { get; set; }
[JsonProperty("public")]
public Boolean Public { get; set; }
}
public class DeleteTrackArg
{
[JsonProperty("uri")]
public String Uri { get; set; }
[JsonProperty("positions")]
public List<int> Positions { get; set; }
public DeleteTrackArg(String uri, params int[] positions)
{
this.Positions = positions.ToList();
this.Uri = uri;
}
public bool ShouldSerializePositions()
{
// don't serialize the Manager property if an employee is their own manager
return (Positions.Count > 0);
}
}
public class SeveralTracks
{
[JsonProperty("tracks")]
@ -68,4 +92,16 @@ namespace SpotifyAPI.SpotifyWebAPI.Models
[JsonProperty("albums")]
public List<FullAlbum> Albums { get; set; }
}
public class Copyright
{
[JsonProperty("text")]
public String Text { get; set; }
[JsonProperty("type")]
public String Type { get; set; }
}
public class CheckUserTracks : BasicModel
{
public List<Boolean> Checked { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace SpotifyAPI.SpotifyWebAPI.Models
{
public class NewAlbumReleases : BasicModel
{
[JsonProperty("albums")]
public Paging<SimpleAlbum> Albums { get; set; }
}
}

View File

@ -15,6 +15,8 @@ namespace SpotifyAPI.SpotifyWebAPI.Models
public String DisplayName { get; set; }
[JsonProperty("external_urls")]
public Dictionary<string, string> ExternalUrls { get; set; }
[JsonProperty("followers")]
public Followers Followers { get; set; }
[JsonProperty("href")]
public String Href { get; set; }
[JsonProperty("id")]

View File

@ -9,12 +9,18 @@ namespace SpotifyAPI.SpotifyWebAPI.Models
{
public class PublicProfile : BasicModel
{
[JsonProperty("display_name")]
public String DisplayName { get; set; }
[JsonProperty("external_urls")]
public Dictionary<string, string> ExternalUrls { get; set; }
[JsonProperty("followers")]
public Followers Followers { get; set; }
[JsonProperty("href")]
public String Href { get; set; }
[JsonProperty("id")]
public String Id { get; set; }
[JsonProperty("images")]
public List<Image> Images { get; set; }
[JsonProperty("type")]
public String Type { get; set; }
[JsonProperty("uri")]

View File

@ -17,6 +17,8 @@ namespace SpotifyAPI.SpotifyWebAPI.Models
public String Href { get; set; }
[JsonProperty("id")]
public String Id { get; set; }
[JsonProperty("images")]
public List<Image> Images { get; set; }
[JsonProperty("name")]
public String Name { get; set; }
[JsonProperty("owner")]

View File

@ -11,6 +11,8 @@ namespace SpotifyAPI.SpotifyWebAPI.Models
{
[JsonProperty("artist")]
public SimpleArtist Artist { get; set; }
[JsonProperty("available_markets")]
public List<String> AvailableMarkets { get; set; }
[JsonProperty("disc_number")]
public int DiscNumber { get; set; }
[JsonProperty("duration_ms")]

View File

@ -11,8 +11,8 @@ namespace SpotifyAPI.SpotifyWebAPI
{
[StringAttribute("")]
NONE = 1,
[StringAttribute("playlist-modify")]
PLAYLIST_MODIFY = 2,
[StringAttribute("playlist-modify-public")]
PLAYLIST_MODIFY_PUBLIC = 2,
[StringAttribute("playlist-modify-private")]
PLAYLIST_MODIFY_PRIVATE = 4,
[StringAttribute("playlist-read-private")]
@ -22,6 +22,10 @@ namespace SpotifyAPI.SpotifyWebAPI
[StringAttribute("user-read-private")]
USER_READ_PRIVATE = 32,
[StringAttribute("user-read-email")]
USER_READ_EMAIL = 64
USER_READ_EMAIL = 64,
[StringAttribute("user-library-read")]
USER_LIBRARAY_READ = 128,
[StringAttribute("user-library-modify")]
USER_LIBRARY_MODIFY = 256
}
}

View File

@ -162,32 +162,49 @@ namespace SpotifyAPI.SpotifyWebAPI
}
}
public abstract class HttpServer {
public abstract class HttpServer : IDisposable {
protected int port;
TcpListener listener;
bool is_active = true;
public bool IsActive { get; set; }
public HttpServer(int port) {
public HttpServer(int port)
{
this.IsActive = true;
this.port = port;
}
public void listen()
{
listener = new TcpListener(port);
listener.Start();
while (is_active) {
TcpClient s = listener.AcceptTcpClient();
HttpProcessor processor = new HttpProcessor(s, this);
Thread thread = new Thread(new ThreadStart(processor.process));
thread.Start();
Thread.Sleep(1);
try
{
listener = new TcpListener(port);
listener.Start();
while (IsActive)
{
TcpClient s = listener.AcceptTcpClient();
HttpProcessor processor = new HttpProcessor(s, this);
Thread thread = new Thread(new ThreadStart(processor.process));
thread.Start();
Thread.Sleep(1);
}
}catch(Exception)
{
}
}
public void Dispose()
{
IsActive = false;
listener.Stop();
}
public abstract void handleGETRequest(HttpProcessor p);
public abstract void handlePOSTRequest(HttpProcessor p, StreamReader inputData);
}
}
public class SimpleHttpServer : HttpServer {

View File

@ -2,17 +2,18 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Net;
using SpotifyAPI.SpotifyWebAPI;
using SpotifyAPI.SpotifyWebAPI.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections.Specialized;
using System.IO;
namespace SpotifyAPI.SpotifyWebAPI
{
public class SpotifyWebAPIClass
public class SpotifyWebAPIClass : IDisposable
{
public String TokenType { get; set; }
public String AccessToken { get; set; }
@ -28,53 +29,139 @@ namespace SpotifyAPI.SpotifyWebAPI
UseAuth = true;
webclient = new WebClient();
webclient.Proxy = null;
settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, TypeNameHandling = TypeNameHandling.All };
}
#region User
public PrivateProfile GetPrivateProfile()
{
return DownloadString<PrivateProfile>("https://api.spotify.com/v1/me");
return DownloadData<PrivateProfile>("https://api.spotify.com/v1/me");
}
public PublicProfile GetPublicProfile(String userId = "")
{
if(userId.Length == 0)
return DownloadString<PublicProfile>("https://api.spotify.com/v1/me");
if (userId.Length == 0)
return DownloadData<PublicProfile>("https://api.spotify.com/v1/me");
else
return DownloadString<PublicProfile>("https://api.spotify.com/v1/users/" + userId);
return DownloadData<PublicProfile>("https://api.spotify.com/v1/users/" + userId);
}
#endregion
#region User-Library
public ErrorResponse SaveTracks(List<String> ids)
{
JArray array = new JArray(ids.ToArray());
return UploadData<ErrorResponse>("https://api.spotify.com/v1/me/tracks/", array.ToString(Formatting.None), "PUT");
}
public Paging<FullTrack> GetSavedTracks()
{
return DownloadData<Paging<FullTrack>>("https://api.spotify.com/v1/me/tracks");
}
public ErrorResponse RemoveSavedTracks(List<String> ids)
{
JArray array = new JArray(ids.ToArray());
return UploadData<ErrorResponse>("https://api.spotify.com/v1/me/tracks/", array.ToString(Formatting.None), "DELETE");
}
public CheckUserTracks CheckSavedTracks(List<String> ids)
{
String resp = DownloadString("https://api.spotify.com/v1/me/tracks/contains?ids=" + string.Join(",", ids));
JToken res = JToken.Parse(resp);
if (res is JArray)
{
return new CheckUserTracks { Checked = res.ToObject<List<Boolean>>(), ErrorResponse = null };
}
else
{
return new CheckUserTracks { Checked = null, ErrorResponse = res.ToObject<Error>() };
}
}
#endregion
#region Playlist
public Paging<SimplePlaylist> GetUserPlaylists(String userId)
{
return DownloadString<Paging<SimplePlaylist>>("https://api.spotify.com/v1/users/" + userId + "/playlists");
return DownloadData<Paging<SimplePlaylist>>("https://api.spotify.com/v1/users/" + userId + "/playlists");
}
public FullPlaylist GetPlaylist(String userId,String playlistId)
public FullPlaylist GetPlaylist(String userId, String playlistId)
{
return DownloadString<FullPlaylist>("https://api.spotify.com/v1/users/" + userId + "/playlists/" + playlistId);
return DownloadData<FullPlaylist>("https://api.spotify.com/v1/users/" + userId + "/playlists/" + playlistId);
}
public Paging<PlaylistTrack> GetPlaylistTracks(String userId,String playlistId)
public Paging<PlaylistTrack> GetPlaylistTracks(String userId, String playlistId)
{
return DownloadString<Paging<PlaylistTrack>>("https://api.spotify.com/v1/users/" + userId + "/playlists/" + playlistId + "/tracks");
return DownloadData<Paging<PlaylistTrack>>("https://api.spotify.com/v1/users/" + userId + "/playlists/" + playlistId + "/tracks");
}
public FullPlaylist CreatePlaylist(String userId,String playlistName,Boolean isPublic = true)
public FullPlaylist CreatePlaylist(String userId, String playlistName, Boolean isPublic = true)
{
CreatePlaylistArgs args = new CreatePlaylistArgs()
{
Name = playlistName,
Public = isPublic
};
return UploadData<FullPlaylist>("https://api.spotify.com/v1/users/" + userId + "/playlists",JsonConvert.SerializeObject(args));
return UploadData<FullPlaylist>("https://api.spotify.com/v1/users/" + userId + "/playlists", JsonConvert.SerializeObject(args));
}
public Error AddTracks(String userId,String playlistId,List<String> uris,int position = int.MaxValue)
public ErrorResponse UpdatePlaylist(String userId, String playlistId, String newName = null, Boolean? newPublic = null)
{
if(position == int.MaxValue)
return UploadData<Error>("https://api.spotify.com/v1/users/" + userId + "/playlists/" + playlistId + "/tracks", JsonConvert.SerializeObject(uris));
JObject ob = new JObject();
if (newName != null)
ob.Add("name", newName);
if (newPublic != null)
ob.Add("public", newPublic);
return UploadData<ErrorResponse>("https://api.spotify.com/v1/users/" + userId + "/playlists/" + playlistId, ob.ToString(Formatting.None), "PUT");
}
public ErrorResponse ReplacePlaylistTracks(String userId, String playlistId, List<String> uris)
{
JObject ob = new JObject();
ob.Add("uris", new JArray(uris));
return UploadData<ErrorResponse>("https://api.spotify.com/v1/users/" + userId + "/playlists/" + playlistId + "/tracks", ob.ToString(Formatting.None), "PUT");
}
public ErrorResponse DeletePlaylistTracks(String userId, String playlistId, List<DeleteTrackArg> args)
{
JObject ob = new JObject();
ob.Add("tracks", JArray.FromObject(args));
return UploadData<ErrorResponse>("https://api.spotify.com/v1/users/" + userId + "/playlists/" + playlistId + "/tracks", ob.ToString(Formatting.None), "DELETE");
}
public ErrorResponse AddTracks(String userId, String playlistId, List<String> uris, int position = int.MaxValue)
{
if (position == int.MaxValue)
return UploadData<ErrorResponse>("https://api.spotify.com/v1/users/" + userId + "/playlists/" + playlistId + "/tracks", JsonConvert.SerializeObject(uris));
else
{
String tracks = string.Join(",", uris);
return UploadData<Error>("https://api.spotify.com/v1/users/" + userId + "/playlists/" + playlistId + "/tracks?position=" + position
return UploadData<ErrorResponse>("https://api.spotify.com/v1/users/" + userId + "/playlists/" + playlistId + "/tracks?position=" + position
+ "&ids=" + tracks
, JsonConvert.SerializeObject(uris));
}
}
public SearchItem SearchItems(String q,SearchType type,int limit = 20,int offset = 0)
public FeaturedPlaylists GetFeaturedPlaylists(String locale = "", String country = "", DateTime timestamp = default(DateTime), int limit = 20, int offset = 0)
{
limit = Math.Max(50, limit);
StringBuilder builder = new StringBuilder("https://api.spotify.com/v1/browse/featured-playlists");
builder.Append("?limit=" + limit);
builder.Append("&offset=" + offset);
if(locale != "")
builder.Append("&locale=" + locale);
if(country != "")
builder.Append("&country=" + country);
if (timestamp != default(DateTime))
builder.Append("&timestamp=" + timestamp.ToString("yyyy-MM-ddTHH:mm:ss"));
return DownloadData<FeaturedPlaylists>(builder.ToString());
}
#endregion
#region Search and Fetch
public NewAlbumReleases GetNewAlbumReleases(String country = "", int limit = 50, int offset = 0)
{
limit = Math.Max(50, limit);
StringBuilder builder = new StringBuilder("https://api.spotify.com/v1/browse/new-releases");
builder.Append("?limit=" + limit);
builder.Append("&offset=" + offset);
if (country != "")
builder.Append("&country=" + country);
return DownloadData<NewAlbumReleases>(builder.ToString());
}
public SearchItem SearchItems(String q, SearchType type, int limit = 20, int offset = 0)
{
limit = Math.Min(50, limit);
StringBuilder builder = new StringBuilder("https://api.spotify.com/v1/search");
@ -83,67 +170,72 @@ namespace SpotifyAPI.SpotifyWebAPI
builder.Append("&limit=" + limit);
builder.Append("&offset=" + offset);
return DownloadString<SearchItem>(builder.ToString());
return DownloadData<SearchItem>(builder.ToString());
}
public SeveralTracks GetSeveralTracks(List<String> ids)
{
return DownloadString<SeveralTracks>("https://api.spotify.com/v1/tracks?ids=" + string.Join(",",ids));
return DownloadData<SeveralTracks>("https://api.spotify.com/v1/tracks?ids=" + string.Join(",", ids));
}
public SeveralAlbums GetSeveralAlbums(List<String> ids)
{
return DownloadString<SeveralAlbums>("https://api.spotify.com/v1/albums?ids=" + string.Join(",", ids));
return DownloadData<SeveralAlbums>("https://api.spotify.com/v1/albums?ids=" + string.Join(",", ids));
}
public SeveralArtists GetSeveralArtists(List<String> ids)
{
return DownloadString<SeveralArtists>("https://api.spotify.com/v1/artists?ids=" + string.Join(",", ids));
return DownloadData<SeveralArtists>("https://api.spotify.com/v1/artists?ids=" + string.Join(",", ids));
}
public FullTrack GetTrack(String id)
{
return DownloadString<FullTrack>("https://api.spotify.com/v1/tracks/" + id);
return DownloadData<FullTrack>("https://api.spotify.com/v1/tracks/" + id);
}
public SeveralArtists GetRelatedArtists(String id)
{
return DownloadString<SeveralArtists>("https://api.spotify.com/v1/artists/" + id + "/related-artists");
return DownloadData<SeveralArtists>("https://api.spotify.com/v1/artists/" + id + "/related-artists");
}
public SeveralTracks GetArtistsTopTracks(String id, String country)
{
return DownloadString<SeveralTracks>("https://api.spotify.com/v1/artists/" + id + "/top-tracks?country=" + country);
return DownloadData<SeveralTracks>("https://api.spotify.com/v1/artists/" + id + "/top-tracks?country=" + country);
}
public Paging<SimpleAlbum> GetArtistsAlbums(String id,AlbumType type = AlbumType.ALL,String country = "",int limit = 20,int offset = 0)
public Paging<SimpleAlbum> GetArtistsAlbums(String id, AlbumType type = AlbumType.ALL, String market = "", int limit = 20, int offset = 0)
{
limit = Math.Min(50, limit);
StringBuilder builder = new StringBuilder("https://api.spotify.com/v1/artists/" + id + "/albums");
builder.Append("?type=" + type.GetAlbumValue(","));
builder.Append("&limit=" + limit);
builder.Append("&offset=" + offset);
return DownloadString<Paging<SimpleAlbum>>(builder.ToString());
if (market != "")
builder.Append("&market=" + market);
return DownloadData<Paging<SimpleAlbum>>(builder.ToString());
}
public FullArtist GetArtist(String id)
{
return DownloadString<FullArtist>("https://api.spotify.com/v1/artists/" + id);
return DownloadData<FullArtist>("https://api.spotify.com/v1/artists/" + id);
}
public Paging<SimpleTrack> GetAlbumTracks(String id,int limit = 20,int offset = 0)
public Paging<SimpleTrack> GetAlbumTracks(String id, int limit = 20, int offset = 0)
{
limit = Math.Min(50, limit);
StringBuilder builder = new StringBuilder("https://api.spotify.com/v1/albums/" + id + "/tracks");
builder.Append("?limit=" + limit);
builder.Append("&offset=" + offset);
return DownloadString<Paging<SimpleTrack>>(builder.ToString());
return DownloadData<Paging<SimpleTrack>>(builder.ToString());
}
public FullAlbum GetAlbum(String id )
public FullAlbum GetAlbum(String id)
{
return DownloadString<FullAlbum>("https://api.spotify.com/v1/albums/" + id);
return DownloadData<FullAlbum>("https://api.spotify.com/v1/albums/" + id);
}
public T UploadData<T>(String url,String uploadData)
#endregion
#region Util
public T UploadData<T>(String url, String uploadData, String method = "POST")
{
if (!UseAuth)
throw new Exception("UseAuth required for 'UploadData'");
webclient.Headers.Add("Authorization", TokenType + " " + AccessToken);
webclient.Headers.Add("Content-Type","application/json");
webclient.Headers.Add("Content-Type", "application/json");
String response = "";
try
{
byte[] data = webclient.UploadData(url,Encoding.UTF8.GetBytes(uploadData));
byte[] data = webclient.UploadData(url, method, Encoding.UTF8.GetBytes(uploadData));
response = Encoding.UTF8.GetString(data);
}
catch (WebException e)
@ -152,21 +244,30 @@ namespace SpotifyAPI.SpotifyWebAPI
}
return JsonConvert.DeserializeObject<T>(response, settings);
}
public T DownloadString<T>(String url)
public T DownloadData<T>(String url)
{
if(UseAuth)
return JsonConvert.DeserializeObject<T>(DownloadString(url), settings);
}
public String DownloadString(String url)
{
if (UseAuth)
webclient.Headers.Add("Authorization", TokenType + " " + AccessToken);
String response = "";
try
{
byte [] data = webclient.DownloadData(url);
byte[] data = webclient.DownloadData(url);
response = Encoding.UTF8.GetString(data);
}catch(WebException e)
}
catch (WebException e)
{
response = new StreamReader(e.Response.GetResponseStream()).ReadToEnd();
}
return JsonConvert.DeserializeObject<T>(response, settings);
Debug.WriteLine(response);
return response;
}
#endregion
public void Dispose()
{
webclient.Dispose();

View File

@ -24,7 +24,7 @@ namespace SpotifyWebAPIExample
//Set this to localhost if you want to use the built-in HTTP Server
RedirectUri = "http://localhost",
//How many permissions we need?
Scope = Scope.USER_READ_PRIVATE | Scope.USER_READ_EMAIL | Scope.PLAYLIST_READ_PRIVATE
Scope = Scope.USER_READ_PRIVATE | Scope.USER_READ_EMAIL | Scope.PLAYLIST_READ_PRIVATE | Scope.USER_LIBRARAY_READ | Scope.USER_LIBRARY_MODIFY | Scope.USER_READ_PRIVATE
};
//Start the internal http server
auth.StartHttpServer();
@ -108,7 +108,7 @@ namespace SpotifyWebAPIExample
Console.WriteLine(playlist.Name + " (" + playlist.Id + ")");
while(playlists.Next != null)
{
playlists = spotify.DownloadString<Paging<SimplePlaylist>>(playlists.Next);
playlists = spotify.DownloadData<Paging<SimplePlaylist>>(playlists.Next);
foreach (SimplePlaylist playlist in playlists.Items)
Console.WriteLine(playlist.Name + " (" + playlist.Id + ")");
}
@ -127,7 +127,7 @@ namespace SpotifyWebAPIExample
Paging<PlaylistTrack> col = spotify.GetPlaylistTracks(spotify.GetPrivateProfile().Id, id);
if(col.HasError())
{
Console.WriteLine("ERROR: " + col.Error.Message);
Console.WriteLine("ERROR: " + col.ErrorResponse.Message);
DisplayMenu(spotify);
return;
}
@ -135,7 +135,7 @@ namespace SpotifyWebAPIExample
Console.WriteLine(track.Track.Name + " (" + track.Track.Id + ")");
while (col.Next != null)
{
col = spotify.DownloadString<Paging<PlaylistTrack>>(col.Next);
col = spotify.DownloadData<Paging<PlaylistTrack>>(col.Next);
foreach (PlaylistTrack track in col.Items)
Console.WriteLine(track.Track.Name + " (" + track.Track.Id + ")");
}