mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-23 22:56:25 +00:00
Code Cleanup and ImplictGrantAuth name fix, fixes #320
This commit is contained in:
parent
278927f704
commit
3917fbefdc
@ -21,10 +21,6 @@ namespace SpotifyAPI.Web.Auth
|
|||||||
{
|
{
|
||||||
Process.Start("open", url);
|
Process.Start("open", url);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// throw
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
url = url.Replace("&", "^&");
|
url = url.Replace("&", "^&");
|
||||||
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}"));
|
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}"));
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net;
|
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -48,7 +47,7 @@ namespace SpotifyAPI.Web.Auth
|
|||||||
|
|
||||||
public async Task<Token> RefreshToken(string refreshToken)
|
public async Task<Token> RefreshToken(string refreshToken)
|
||||||
{
|
{
|
||||||
List<KeyValuePair<string, string>> args = new List<KeyValuePair<string, string>>()
|
List<KeyValuePair<string, string>> args = new List<KeyValuePair<string, string>>
|
||||||
{
|
{
|
||||||
new KeyValuePair<string, string>("grant_type", "refresh_token"),
|
new KeyValuePair<string, string>("grant_type", "refresh_token"),
|
||||||
new KeyValuePair<string, string>("refresh_token", refreshToken)
|
new KeyValuePair<string, string>("refresh_token", refreshToken)
|
||||||
@ -65,7 +64,7 @@ namespace SpotifyAPI.Web.Auth
|
|||||||
}
|
}
|
||||||
public async Task<Token> ExchangeCode(string code)
|
public async Task<Token> ExchangeCode(string code)
|
||||||
{
|
{
|
||||||
List<KeyValuePair<string, string>> args = new List<KeyValuePair<string, string>>()
|
List<KeyValuePair<string, string>> args = new List<KeyValuePair<string, string>>
|
||||||
{
|
{
|
||||||
new KeyValuePair<string, string>("grant_type", "authorization_code"),
|
new KeyValuePair<string, string>("grant_type", "authorization_code"),
|
||||||
new KeyValuePair<string, string>("code", code),
|
new KeyValuePair<string, string>("code", code),
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net;
|
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -25,7 +24,7 @@ namespace SpotifyAPI.Web.Auth
|
|||||||
{
|
{
|
||||||
string auth = Convert.ToBase64String(Encoding.UTF8.GetBytes(ClientId + ":" + ClientSecret));
|
string auth = Convert.ToBase64String(Encoding.UTF8.GetBytes(ClientId + ":" + ClientSecret));
|
||||||
|
|
||||||
List<KeyValuePair<string, string>> args = new List<KeyValuePair<string, string>>()
|
List<KeyValuePair<string, string>> args = new List<KeyValuePair<string, string>>
|
||||||
{
|
{
|
||||||
new KeyValuePair<string, string>("grant_type", "client_credentials")
|
new KeyValuePair<string, string>("grant_type", "client_credentials")
|
||||||
};
|
};
|
||||||
|
@ -1,24 +1,15 @@
|
|||||||
using System;
|
|
||||||
using System.Net;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using SpotifyAPI.Web.Enums;
|
using SpotifyAPI.Web.Enums;
|
||||||
using SpotifyAPI.Web.Models;
|
using SpotifyAPI.Web.Models;
|
||||||
using Unosquare.Labs.EmbedIO;
|
using Unosquare.Labs.EmbedIO;
|
||||||
using Unosquare.Labs.EmbedIO.Constants;
|
using Unosquare.Labs.EmbedIO.Constants;
|
||||||
using Unosquare.Labs.EmbedIO.Modules;
|
using Unosquare.Labs.EmbedIO.Modules;
|
||||||
#if NETSTANDARD2_0
|
|
||||||
using System.Net.Http;
|
|
||||||
#endif
|
|
||||||
#if NET46
|
|
||||||
using System.Net.Http;
|
|
||||||
using HttpListenerContext = Unosquare.Net.HttpListenerContext;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace SpotifyAPI.Web.Auth
|
namespace SpotifyAPI.Web.Auth
|
||||||
{
|
{
|
||||||
public class ImplictGrantAuth : SpotifyAuthServer<Token>
|
public class ImplicitGrantAuth : SpotifyAuthServer<Token>
|
||||||
{
|
{
|
||||||
public ImplictGrantAuth(string clientId, string redirectUri, string serverUri, Scope scope = Scope.None, string state = "") :
|
public ImplicitGrantAuth(string clientId, string redirectUri, string serverUri, Scope scope = Scope.None, string state = "") :
|
||||||
base("token", "ImplicitGrantAuth", redirectUri, serverUri, scope, state)
|
base("token", "ImplicitGrantAuth", redirectUri, serverUri, scope, state)
|
||||||
{
|
{
|
||||||
ClientId = clientId;
|
ClientId = clientId;
|
||||||
@ -26,17 +17,17 @@ namespace SpotifyAPI.Web.Auth
|
|||||||
|
|
||||||
protected override void AdaptWebServer(WebServer webServer)
|
protected override void AdaptWebServer(WebServer webServer)
|
||||||
{
|
{
|
||||||
webServer.Module<WebApiModule>().RegisterController<ImplictGrantAuthController>();
|
webServer.Module<WebApiModule>().RegisterController<ImplicitGrantAuthController>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ImplictGrantAuthController : WebApiController
|
public class ImplicitGrantAuthController : WebApiController
|
||||||
{
|
{
|
||||||
[WebApiHandler(HttpVerbs.Get, "/auth")]
|
[WebApiHandler(HttpVerbs.Get, "/auth")]
|
||||||
public Task<bool> GetAuth()
|
public Task<bool> GetAuth()
|
||||||
{
|
{
|
||||||
string state = Request.QueryString["state"];
|
string state = Request.QueryString["state"];
|
||||||
SpotifyAuthServer<Token> auth = ImplictGrantAuth.GetByState(state);
|
SpotifyAuthServer<Token> auth = ImplicitGrantAuth.GetByState(state);
|
||||||
if (auth == null)
|
if (auth == null)
|
||||||
return this.StringResponseAsync(
|
return this.StringResponseAsync(
|
||||||
$"Failed - Unable to find auth request with state \"{state}\" - Please retry");
|
$"Failed - Unable to find auth request with state \"{state}\" - Please retry");
|
||||||
@ -57,7 +48,7 @@ namespace SpotifyAPI.Web.Auth
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
token = new Token()
|
token = new Token
|
||||||
{
|
{
|
||||||
Error = error
|
Error = error
|
||||||
};
|
};
|
||||||
@ -67,7 +58,7 @@ namespace SpotifyAPI.Web.Auth
|
|||||||
return this.StringResponseAsync("OK - This window can be closed now");
|
return this.StringResponseAsync("OK - This window can be closed now");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImplictGrantAuthController(IHttpContext context) : base(context)
|
public ImplicitGrantAuthController(IHttpContext context) : base(context)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,7 +6,6 @@ using System.Text;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using SpotifyAPI.Web.Enums;
|
using SpotifyAPI.Web.Enums;
|
||||||
using Unosquare.Labs.EmbedIO;
|
using Unosquare.Labs.EmbedIO;
|
||||||
using Unosquare.Labs.EmbedIO.Constants;
|
|
||||||
using Unosquare.Labs.EmbedIO.Modules;
|
using Unosquare.Labs.EmbedIO.Modules;
|
||||||
|
|
||||||
namespace SpotifyAPI.Web.Auth
|
namespace SpotifyAPI.Web.Auth
|
||||||
|
@ -10,6 +10,7 @@ namespace SpotifyAPI.Web.Example
|
|||||||
private static string _clientId = ""; //"";
|
private static string _clientId = ""; //"";
|
||||||
private static string _secretId = ""; //"";
|
private static string _secretId = ""; //"";
|
||||||
|
|
||||||
|
// ReSharper disable once UnusedParameter.Local
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
_clientId = string.IsNullOrEmpty(_clientId)
|
_clientId = string.IsNullOrEmpty(_clientId)
|
||||||
|
@ -21,7 +21,7 @@ namespace SpotifyAPI.Web.Tests
|
|||||||
public void SetUp()
|
public void SetUp()
|
||||||
{
|
{
|
||||||
_mock = new Mock<IClient>();
|
_mock = new Mock<IClient>();
|
||||||
_spotify = new SpotifyWebAPI()
|
_spotify = new SpotifyWebAPI
|
||||||
{
|
{
|
||||||
WebClient = _mock.Object,
|
WebClient = _mock.Object,
|
||||||
UseAuth = false
|
UseAuth = false
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using SpotifyAPI.Web.Enums;
|
|
||||||
using System;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
||||||
namespace SpotifyAPI.Web.Models
|
namespace SpotifyAPI.Web.Models
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace SpotifyAPI.Web.Models
|
namespace SpotifyAPI.Web.Models
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace SpotifyAPI.Web.Models
|
namespace SpotifyAPI.Web.Models
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace SpotifyAPI.Web.Models
|
namespace SpotifyAPI.Web.Models
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace SpotifyAPI.Web.Models
|
namespace SpotifyAPI.Web.Models
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace SpotifyAPI.Web.Models
|
namespace SpotifyAPI.Web.Models
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace SpotifyAPI.Web.Models
|
namespace SpotifyAPI.Web.Models
|
||||||
@ -7,7 +6,7 @@ namespace SpotifyAPI.Web.Models
|
|||||||
public class FullPlaylist : BasicModel
|
public class FullPlaylist : BasicModel
|
||||||
{
|
{
|
||||||
[JsonProperty("collaborative")]
|
[JsonProperty("collaborative")]
|
||||||
public Boolean Collaborative { get; set; }
|
public bool Collaborative { get; set; }
|
||||||
|
|
||||||
[JsonProperty("description")]
|
[JsonProperty("description")]
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
@ -34,7 +33,7 @@ namespace SpotifyAPI.Web.Models
|
|||||||
public PublicProfile Owner { get; set; }
|
public PublicProfile Owner { get; set; }
|
||||||
|
|
||||||
[JsonProperty("public")]
|
[JsonProperty("public")]
|
||||||
public Boolean Public { get; set; }
|
public bool Public { get; set; }
|
||||||
|
|
||||||
[JsonProperty("snapshot_id")]
|
[JsonProperty("snapshot_id")]
|
||||||
public string SnapshotId { get; set; }
|
public string SnapshotId { get; set; }
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace SpotifyAPI.Web.Models
|
namespace SpotifyAPI.Web.Models
|
||||||
@ -22,7 +21,7 @@ namespace SpotifyAPI.Web.Models
|
|||||||
public int DurationMs { get; set; }
|
public int DurationMs { get; set; }
|
||||||
|
|
||||||
[JsonProperty("explicit")]
|
[JsonProperty("explicit")]
|
||||||
public Boolean Explicit { get; set; }
|
public bool Explicit { get; set; }
|
||||||
|
|
||||||
[JsonProperty("external_ids")]
|
[JsonProperty("external_ids")]
|
||||||
public Dictionary<string, string> ExternalIds { get; set; }
|
public Dictionary<string, string> ExternalIds { get; set; }
|
||||||
@ -61,7 +60,7 @@ namespace SpotifyAPI.Web.Models
|
|||||||
/// Only filled when the "market"-parameter was supplied!
|
/// Only filled when the "market"-parameter was supplied!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("is_playable")]
|
[JsonProperty("is_playable")]
|
||||||
public Boolean? IsPlayable { get; set; }
|
public bool? IsPlayable { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Only filled when the "market"-parameter was supplied!
|
/// Only filled when the "market"-parameter was supplied!
|
||||||
|
@ -60,7 +60,7 @@ namespace SpotifyAPI.Web.Models
|
|||||||
public FullTrack Track { get; set; }
|
public FullTrack Track { get; set; }
|
||||||
|
|
||||||
[JsonProperty("is_local")]
|
[JsonProperty("is_local")]
|
||||||
public Boolean IsLocal { get; set; }
|
public bool IsLocal { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DeleteTrackUri
|
public class DeleteTrackUri
|
||||||
@ -84,7 +84,7 @@ namespace SpotifyAPI.Web.Models
|
|||||||
|
|
||||||
public bool ShouldSerializePositions()
|
public bool ShouldSerializePositions()
|
||||||
{
|
{
|
||||||
return (Positions.Count > 0);
|
return Positions.Count > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace SpotifyAPI.Web.Models
|
namespace SpotifyAPI.Web.Models
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
using SpotifyAPI.Web.Enums;
|
using SpotifyAPI.Web.Enums;
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace SpotifyAPI.Web.Models
|
namespace SpotifyAPI.Web.Models
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace SpotifyAPI.Web.Models
|
namespace SpotifyAPI.Web.Models
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System.Collections;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace SpotifyAPI.Web.Models
|
namespace SpotifyAPI.Web.Models
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using SpotifyAPI.Web.Enums;
|
using System.Net;
|
||||||
using System.Net;
|
|
||||||
|
|
||||||
namespace SpotifyAPI.Web.Models
|
namespace SpotifyAPI.Web.Models
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace SpotifyAPI.Web.Models
|
namespace SpotifyAPI.Web.Models
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace SpotifyAPI.Web.Models
|
namespace SpotifyAPI.Web.Models
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace SpotifyAPI.Web.Models
|
namespace SpotifyAPI.Web.Models
|
||||||
@ -7,7 +6,7 @@ namespace SpotifyAPI.Web.Models
|
|||||||
public class SimplePlaylist : BasicModel
|
public class SimplePlaylist : BasicModel
|
||||||
{
|
{
|
||||||
[JsonProperty("collaborative")]
|
[JsonProperty("collaborative")]
|
||||||
public Boolean Collaborative { get; set; }
|
public bool Collaborative { get; set; }
|
||||||
|
|
||||||
[JsonProperty("external_urls")]
|
[JsonProperty("external_urls")]
|
||||||
public Dictionary<string, string> ExternalUrls { get; set; }
|
public Dictionary<string, string> ExternalUrls { get; set; }
|
||||||
@ -28,7 +27,7 @@ namespace SpotifyAPI.Web.Models
|
|||||||
public PublicProfile Owner { get; set; }
|
public PublicProfile Owner { get; set; }
|
||||||
|
|
||||||
[JsonProperty("public")]
|
[JsonProperty("public")]
|
||||||
public Boolean Public { get; set; }
|
public bool Public { get; set; }
|
||||||
|
|
||||||
[JsonProperty("snapshot_id")]
|
[JsonProperty("snapshot_id")]
|
||||||
public string SnapshotId { get; set; }
|
public string SnapshotId { get; set; }
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace SpotifyAPI.Web.Models
|
namespace SpotifyAPI.Web.Models
|
||||||
@ -19,7 +18,7 @@ namespace SpotifyAPI.Web.Models
|
|||||||
public int DurationMs { get; set; }
|
public int DurationMs { get; set; }
|
||||||
|
|
||||||
[JsonProperty("explicit")]
|
[JsonProperty("explicit")]
|
||||||
public Boolean Explicit { get; set; }
|
public bool Explicit { get; set; }
|
||||||
|
|
||||||
[JsonProperty("external_urls")]
|
[JsonProperty("external_urls")]
|
||||||
public Dictionary<string, string> ExternUrls { get; set; }
|
public Dictionary<string, string> ExternUrls { get; set; }
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace SpotifyAPI.Web.Models
|
namespace SpotifyAPI.Web.Models
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace SpotifyAPI.Web.Models
|
namespace SpotifyAPI.Web.Models
|
||||||
{
|
{
|
||||||
@ -61,10 +57,9 @@ namespace SpotifyAPI.Web.Models
|
|||||||
string name = info.GetCustomAttribute<StringAttribute>()?.Text;
|
string name = info.GetCustomAttribute<StringAttribute>()?.Text;
|
||||||
if(name == null || value == null)
|
if(name == null || value == null)
|
||||||
continue;
|
continue;
|
||||||
if (value is float)
|
urlParams.Add(value is float valueAsFloat
|
||||||
urlParams.Add($"{prefix}_{name}={((float)value).ToString(CultureInfo.InvariantCulture)}");
|
? $"{prefix}_{name}={valueAsFloat.ToString(CultureInfo.InvariantCulture)}"
|
||||||
else
|
: $"{prefix}_{name}={value}");
|
||||||
urlParams.Add($"{prefix}_{name}={value}");
|
|
||||||
}
|
}
|
||||||
if (urlParams.Count > 0)
|
if (urlParams.Count > 0)
|
||||||
return "&" + string.Join("&", urlParams);
|
return "&" + string.Join("&", urlParams);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
||||||
namespace SpotifyAPI
|
namespace SpotifyAPI.Web
|
||||||
{
|
{
|
||||||
public class ProxyConfig
|
public class ProxyConfig
|
||||||
{
|
{
|
||||||
@ -65,11 +65,11 @@ namespace SpotifyAPI
|
|||||||
BypassProxyOnLocal = BypassProxyOnLocal
|
BypassProxyOnLocal = BypassProxyOnLocal
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password))
|
if (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password))
|
||||||
{
|
return proxy;
|
||||||
proxy.UseDefaultCredentials = false;
|
|
||||||
proxy.Credentials = new NetworkCredential(Username, Password);
|
proxy.UseDefaultCredentials = false;
|
||||||
}
|
proxy.Credentials = new NetworkCredential(Username, Password);
|
||||||
|
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
@ -647,8 +647,8 @@ namespace SpotifyAPI.Web
|
|||||||
{
|
{
|
||||||
{"ids", new JArray(ids)}
|
{"ids", new JArray(ids)}
|
||||||
};
|
};
|
||||||
return (await UploadDataAsync<ErrorResponse>(_builder.Follow(followType),
|
return await UploadDataAsync<ErrorResponse>(_builder.Follow(followType),
|
||||||
ob.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse();
|
ob.ToString(Formatting.None), "PUT").ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -704,7 +704,7 @@ namespace SpotifyAPI.Web
|
|||||||
{
|
{
|
||||||
{"ids", new JArray(ids)}
|
{"ids", new JArray(ids)}
|
||||||
};
|
};
|
||||||
return (await UploadDataAsync<ErrorResponse>(_builder.Unfollow(followType), ob.ToString(Formatting.None), "DELETE").ConfigureAwait(false)) ?? new ErrorResponse();
|
return await UploadDataAsync<ErrorResponse>(_builder.Unfollow(followType), ob.ToString(Formatting.None), "DELETE").ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -743,7 +743,7 @@ namespace SpotifyAPI.Web
|
|||||||
if (!UseAuth)
|
if (!UseAuth)
|
||||||
throw new InvalidOperationException("Auth is required for IsFollowing");
|
throw new InvalidOperationException("Auth is required for IsFollowing");
|
||||||
|
|
||||||
var url = _builder.IsFollowing(followType, ids);
|
string url = _builder.IsFollowing(followType, ids);
|
||||||
return DownloadList<bool>(url);
|
return DownloadList<bool>(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -761,7 +761,7 @@ namespace SpotifyAPI.Web
|
|||||||
if (!UseAuth)
|
if (!UseAuth)
|
||||||
throw new InvalidOperationException("Auth is required for IsFollowing");
|
throw new InvalidOperationException("Auth is required for IsFollowing");
|
||||||
|
|
||||||
var url = _builder.IsFollowing(followType, ids);
|
string url = _builder.IsFollowing(followType, ids);
|
||||||
return DownloadListAsync<bool>(url);
|
return DownloadListAsync<bool>(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -872,7 +872,7 @@ namespace SpotifyAPI.Web
|
|||||||
if (!UseAuth)
|
if (!UseAuth)
|
||||||
throw new InvalidOperationException("Auth is required for IsFollowingPlaylist");
|
throw new InvalidOperationException("Auth is required for IsFollowingPlaylist");
|
||||||
|
|
||||||
var url = _builder.IsFollowingPlaylist(ownerId, playlistId, ids);
|
string url = _builder.IsFollowingPlaylist(ownerId, playlistId, ids);
|
||||||
return DownloadList<bool>(url);
|
return DownloadList<bool>(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -889,7 +889,7 @@ namespace SpotifyAPI.Web
|
|||||||
if (!UseAuth)
|
if (!UseAuth)
|
||||||
throw new InvalidOperationException("Auth is required for IsFollowingPlaylist");
|
throw new InvalidOperationException("Auth is required for IsFollowingPlaylist");
|
||||||
|
|
||||||
var url = _builder.IsFollowingPlaylist(ownerId, playlistId, ids);
|
string url = _builder.IsFollowingPlaylist(ownerId, playlistId, ids);
|
||||||
return DownloadListAsync<bool>(url);
|
return DownloadListAsync<bool>(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -944,7 +944,7 @@ namespace SpotifyAPI.Web
|
|||||||
public async Task<ErrorResponse> SaveTracksAsync(List<string> ids)
|
public async Task<ErrorResponse> SaveTracksAsync(List<string> ids)
|
||||||
{
|
{
|
||||||
JArray array = new JArray(ids);
|
JArray array = new JArray(ids);
|
||||||
return (await UploadDataAsync<ErrorResponse>(_builder.SaveTracks(), array.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse();
|
return await UploadDataAsync<ErrorResponse>(_builder.SaveTracks(), array.ToString(Formatting.None), "PUT").ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1020,7 +1020,7 @@ namespace SpotifyAPI.Web
|
|||||||
public async Task<ErrorResponse> RemoveSavedTracksAsync(List<string> ids)
|
public async Task<ErrorResponse> RemoveSavedTracksAsync(List<string> ids)
|
||||||
{
|
{
|
||||||
JArray array = new JArray(ids);
|
JArray array = new JArray(ids);
|
||||||
return (await UploadDataAsync<ErrorResponse>(_builder.RemoveSavedTracks(), array.ToString(Formatting.None), "DELETE").ConfigureAwait(false)) ?? new ErrorResponse();
|
return await UploadDataAsync<ErrorResponse>(_builder.RemoveSavedTracks(), array.ToString(Formatting.None), "DELETE").ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1034,7 +1034,7 @@ namespace SpotifyAPI.Web
|
|||||||
if (!UseAuth)
|
if (!UseAuth)
|
||||||
throw new InvalidOperationException("Auth is required for CheckSavedTracks");
|
throw new InvalidOperationException("Auth is required for CheckSavedTracks");
|
||||||
|
|
||||||
var url = _builder.CheckSavedTracks(ids);
|
string url = _builder.CheckSavedTracks(ids);
|
||||||
return DownloadList<bool>(url);
|
return DownloadList<bool>(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1048,7 +1048,7 @@ namespace SpotifyAPI.Web
|
|||||||
{
|
{
|
||||||
if (!UseAuth)
|
if (!UseAuth)
|
||||||
throw new InvalidOperationException("Auth is required for CheckSavedTracks");
|
throw new InvalidOperationException("Auth is required for CheckSavedTracks");
|
||||||
var url = _builder.CheckSavedTracks(ids);
|
string url = _builder.CheckSavedTracks(ids);
|
||||||
return DownloadListAsync<bool>(url);
|
return DownloadListAsync<bool>(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1073,7 +1073,7 @@ namespace SpotifyAPI.Web
|
|||||||
public async Task<ErrorResponse> SaveAlbumsAsync(List<string> ids)
|
public async Task<ErrorResponse> SaveAlbumsAsync(List<string> ids)
|
||||||
{
|
{
|
||||||
JArray array = new JArray(ids);
|
JArray array = new JArray(ids);
|
||||||
return (await UploadDataAsync<ErrorResponse>(_builder.SaveAlbums(), array.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse();
|
return await UploadDataAsync<ErrorResponse>(_builder.SaveAlbums(), array.ToString(Formatting.None), "PUT").ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1149,7 +1149,7 @@ namespace SpotifyAPI.Web
|
|||||||
public async Task<ErrorResponse> RemoveSavedAlbumsAsync(List<string> ids)
|
public async Task<ErrorResponse> RemoveSavedAlbumsAsync(List<string> ids)
|
||||||
{
|
{
|
||||||
JArray array = new JArray(ids);
|
JArray array = new JArray(ids);
|
||||||
return (await UploadDataAsync<ErrorResponse>(_builder.RemoveSavedAlbums(), array.ToString(Formatting.None), "DELETE").ConfigureAwait(false)) ?? new ErrorResponse();
|
return await UploadDataAsync<ErrorResponse>(_builder.RemoveSavedAlbums(), array.ToString(Formatting.None), "DELETE").ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1163,7 +1163,7 @@ namespace SpotifyAPI.Web
|
|||||||
if (!UseAuth)
|
if (!UseAuth)
|
||||||
throw new InvalidOperationException("Auth is required for CheckSavedTracks");
|
throw new InvalidOperationException("Auth is required for CheckSavedTracks");
|
||||||
|
|
||||||
var url = _builder.CheckSavedAlbums(ids);
|
string url = _builder.CheckSavedAlbums(ids);
|
||||||
return DownloadList<bool>(url);
|
return DownloadList<bool>(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1177,7 +1177,7 @@ namespace SpotifyAPI.Web
|
|||||||
{
|
{
|
||||||
if (!UseAuth)
|
if (!UseAuth)
|
||||||
throw new InvalidOperationException("Auth is required for CheckSavedAlbumsAsync");
|
throw new InvalidOperationException("Auth is required for CheckSavedAlbumsAsync");
|
||||||
var url = _builder.CheckSavedAlbums(ids);
|
string url = _builder.CheckSavedAlbums(ids);
|
||||||
return DownloadListAsync<bool>(url);
|
return DownloadListAsync<bool>(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1601,7 +1601,7 @@ namespace SpotifyAPI.Web
|
|||||||
body.Add("collaborative", newCollaborative);
|
body.Add("collaborative", newCollaborative);
|
||||||
if (newDescription != null)
|
if (newDescription != null)
|
||||||
body.Add("description", newDescription);
|
body.Add("description", newDescription);
|
||||||
return (await UploadDataAsync<ErrorResponse>(_builder.UpdatePlaylist(userId, playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse();
|
return await UploadDataAsync<ErrorResponse>(_builder.UpdatePlaylist(userId, playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1625,7 +1625,7 @@ namespace SpotifyAPI.Web
|
|||||||
body.Add("collaborative", newCollaborative);
|
body.Add("collaborative", newCollaborative);
|
||||||
if (newDescription != null)
|
if (newDescription != null)
|
||||||
body.Add("description", newDescription);
|
body.Add("description", newDescription);
|
||||||
return (await UploadDataAsync<ErrorResponse>(_builder.UpdatePlaylist(playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse();
|
return await UploadDataAsync<ErrorResponse>(_builder.UpdatePlaylist(playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1651,7 +1651,7 @@ namespace SpotifyAPI.Web
|
|||||||
/// <remarks>AUTH NEEDED</remarks>
|
/// <remarks>AUTH NEEDED</remarks>
|
||||||
public async Task<ErrorResponse> UploadPlaylistImageAsync(string userId, string playlistId, string base64EncodedJpgImage)
|
public async Task<ErrorResponse> UploadPlaylistImageAsync(string userId, string playlistId, string base64EncodedJpgImage)
|
||||||
{
|
{
|
||||||
return (await UploadDataAsync<ErrorResponse>(_builder.UploadPlaylistImage(userId, playlistId), base64EncodedJpgImage, "PUT").ConfigureAwait(false)) ?? new ErrorResponse();
|
return await UploadDataAsync<ErrorResponse>(_builder.UploadPlaylistImage(userId, playlistId), base64EncodedJpgImage, "PUT").ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1675,8 +1675,8 @@ namespace SpotifyAPI.Web
|
|||||||
/// <remarks>AUTH NEEDED</remarks>
|
/// <remarks>AUTH NEEDED</remarks>
|
||||||
public async Task<ErrorResponse> UploadPlaylistImageAsync(string playlistId, string base64EncodedJpgImage)
|
public async Task<ErrorResponse> UploadPlaylistImageAsync(string playlistId, string base64EncodedJpgImage)
|
||||||
{
|
{
|
||||||
return (await UploadDataAsync<ErrorResponse>(_builder.UploadPlaylistImage(playlistId),
|
return await UploadDataAsync<ErrorResponse>(_builder.UploadPlaylistImage(playlistId),
|
||||||
base64EncodedJpgImage, "PUT").ConfigureAwait(false)) ?? new ErrorResponse();
|
base64EncodedJpgImage, "PUT").ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1731,7 +1731,7 @@ namespace SpotifyAPI.Web
|
|||||||
{
|
{
|
||||||
{"uris", new JArray(uris.Take(100))}
|
{"uris", new JArray(uris.Take(100))}
|
||||||
};
|
};
|
||||||
return await (UploadDataAsync<ErrorResponse>(_builder.ReplacePlaylistTracks(userId, playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse();
|
return await UploadDataAsync<ErrorResponse>(_builder.ReplacePlaylistTracks(userId, playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1748,7 +1748,7 @@ namespace SpotifyAPI.Web
|
|||||||
{
|
{
|
||||||
{"uris", new JArray(uris.Take(100))}
|
{"uris", new JArray(uris.Take(100))}
|
||||||
};
|
};
|
||||||
return await (UploadDataAsync<ErrorResponse>(_builder.ReplacePlaylistTracks(playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse();
|
return await UploadDataAsync<ErrorResponse>(_builder.ReplacePlaylistTracks(playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1809,7 +1809,7 @@ namespace SpotifyAPI.Web
|
|||||||
{
|
{
|
||||||
{"tracks", JArray.FromObject(uris.Take(100))}
|
{"tracks", JArray.FromObject(uris.Take(100))}
|
||||||
};
|
};
|
||||||
return await (UploadDataAsync<ErrorResponse>(_builder.RemovePlaylistTracks(userId, playlistId, uris), body.ToString(Formatting.None), "DELETE").ConfigureAwait(false)) ?? new ErrorResponse();
|
return await UploadDataAsync<ErrorResponse>(_builder.RemovePlaylistTracks(userId, playlistId, uris), body.ToString(Formatting.None), "DELETE").ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1828,7 +1828,7 @@ namespace SpotifyAPI.Web
|
|||||||
{
|
{
|
||||||
{"tracks", JArray.FromObject(uris.Take(100))}
|
{"tracks", JArray.FromObject(uris.Take(100))}
|
||||||
};
|
};
|
||||||
return await (UploadDataAsync<ErrorResponse>(_builder.RemovePlaylistTracks(playlistId, uris), body.ToString(Formatting.None), "DELETE").ConfigureAwait(false)) ?? new ErrorResponse();
|
return await UploadDataAsync<ErrorResponse>(_builder.RemovePlaylistTracks(playlistId, uris), body.ToString(Formatting.None), "DELETE").ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1935,7 +1935,7 @@ namespace SpotifyAPI.Web
|
|||||||
{
|
{
|
||||||
{"uris", JArray.FromObject(uris.Take(100))}
|
{"uris", JArray.FromObject(uris.Take(100))}
|
||||||
};
|
};
|
||||||
return await (UploadDataAsync<ErrorResponse>(_builder.AddPlaylistTracks(userId, playlistId, uris, position), body.ToString(Formatting.None)).ConfigureAwait(false)) ?? new ErrorResponse();
|
return await UploadDataAsync<ErrorResponse>(_builder.AddPlaylistTracks(userId, playlistId, uris, position), body.ToString(Formatting.None)).ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1952,7 +1952,7 @@ namespace SpotifyAPI.Web
|
|||||||
{
|
{
|
||||||
{"uris", JArray.FromObject(uris.Take(100))}
|
{"uris", JArray.FromObject(uris.Take(100))}
|
||||||
};
|
};
|
||||||
return await (UploadDataAsync<ErrorResponse>(_builder.AddPlaylistTracks(playlistId, uris, position), body.ToString(Formatting.None)).ConfigureAwait(false)) ?? new ErrorResponse();
|
return await UploadDataAsync<ErrorResponse>(_builder.AddPlaylistTracks(playlistId, uris, position), body.ToString(Formatting.None)).ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -2370,7 +2370,7 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public ErrorResponse TransferPlayback(List<string> deviceIds, bool play = false)
|
public ErrorResponse TransferPlayback(List<string> deviceIds, bool play = false)
|
||||||
{
|
{
|
||||||
JObject ob = new JObject()
|
JObject ob = new JObject
|
||||||
{
|
{
|
||||||
{ "play", play },
|
{ "play", play },
|
||||||
{ "device_ids", new JArray(deviceIds) }
|
{ "device_ids", new JArray(deviceIds) }
|
||||||
@ -2390,7 +2390,7 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Task<ErrorResponse> TransferPlaybackAsync(List<string> deviceIds, bool play = false)
|
public Task<ErrorResponse> TransferPlaybackAsync(List<string> deviceIds, bool play = false)
|
||||||
{
|
{
|
||||||
JObject ob = new JObject()
|
JObject ob = new JObject
|
||||||
{
|
{
|
||||||
{ "play", play },
|
{ "play", play },
|
||||||
{ "device_ids", new JArray(deviceIds) }
|
{ "device_ids", new JArray(deviceIds) }
|
||||||
@ -2405,8 +2405,8 @@ namespace SpotifyAPI.Web
|
|||||||
/// <param name="contextUri">Spotify URI of the context to play.</param>
|
/// <param name="contextUri">Spotify URI of the context to play.</param>
|
||||||
/// <param name="uris">A JSON array of the Spotify track URIs to play.</param>
|
/// <param name="uris">A JSON array of the Spotify track URIs to play.</param>
|
||||||
/// <param name="offset">Indicates from where in the context playback should start.
|
/// <param name="offset">Indicates from where in the context playback should start.
|
||||||
/// <param name="positionMs">The starting time to seek the track to</param>
|
|
||||||
/// Only available when context_uri corresponds to an album or playlist object, or when the uris parameter is used.</param>
|
/// Only available when context_uri corresponds to an album or playlist object, or when the uris parameter is used.</param>
|
||||||
|
/// <param name="positionMs">The starting time to seek the track to</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public ErrorResponse ResumePlayback(string deviceId = "", string contextUri = "", List<string> uris = null,
|
public ErrorResponse ResumePlayback(string deviceId = "", string contextUri = "", List<string> uris = null,
|
||||||
int? offset = null, int positionMs = 0)
|
int? offset = null, int positionMs = 0)
|
||||||
@ -2430,8 +2430,8 @@ namespace SpotifyAPI.Web
|
|||||||
/// <param name="contextUri">Spotify URI of the context to play.</param>
|
/// <param name="contextUri">Spotify URI of the context to play.</param>
|
||||||
/// <param name="uris">A JSON array of the Spotify track URIs to play.</param>
|
/// <param name="uris">A JSON array of the Spotify track URIs to play.</param>
|
||||||
/// <param name="offset">Indicates from where in the context playback should start.
|
/// <param name="offset">Indicates from where in the context playback should start.
|
||||||
/// <param name="positionMs">The starting time to seek the track to</param>
|
|
||||||
/// Only available when context_uri corresponds to an album or playlist object, or when the uris parameter is used.</param>
|
/// Only available when context_uri corresponds to an album or playlist object, or when the uris parameter is used.</param>
|
||||||
|
/// <param name="positionMs">The starting time to seek the track to</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Task<ErrorResponse> ResumePlaybackAsync(string deviceId = "", string contextUri = "", List<string> uris = null,
|
public Task<ErrorResponse> ResumePlaybackAsync(string deviceId = "", string contextUri = "", List<string> uris = null,
|
||||||
int? offset = null, int positionMs = 0)
|
int? offset = null, int positionMs = 0)
|
||||||
@ -2455,8 +2455,8 @@ namespace SpotifyAPI.Web
|
|||||||
/// <param name="contextUri">Spotify URI of the context to play.</param>
|
/// <param name="contextUri">Spotify URI of the context to play.</param>
|
||||||
/// <param name="uris">A JSON array of the Spotify track URIs to play.</param>
|
/// <param name="uris">A JSON array of the Spotify track URIs to play.</param>
|
||||||
/// <param name="offset">Indicates from where in the context playback should start.
|
/// <param name="offset">Indicates from where in the context playback should start.
|
||||||
/// <param name="positionMs">The starting time to seek the track to</param>
|
|
||||||
/// Only available when context_uri corresponds to an album or playlist object, or when the uris parameter is used.</param>
|
/// Only available when context_uri corresponds to an album or playlist object, or when the uris parameter is used.</param>
|
||||||
|
/// <param name="positionMs">The starting time to seek the track to</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public ErrorResponse ResumePlayback(string deviceId = "", string contextUri = "", List<string> uris = null,
|
public ErrorResponse ResumePlayback(string deviceId = "", string contextUri = "", List<string> uris = null,
|
||||||
string offset = "", int positionMs = 0)
|
string offset = "", int positionMs = 0)
|
||||||
@ -2480,8 +2480,8 @@ namespace SpotifyAPI.Web
|
|||||||
/// <param name="contextUri">Spotify URI of the context to play.</param>
|
/// <param name="contextUri">Spotify URI of the context to play.</param>
|
||||||
/// <param name="uris">A JSON array of the Spotify track URIs to play.</param>
|
/// <param name="uris">A JSON array of the Spotify track URIs to play.</param>
|
||||||
/// <param name="offset">Indicates from where in the context playback should start.
|
/// <param name="offset">Indicates from where in the context playback should start.
|
||||||
/// <param name="positionMs">The starting time to seek the track to</param>
|
|
||||||
/// Only available when context_uri corresponds to an album or playlist object, or when the uris parameter is used.</param>
|
/// Only available when context_uri corresponds to an album or playlist object, or when the uris parameter is used.</param>
|
||||||
|
/// <param name="positionMs">The starting time to seek the track to</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Task<ErrorResponse> ResumePlaybackAsync(string deviceId = "", string contextUri = "", List<string> uris = null,
|
public Task<ErrorResponse> ResumePlaybackAsync(string deviceId = "", string contextUri = "", List<string> uris = null,
|
||||||
string offset = "", int positionMs = 0)
|
string offset = "", int positionMs = 0)
|
||||||
@ -2862,7 +2862,7 @@ namespace SpotifyAPI.Web
|
|||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!int.TryParse(info.Headers.Get("Retry-After"), out var secondsToWait))
|
if (!int.TryParse(info.Headers.Get("Retry-After"), out int secondsToWait))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -2880,7 +2880,7 @@ namespace SpotifyAPI.Web
|
|||||||
if (response != null)
|
if (response != null)
|
||||||
{
|
{
|
||||||
int msToWait = RetryAfter;
|
int msToWait = RetryAfter;
|
||||||
var secondsToWait = GetTooManyRequests(response.Item1);
|
int secondsToWait = GetTooManyRequests(response.Item1);
|
||||||
if (secondsToWait > 0)
|
if (secondsToWait > 0)
|
||||||
{
|
{
|
||||||
msToWait = secondsToWait * 1000;
|
msToWait = secondsToWait * 1000;
|
||||||
@ -2900,7 +2900,7 @@ namespace SpotifyAPI.Web
|
|||||||
} while (UseAutoRetry
|
} while (UseAutoRetry
|
||||||
&& triesLeft > 0
|
&& triesLeft > 0
|
||||||
&& (GetTooManyRequests(response.Item1) != -1
|
&& (GetTooManyRequests(response.Item1) != -1
|
||||||
|| (lastError != null && RetryErrorCodes.Contains(lastError.Status))));
|
|| lastError != null && RetryErrorCodes.Contains(lastError.Status)));
|
||||||
|
|
||||||
|
|
||||||
return response.Item2;
|
return response.Item2;
|
||||||
|
@ -70,9 +70,7 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string GetAlbum(string id, string market = "")
|
public string GetAlbum(string id, string market = "")
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(market))
|
return string.IsNullOrEmpty(market) ? $"{APIBase}/albums/{id}" : $"{APIBase}/albums/{id}?market={market}";
|
||||||
return $"{APIBase}/albums/{id}";
|
|
||||||
return $"{APIBase}/albums/{id}?market={market}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -83,9 +81,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string GetSeveralAlbums(List<string> ids, string market = "")
|
public string GetSeveralAlbums(List<string> ids, string market = "")
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(market))
|
return string.IsNullOrEmpty(market)
|
||||||
return $"{APIBase}/albums?ids={string.Join(",", ids.Take(20))}";
|
? $"{APIBase}/albums?ids={string.Join(",", ids.Take(20))}"
|
||||||
return $"{APIBase}/albums?market={market}&ids={string.Join(",", ids.Take(20))}";
|
: $"{APIBase}/albums?market={market}&ids={string.Join(",", ids.Take(20))}";
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Albums
|
#endregion Albums
|
||||||
@ -734,7 +732,7 @@ namespace SpotifyAPI.Web
|
|||||||
/// </param>
|
/// </param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <remarks>AUTH NEEDED</remarks>
|
/// <remarks>AUTH NEEDED</remarks>
|
||||||
public string CreatePlaylist(string userId, string playlistName, Boolean isPublic = true)
|
public string CreatePlaylist(string userId, string playlistName, bool isPublic = true)
|
||||||
{
|
{
|
||||||
return $"{APIBase}/users/{userId}/playlists";
|
return $"{APIBase}/users/{userId}/playlists";
|
||||||
}
|
}
|
||||||
@ -829,9 +827,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <remarks>AUTH NEEDED</remarks>
|
/// <remarks>AUTH NEEDED</remarks>
|
||||||
public string AddPlaylistTracks(string userId, string playlistId, List<string> uris, int? position = null)
|
public string AddPlaylistTracks(string userId, string playlistId, List<string> uris, int? position = null)
|
||||||
{
|
{
|
||||||
if (position == null)
|
return position == null
|
||||||
return $"{APIBase}/users/{userId}/playlists/{playlistId}/tracks";
|
? $"{APIBase}/users/{userId}/playlists/{playlistId}/tracks"
|
||||||
return $"{APIBase}/users/{userId}/playlists/{playlistId}/tracks?position={position}";
|
: $"{APIBase}/users/{userId}/playlists/{playlistId}/tracks?position={position}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -844,9 +842,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <remarks>AUTH NEEDED</remarks>
|
/// <remarks>AUTH NEEDED</remarks>
|
||||||
public string AddPlaylistTracks(string playlistId, List<string> uris, int? position = null)
|
public string AddPlaylistTracks(string playlistId, List<string> uris, int? position = null)
|
||||||
{
|
{
|
||||||
if (position == null)
|
return position == null
|
||||||
return $"{APIBase}/playlists/{playlistId}/tracks";
|
? $"{APIBase}/playlists/{playlistId}/tracks"
|
||||||
return $"{APIBase}/playlists/{playlistId}/tracks?position={position}";
|
: $"{APIBase}/playlists/{playlistId}/tracks?position={position}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -931,9 +929,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string GetSeveralTracks(List<string> ids, string market = "")
|
public string GetSeveralTracks(List<string> ids, string market = "")
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(market))
|
return string.IsNullOrEmpty(market)
|
||||||
return $"{APIBase}/tracks?ids={string.Join(",", ids.Take(50))}";
|
? $"{APIBase}/tracks?ids={string.Join(",", ids.Take(50))}"
|
||||||
return $"{APIBase}/tracks?market={market}&ids={string.Join(",", ids.Take(50))}";
|
: $"{APIBase}/tracks?market={market}&ids={string.Join(",", ids.Take(50))}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -944,9 +942,7 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string GetTrack(string id, string market = "")
|
public string GetTrack(string id, string market = "")
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(market))
|
return string.IsNullOrEmpty(market) ? $"{APIBase}/tracks/{id}" : $"{APIBase}/tracks/{id}?market={market}";
|
||||||
return $"{APIBase}/tracks/{id}";
|
|
||||||
return $"{APIBase}/tracks/{id}?market={market}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1002,9 +998,7 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string GetPlayback(string market = "")
|
public string GetPlayback(string market = "")
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(market))
|
return string.IsNullOrEmpty(market) ? $"{APIBase}/me/player" : $"{APIBase}/me/player?market={market}";
|
||||||
return $"{APIBase}/me/player";
|
|
||||||
return $"{APIBase}/me/player?market={market}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1014,9 +1008,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string GetPlayingTrack(string market = "")
|
public string GetPlayingTrack(string market = "")
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(market))
|
return string.IsNullOrEmpty(market)
|
||||||
return $"{APIBase}/me/player/currently-playing";
|
? $"{APIBase}/me/player/currently-playing"
|
||||||
return $"{APIBase}/me/player/currently-playing?market={market}";
|
: $"{APIBase}/me/player/currently-playing?market={market}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1035,9 +1029,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string ResumePlayback(string deviceId = "")
|
public string ResumePlayback(string deviceId = "")
|
||||||
{
|
{
|
||||||
if(string.IsNullOrEmpty(deviceId))
|
return string.IsNullOrEmpty(deviceId)
|
||||||
return $"{APIBase}/me/player/play";
|
? $"{APIBase}/me/player/play"
|
||||||
return $"{APIBase}/me/player/play?device_id={deviceId}";
|
: $"{APIBase}/me/player/play?device_id={deviceId}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1047,9 +1041,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string PausePlayback(string deviceId = "")
|
public string PausePlayback(string deviceId = "")
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(deviceId))
|
return string.IsNullOrEmpty(deviceId)
|
||||||
return $"{APIBase}/me/player/pause";
|
? $"{APIBase}/me/player/pause"
|
||||||
return $"{APIBase}/me/player/pause?device_id={deviceId}";
|
: $"{APIBase}/me/player/pause?device_id={deviceId}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1059,9 +1053,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string SkipPlaybackToNext(string deviceId = "")
|
public string SkipPlaybackToNext(string deviceId = "")
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(deviceId))
|
return string.IsNullOrEmpty(deviceId)
|
||||||
return $"{APIBase}/me/player/next";
|
? $"{APIBase}/me/player/next"
|
||||||
return $"{APIBase}/me/player/next?device_id={deviceId}";
|
: $"{APIBase}/me/player/next?device_id={deviceId}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1073,9 +1067,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string SkipPlaybackToPrevious(string deviceId = "")
|
public string SkipPlaybackToPrevious(string deviceId = "")
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(deviceId))
|
return string.IsNullOrEmpty(deviceId)
|
||||||
return $"{APIBase}/me/player/previous";
|
? $"{APIBase}/me/player/previous"
|
||||||
return $"{APIBase}/me/player/previous?device_id={deviceId}";
|
: $"{APIBase}/me/player/previous?device_id={deviceId}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1087,9 +1081,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string SeekPlayback(int positionMs, string deviceId = "")
|
public string SeekPlayback(int positionMs, string deviceId = "")
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(deviceId))
|
return string.IsNullOrEmpty(deviceId)
|
||||||
return $"{APIBase}/me/player/seek?position_ms={positionMs}";
|
? $"{APIBase}/me/player/seek?position_ms={positionMs}"
|
||||||
return $"{APIBase}/me/player/seek?position_ms={positionMs}&device_id={deviceId}";
|
: $"{APIBase}/me/player/seek?position_ms={positionMs}&device_id={deviceId}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1100,9 +1094,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string SetRepeatMode(RepeatState repeatState, string deviceId = "")
|
public string SetRepeatMode(RepeatState repeatState, string deviceId = "")
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(deviceId))
|
return string.IsNullOrEmpty(deviceId)
|
||||||
return $"{APIBase}/me/player/repeat?state={repeatState.GetStringAttribute()}";
|
? $"{APIBase}/me/player/repeat?state={repeatState.GetStringAttribute()}"
|
||||||
return $"{APIBase}/me/player/repeat?state={repeatState.GetStringAttribute()}&device_id={deviceId}";
|
: $"{APIBase}/me/player/repeat?state={repeatState.GetStringAttribute()}&device_id={deviceId}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1113,9 +1107,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string SetVolume(int volumePercent, string deviceId = "")
|
public string SetVolume(int volumePercent, string deviceId = "")
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(deviceId))
|
return string.IsNullOrEmpty(deviceId)
|
||||||
return $"{APIBase}/me/player/volume?volume_percent={volumePercent}";
|
? $"{APIBase}/me/player/volume?volume_percent={volumePercent}"
|
||||||
return $"{APIBase}/me/player/volume?volume_percent={volumePercent}&device_id={deviceId}";
|
: $"{APIBase}/me/player/volume?volume_percent={volumePercent}&device_id={deviceId}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1126,9 +1120,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string SetShuffle(bool shuffle, string deviceId = "")
|
public string SetShuffle(bool shuffle, string deviceId = "")
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(deviceId))
|
return string.IsNullOrEmpty(deviceId)
|
||||||
return $"{APIBase}/me/player/shuffle?state={shuffle}";
|
? $"{APIBase}/me/player/shuffle?state={shuffle}"
|
||||||
return $"{APIBase}/me/player/shuffle?state={shuffle}&device_id={deviceId}";
|
: $"{APIBase}/me/player/shuffle?state={shuffle}&device_id={deviceId}";
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ using System.Net.Http.Headers;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using SpotifyAPI.Web.Models;
|
using SpotifyAPI.Web.Models;
|
||||||
using SpotifyAPI.Web.Enums;
|
|
||||||
|
|
||||||
namespace SpotifyAPI.Web
|
namespace SpotifyAPI.Web
|
||||||
{
|
{
|
||||||
@ -211,14 +210,12 @@ namespace SpotifyAPI.Web
|
|||||||
UseProxy = false
|
UseProxy = false
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(proxyConfig?.Host))
|
if (string.IsNullOrWhiteSpace(proxyConfig?.Host)) return clientHandler;
|
||||||
{
|
WebProxy proxy = proxyConfig.CreateWebProxy();
|
||||||
WebProxy proxy = proxyConfig.CreateWebProxy();
|
clientHandler.UseProxy = true;
|
||||||
clientHandler.UseProxy = true;
|
clientHandler.Proxy = proxy;
|
||||||
clientHandler.Proxy = proxy;
|
clientHandler.UseDefaultCredentials = proxy.UseDefaultCredentials;
|
||||||
clientHandler.UseDefaultCredentials = proxy.UseDefaultCredentials;
|
clientHandler.PreAuthenticate = proxy.UseDefaultCredentials;
|
||||||
clientHandler.PreAuthenticate = proxy.UseDefaultCredentials;
|
|
||||||
}
|
|
||||||
|
|
||||||
return clientHandler;
|
return clientHandler;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user