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);
|
||||
}
|
||||
else
|
||||
{
|
||||
// throw
|
||||
}
|
||||
#else
|
||||
url = url.Replace("&", "^&");
|
||||
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}"));
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -48,7 +47,7 @@ namespace SpotifyAPI.Web.Auth
|
||||
|
||||
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>("refresh_token", refreshToken)
|
||||
@ -65,7 +64,7 @@ namespace SpotifyAPI.Web.Auth
|
||||
}
|
||||
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>("code", code),
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -25,7 +24,7 @@ namespace SpotifyAPI.Web.Auth
|
||||
{
|
||||
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")
|
||||
};
|
||||
|
@ -1,24 +1,15 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using SpotifyAPI.Web.Enums;
|
||||
using SpotifyAPI.Web.Models;
|
||||
using Unosquare.Labs.EmbedIO;
|
||||
using Unosquare.Labs.EmbedIO.Constants;
|
||||
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
|
||||
{
|
||||
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)
|
||||
{
|
||||
ClientId = clientId;
|
||||
@ -26,17 +17,17 @@ namespace SpotifyAPI.Web.Auth
|
||||
|
||||
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")]
|
||||
public Task<bool> GetAuth()
|
||||
{
|
||||
string state = Request.QueryString["state"];
|
||||
SpotifyAuthServer<Token> auth = ImplictGrantAuth.GetByState(state);
|
||||
SpotifyAuthServer<Token> auth = ImplicitGrantAuth.GetByState(state);
|
||||
if (auth == null)
|
||||
return this.StringResponseAsync(
|
||||
$"Failed - Unable to find auth request with state \"{state}\" - Please retry");
|
||||
@ -57,7 +48,7 @@ namespace SpotifyAPI.Web.Auth
|
||||
}
|
||||
else
|
||||
{
|
||||
token = new Token()
|
||||
token = new Token
|
||||
{
|
||||
Error = error
|
||||
};
|
||||
@ -67,7 +58,7 @@ namespace SpotifyAPI.Web.Auth
|
||||
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 SpotifyAPI.Web.Enums;
|
||||
using Unosquare.Labs.EmbedIO;
|
||||
using Unosquare.Labs.EmbedIO.Constants;
|
||||
using Unosquare.Labs.EmbedIO.Modules;
|
||||
|
||||
namespace SpotifyAPI.Web.Auth
|
||||
|
@ -10,6 +10,7 @@ namespace SpotifyAPI.Web.Example
|
||||
private static string _clientId = ""; //"";
|
||||
private static string _secretId = ""; //"";
|
||||
|
||||
// ReSharper disable once UnusedParameter.Local
|
||||
static void Main(string[] args)
|
||||
{
|
||||
_clientId = string.IsNullOrEmpty(_clientId)
|
||||
|
@ -21,7 +21,7 @@ namespace SpotifyAPI.Web.Tests
|
||||
public void SetUp()
|
||||
{
|
||||
_mock = new Mock<IClient>();
|
||||
_spotify = new SpotifyWebAPI()
|
||||
_spotify = new SpotifyWebAPI
|
||||
{
|
||||
WebClient = _mock.Object,
|
||||
UseAuth = false
|
||||
|
@ -1,6 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using SpotifyAPI.Web.Enums;
|
||||
using System;
|
||||
using System.Net;
|
||||
|
||||
namespace SpotifyAPI.Web.Models
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SpotifyAPI.Web.Models
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SpotifyAPI.Web.Models
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
namespace SpotifyAPI.Web.Models
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SpotifyAPI.Web.Models
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SpotifyAPI.Web.Models
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SpotifyAPI.Web.Models
|
||||
@ -7,7 +6,7 @@ namespace SpotifyAPI.Web.Models
|
||||
public class FullPlaylist : BasicModel
|
||||
{
|
||||
[JsonProperty("collaborative")]
|
||||
public Boolean Collaborative { get; set; }
|
||||
public bool Collaborative { get; set; }
|
||||
|
||||
[JsonProperty("description")]
|
||||
public string Description { get; set; }
|
||||
@ -34,7 +33,7 @@ namespace SpotifyAPI.Web.Models
|
||||
public PublicProfile Owner { get; set; }
|
||||
|
||||
[JsonProperty("public")]
|
||||
public Boolean Public { get; set; }
|
||||
public bool Public { get; set; }
|
||||
|
||||
[JsonProperty("snapshot_id")]
|
||||
public string SnapshotId { get; set; }
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SpotifyAPI.Web.Models
|
||||
@ -22,7 +21,7 @@ namespace SpotifyAPI.Web.Models
|
||||
public int DurationMs { get; set; }
|
||||
|
||||
[JsonProperty("explicit")]
|
||||
public Boolean Explicit { get; set; }
|
||||
public bool Explicit { get; set; }
|
||||
|
||||
[JsonProperty("external_ids")]
|
||||
public Dictionary<string, string> ExternalIds { get; set; }
|
||||
@ -61,7 +60,7 @@ namespace SpotifyAPI.Web.Models
|
||||
/// Only filled when the "market"-parameter was supplied!
|
||||
/// </summary>
|
||||
[JsonProperty("is_playable")]
|
||||
public Boolean? IsPlayable { get; set; }
|
||||
public bool? IsPlayable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Only filled when the "market"-parameter was supplied!
|
||||
|
@ -60,7 +60,7 @@ namespace SpotifyAPI.Web.Models
|
||||
public FullTrack Track { get; set; }
|
||||
|
||||
[JsonProperty("is_local")]
|
||||
public Boolean IsLocal { get; set; }
|
||||
public bool IsLocal { get; set; }
|
||||
}
|
||||
|
||||
public class DeleteTrackUri
|
||||
@ -84,7 +84,7 @@ namespace SpotifyAPI.Web.Models
|
||||
|
||||
public bool ShouldSerializePositions()
|
||||
{
|
||||
return (Positions.Count > 0);
|
||||
return Positions.Count > 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SpotifyAPI.Web.Models
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using SpotifyAPI.Web.Enums;
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SpotifyAPI.Web.Models
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SpotifyAPI.Web.Models
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace SpotifyAPI.Web.Models
|
||||
|
@ -1,5 +1,4 @@
|
||||
using SpotifyAPI.Web.Enums;
|
||||
using System.Net;
|
||||
using System.Net;
|
||||
|
||||
namespace SpotifyAPI.Web.Models
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SpotifyAPI.Web.Models
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SpotifyAPI.Web.Models
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SpotifyAPI.Web.Models
|
||||
@ -7,7 +6,7 @@ namespace SpotifyAPI.Web.Models
|
||||
public class SimplePlaylist : BasicModel
|
||||
{
|
||||
[JsonProperty("collaborative")]
|
||||
public Boolean Collaborative { get; set; }
|
||||
public bool Collaborative { get; set; }
|
||||
|
||||
[JsonProperty("external_urls")]
|
||||
public Dictionary<string, string> ExternalUrls { get; set; }
|
||||
@ -28,7 +27,7 @@ namespace SpotifyAPI.Web.Models
|
||||
public PublicProfile Owner { get; set; }
|
||||
|
||||
[JsonProperty("public")]
|
||||
public Boolean Public { get; set; }
|
||||
public bool Public { get; set; }
|
||||
|
||||
[JsonProperty("snapshot_id")]
|
||||
public string SnapshotId { get; set; }
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SpotifyAPI.Web.Models
|
||||
@ -19,7 +18,7 @@ namespace SpotifyAPI.Web.Models
|
||||
public int DurationMs { get; set; }
|
||||
|
||||
[JsonProperty("explicit")]
|
||||
public Boolean Explicit { get; set; }
|
||||
public bool Explicit { get; set; }
|
||||
|
||||
[JsonProperty("external_urls")]
|
||||
public Dictionary<string, string> ExternUrls { get; set; }
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
namespace SpotifyAPI.Web.Models
|
||||
{
|
||||
|
@ -1,10 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace SpotifyAPI.Web.Models
|
||||
{
|
||||
@ -61,10 +57,9 @@ namespace SpotifyAPI.Web.Models
|
||||
string name = info.GetCustomAttribute<StringAttribute>()?.Text;
|
||||
if(name == null || value == null)
|
||||
continue;
|
||||
if (value is float)
|
||||
urlParams.Add($"{prefix}_{name}={((float)value).ToString(CultureInfo.InvariantCulture)}");
|
||||
else
|
||||
urlParams.Add($"{prefix}_{name}={value}");
|
||||
urlParams.Add(value is float valueAsFloat
|
||||
? $"{prefix}_{name}={valueAsFloat.ToString(CultureInfo.InvariantCulture)}"
|
||||
: $"{prefix}_{name}={value}");
|
||||
}
|
||||
if (urlParams.Count > 0)
|
||||
return "&" + string.Join("&", urlParams);
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
|
||||
namespace SpotifyAPI
|
||||
namespace SpotifyAPI.Web
|
||||
{
|
||||
public class ProxyConfig
|
||||
{
|
||||
@ -65,11 +65,11 @@ namespace SpotifyAPI
|
||||
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);
|
||||
}
|
||||
|
||||
return proxy;
|
||||
}
|
||||
|
@ -647,8 +647,8 @@ namespace SpotifyAPI.Web
|
||||
{
|
||||
{"ids", new JArray(ids)}
|
||||
};
|
||||
return (await UploadDataAsync<ErrorResponse>(_builder.Follow(followType),
|
||||
ob.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse();
|
||||
return await UploadDataAsync<ErrorResponse>(_builder.Follow(followType),
|
||||
ob.ToString(Formatting.None), "PUT").ConfigureAwait(false) ?? new ErrorResponse();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -704,7 +704,7 @@ namespace SpotifyAPI.Web
|
||||
{
|
||||
{"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>
|
||||
@ -743,7 +743,7 @@ namespace SpotifyAPI.Web
|
||||
if (!UseAuth)
|
||||
throw new InvalidOperationException("Auth is required for IsFollowing");
|
||||
|
||||
var url = _builder.IsFollowing(followType, ids);
|
||||
string url = _builder.IsFollowing(followType, ids);
|
||||
return DownloadList<bool>(url);
|
||||
}
|
||||
|
||||
@ -761,7 +761,7 @@ namespace SpotifyAPI.Web
|
||||
if (!UseAuth)
|
||||
throw new InvalidOperationException("Auth is required for IsFollowing");
|
||||
|
||||
var url = _builder.IsFollowing(followType, ids);
|
||||
string url = _builder.IsFollowing(followType, ids);
|
||||
return DownloadListAsync<bool>(url);
|
||||
}
|
||||
|
||||
@ -872,7 +872,7 @@ namespace SpotifyAPI.Web
|
||||
if (!UseAuth)
|
||||
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);
|
||||
}
|
||||
|
||||
@ -889,7 +889,7 @@ namespace SpotifyAPI.Web
|
||||
if (!UseAuth)
|
||||
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);
|
||||
}
|
||||
|
||||
@ -944,7 +944,7 @@ namespace SpotifyAPI.Web
|
||||
public async Task<ErrorResponse> SaveTracksAsync(List<string> 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>
|
||||
@ -1020,7 +1020,7 @@ namespace SpotifyAPI.Web
|
||||
public async Task<ErrorResponse> RemoveSavedTracksAsync(List<string> 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>
|
||||
@ -1034,7 +1034,7 @@ namespace SpotifyAPI.Web
|
||||
if (!UseAuth)
|
||||
throw new InvalidOperationException("Auth is required for CheckSavedTracks");
|
||||
|
||||
var url = _builder.CheckSavedTracks(ids);
|
||||
string url = _builder.CheckSavedTracks(ids);
|
||||
return DownloadList<bool>(url);
|
||||
}
|
||||
|
||||
@ -1048,7 +1048,7 @@ namespace SpotifyAPI.Web
|
||||
{
|
||||
if (!UseAuth)
|
||||
throw new InvalidOperationException("Auth is required for CheckSavedTracks");
|
||||
var url = _builder.CheckSavedTracks(ids);
|
||||
string url = _builder.CheckSavedTracks(ids);
|
||||
return DownloadListAsync<bool>(url);
|
||||
}
|
||||
|
||||
@ -1073,7 +1073,7 @@ namespace SpotifyAPI.Web
|
||||
public async Task<ErrorResponse> SaveAlbumsAsync(List<string> 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>
|
||||
@ -1149,7 +1149,7 @@ namespace SpotifyAPI.Web
|
||||
public async Task<ErrorResponse> RemoveSavedAlbumsAsync(List<string> 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>
|
||||
@ -1163,7 +1163,7 @@ namespace SpotifyAPI.Web
|
||||
if (!UseAuth)
|
||||
throw new InvalidOperationException("Auth is required for CheckSavedTracks");
|
||||
|
||||
var url = _builder.CheckSavedAlbums(ids);
|
||||
string url = _builder.CheckSavedAlbums(ids);
|
||||
return DownloadList<bool>(url);
|
||||
}
|
||||
|
||||
@ -1177,7 +1177,7 @@ namespace SpotifyAPI.Web
|
||||
{
|
||||
if (!UseAuth)
|
||||
throw new InvalidOperationException("Auth is required for CheckSavedAlbumsAsync");
|
||||
var url = _builder.CheckSavedAlbums(ids);
|
||||
string url = _builder.CheckSavedAlbums(ids);
|
||||
return DownloadListAsync<bool>(url);
|
||||
}
|
||||
|
||||
@ -1601,7 +1601,7 @@ namespace SpotifyAPI.Web
|
||||
body.Add("collaborative", newCollaborative);
|
||||
if (newDescription != null)
|
||||
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>
|
||||
@ -1625,7 +1625,7 @@ namespace SpotifyAPI.Web
|
||||
body.Add("collaborative", newCollaborative);
|
||||
if (newDescription != null)
|
||||
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>
|
||||
@ -1651,7 +1651,7 @@ namespace SpotifyAPI.Web
|
||||
/// <remarks>AUTH NEEDED</remarks>
|
||||
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>
|
||||
@ -1675,8 +1675,8 @@ namespace SpotifyAPI.Web
|
||||
/// <remarks>AUTH NEEDED</remarks>
|
||||
public async Task<ErrorResponse> UploadPlaylistImageAsync(string playlistId, string base64EncodedJpgImage)
|
||||
{
|
||||
return (await UploadDataAsync<ErrorResponse>(_builder.UploadPlaylistImage(playlistId),
|
||||
base64EncodedJpgImage, "PUT").ConfigureAwait(false)) ?? new ErrorResponse();
|
||||
return await UploadDataAsync<ErrorResponse>(_builder.UploadPlaylistImage(playlistId),
|
||||
base64EncodedJpgImage, "PUT").ConfigureAwait(false) ?? new ErrorResponse();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1731,7 +1731,7 @@ namespace SpotifyAPI.Web
|
||||
{
|
||||
{"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>
|
||||
@ -1748,7 +1748,7 @@ namespace SpotifyAPI.Web
|
||||
{
|
||||
{"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>
|
||||
@ -1809,7 +1809,7 @@ namespace SpotifyAPI.Web
|
||||
{
|
||||
{"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>
|
||||
@ -1828,7 +1828,7 @@ namespace SpotifyAPI.Web
|
||||
{
|
||||
{"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>
|
||||
@ -1935,7 +1935,7 @@ namespace SpotifyAPI.Web
|
||||
{
|
||||
{"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>
|
||||
@ -1952,7 +1952,7 @@ namespace SpotifyAPI.Web
|
||||
{
|
||||
{"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>
|
||||
@ -2370,7 +2370,7 @@ namespace SpotifyAPI.Web
|
||||
/// <returns></returns>
|
||||
public ErrorResponse TransferPlayback(List<string> deviceIds, bool play = false)
|
||||
{
|
||||
JObject ob = new JObject()
|
||||
JObject ob = new JObject
|
||||
{
|
||||
{ "play", play },
|
||||
{ "device_ids", new JArray(deviceIds) }
|
||||
@ -2390,7 +2390,7 @@ namespace SpotifyAPI.Web
|
||||
/// <returns></returns>
|
||||
public Task<ErrorResponse> TransferPlaybackAsync(List<string> deviceIds, bool play = false)
|
||||
{
|
||||
JObject ob = new JObject()
|
||||
JObject ob = new JObject
|
||||
{
|
||||
{ "play", play },
|
||||
{ "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="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="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>
|
||||
/// <param name="positionMs">The starting time to seek the track to</param>
|
||||
/// <returns></returns>
|
||||
public ErrorResponse ResumePlayback(string deviceId = "", string contextUri = "", List<string> uris = null,
|
||||
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="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="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>
|
||||
/// <param name="positionMs">The starting time to seek the track to</param>
|
||||
/// <returns></returns>
|
||||
public Task<ErrorResponse> ResumePlaybackAsync(string deviceId = "", string contextUri = "", List<string> uris = null,
|
||||
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="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="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>
|
||||
/// <param name="positionMs">The starting time to seek the track to</param>
|
||||
/// <returns></returns>
|
||||
public ErrorResponse ResumePlayback(string deviceId = "", string contextUri = "", List<string> uris = null,
|
||||
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="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="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>
|
||||
/// <param name="positionMs">The starting time to seek the track to</param>
|
||||
/// <returns></returns>
|
||||
public Task<ErrorResponse> ResumePlaybackAsync(string deviceId = "", string contextUri = "", List<string> uris = null,
|
||||
string offset = "", int positionMs = 0)
|
||||
@ -2862,7 +2862,7 @@ namespace SpotifyAPI.Web
|
||||
{
|
||||
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;
|
||||
}
|
||||
@ -2880,7 +2880,7 @@ namespace SpotifyAPI.Web
|
||||
if (response != null)
|
||||
{
|
||||
int msToWait = RetryAfter;
|
||||
var secondsToWait = GetTooManyRequests(response.Item1);
|
||||
int secondsToWait = GetTooManyRequests(response.Item1);
|
||||
if (secondsToWait > 0)
|
||||
{
|
||||
msToWait = secondsToWait * 1000;
|
||||
@ -2900,7 +2900,7 @@ namespace SpotifyAPI.Web
|
||||
} while (UseAutoRetry
|
||||
&& triesLeft > 0
|
||||
&& (GetTooManyRequests(response.Item1) != -1
|
||||
|| (lastError != null && RetryErrorCodes.Contains(lastError.Status))));
|
||||
|| lastError != null && RetryErrorCodes.Contains(lastError.Status)));
|
||||
|
||||
|
||||
return response.Item2;
|
||||
|
@ -70,9 +70,7 @@ namespace SpotifyAPI.Web
|
||||
/// <returns></returns>
|
||||
public string GetAlbum(string id, string market = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(market))
|
||||
return $"{APIBase}/albums/{id}";
|
||||
return $"{APIBase}/albums/{id}?market={market}";
|
||||
return string.IsNullOrEmpty(market) ? $"{APIBase}/albums/{id}" : $"{APIBase}/albums/{id}?market={market}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -83,9 +81,9 @@ namespace SpotifyAPI.Web
|
||||
/// <returns></returns>
|
||||
public string GetSeveralAlbums(List<string> ids, string market = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(market))
|
||||
return $"{APIBase}/albums?ids={string.Join(",", ids.Take(20))}";
|
||||
return $"{APIBase}/albums?market={market}&ids={string.Join(",", ids.Take(20))}";
|
||||
return string.IsNullOrEmpty(market)
|
||||
? $"{APIBase}/albums?ids={string.Join(",", ids.Take(20))}"
|
||||
: $"{APIBase}/albums?market={market}&ids={string.Join(",", ids.Take(20))}";
|
||||
}
|
||||
|
||||
#endregion Albums
|
||||
@ -734,7 +732,7 @@ namespace SpotifyAPI.Web
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
/// <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";
|
||||
}
|
||||
@ -829,9 +827,9 @@ namespace SpotifyAPI.Web
|
||||
/// <remarks>AUTH NEEDED</remarks>
|
||||
public string AddPlaylistTracks(string userId, string playlistId, List<string> uris, int? position = null)
|
||||
{
|
||||
if (position == null)
|
||||
return $"{APIBase}/users/{userId}/playlists/{playlistId}/tracks";
|
||||
return $"{APIBase}/users/{userId}/playlists/{playlistId}/tracks?position={position}";
|
||||
return position == null
|
||||
? $"{APIBase}/users/{userId}/playlists/{playlistId}/tracks"
|
||||
: $"{APIBase}/users/{userId}/playlists/{playlistId}/tracks?position={position}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -844,9 +842,9 @@ namespace SpotifyAPI.Web
|
||||
/// <remarks>AUTH NEEDED</remarks>
|
||||
public string AddPlaylistTracks(string playlistId, List<string> uris, int? position = null)
|
||||
{
|
||||
if (position == null)
|
||||
return $"{APIBase}/playlists/{playlistId}/tracks";
|
||||
return $"{APIBase}/playlists/{playlistId}/tracks?position={position}";
|
||||
return position == null
|
||||
? $"{APIBase}/playlists/{playlistId}/tracks"
|
||||
: $"{APIBase}/playlists/{playlistId}/tracks?position={position}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -931,9 +929,9 @@ namespace SpotifyAPI.Web
|
||||
/// <returns></returns>
|
||||
public string GetSeveralTracks(List<string> ids, string market = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(market))
|
||||
return $"{APIBase}/tracks?ids={string.Join(",", ids.Take(50))}";
|
||||
return $"{APIBase}/tracks?market={market}&ids={string.Join(",", ids.Take(50))}";
|
||||
return string.IsNullOrEmpty(market)
|
||||
? $"{APIBase}/tracks?ids={string.Join(",", ids.Take(50))}"
|
||||
: $"{APIBase}/tracks?market={market}&ids={string.Join(",", ids.Take(50))}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -944,9 +942,7 @@ namespace SpotifyAPI.Web
|
||||
/// <returns></returns>
|
||||
public string GetTrack(string id, string market = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(market))
|
||||
return $"{APIBase}/tracks/{id}";
|
||||
return $"{APIBase}/tracks/{id}?market={market}";
|
||||
return string.IsNullOrEmpty(market) ? $"{APIBase}/tracks/{id}" : $"{APIBase}/tracks/{id}?market={market}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1002,9 +998,7 @@ namespace SpotifyAPI.Web
|
||||
/// <returns></returns>
|
||||
public string GetPlayback(string market = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(market))
|
||||
return $"{APIBase}/me/player";
|
||||
return $"{APIBase}/me/player?market={market}";
|
||||
return string.IsNullOrEmpty(market) ? $"{APIBase}/me/player" : $"{APIBase}/me/player?market={market}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1014,9 +1008,9 @@ namespace SpotifyAPI.Web
|
||||
/// <returns></returns>
|
||||
public string GetPlayingTrack(string market = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(market))
|
||||
return $"{APIBase}/me/player/currently-playing";
|
||||
return $"{APIBase}/me/player/currently-playing?market={market}";
|
||||
return string.IsNullOrEmpty(market)
|
||||
? $"{APIBase}/me/player/currently-playing"
|
||||
: $"{APIBase}/me/player/currently-playing?market={market}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1035,9 +1029,9 @@ namespace SpotifyAPI.Web
|
||||
/// <returns></returns>
|
||||
public string ResumePlayback(string deviceId = "")
|
||||
{
|
||||
if(string.IsNullOrEmpty(deviceId))
|
||||
return $"{APIBase}/me/player/play";
|
||||
return $"{APIBase}/me/player/play?device_id={deviceId}";
|
||||
return string.IsNullOrEmpty(deviceId)
|
||||
? $"{APIBase}/me/player/play"
|
||||
: $"{APIBase}/me/player/play?device_id={deviceId}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1047,9 +1041,9 @@ namespace SpotifyAPI.Web
|
||||
/// <returns></returns>
|
||||
public string PausePlayback(string deviceId = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(deviceId))
|
||||
return $"{APIBase}/me/player/pause";
|
||||
return $"{APIBase}/me/player/pause?device_id={deviceId}";
|
||||
return string.IsNullOrEmpty(deviceId)
|
||||
? $"{APIBase}/me/player/pause"
|
||||
: $"{APIBase}/me/player/pause?device_id={deviceId}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1059,9 +1053,9 @@ namespace SpotifyAPI.Web
|
||||
/// <returns></returns>
|
||||
public string SkipPlaybackToNext(string deviceId = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(deviceId))
|
||||
return $"{APIBase}/me/player/next";
|
||||
return $"{APIBase}/me/player/next?device_id={deviceId}";
|
||||
return string.IsNullOrEmpty(deviceId)
|
||||
? $"{APIBase}/me/player/next"
|
||||
: $"{APIBase}/me/player/next?device_id={deviceId}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1073,9 +1067,9 @@ namespace SpotifyAPI.Web
|
||||
/// <returns></returns>
|
||||
public string SkipPlaybackToPrevious(string deviceId = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(deviceId))
|
||||
return $"{APIBase}/me/player/previous";
|
||||
return $"{APIBase}/me/player/previous?device_id={deviceId}";
|
||||
return string.IsNullOrEmpty(deviceId)
|
||||
? $"{APIBase}/me/player/previous"
|
||||
: $"{APIBase}/me/player/previous?device_id={deviceId}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1087,9 +1081,9 @@ namespace SpotifyAPI.Web
|
||||
/// <returns></returns>
|
||||
public string SeekPlayback(int positionMs, string deviceId = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(deviceId))
|
||||
return $"{APIBase}/me/player/seek?position_ms={positionMs}";
|
||||
return $"{APIBase}/me/player/seek?position_ms={positionMs}&device_id={deviceId}";
|
||||
return string.IsNullOrEmpty(deviceId)
|
||||
? $"{APIBase}/me/player/seek?position_ms={positionMs}"
|
||||
: $"{APIBase}/me/player/seek?position_ms={positionMs}&device_id={deviceId}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1100,9 +1094,9 @@ namespace SpotifyAPI.Web
|
||||
/// <returns></returns>
|
||||
public string SetRepeatMode(RepeatState repeatState, string deviceId = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(deviceId))
|
||||
return $"{APIBase}/me/player/repeat?state={repeatState.GetStringAttribute()}";
|
||||
return $"{APIBase}/me/player/repeat?state={repeatState.GetStringAttribute()}&device_id={deviceId}";
|
||||
return string.IsNullOrEmpty(deviceId)
|
||||
? $"{APIBase}/me/player/repeat?state={repeatState.GetStringAttribute()}"
|
||||
: $"{APIBase}/me/player/repeat?state={repeatState.GetStringAttribute()}&device_id={deviceId}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1113,9 +1107,9 @@ namespace SpotifyAPI.Web
|
||||
/// <returns></returns>
|
||||
public string SetVolume(int volumePercent, string deviceId = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(deviceId))
|
||||
return $"{APIBase}/me/player/volume?volume_percent={volumePercent}";
|
||||
return $"{APIBase}/me/player/volume?volume_percent={volumePercent}&device_id={deviceId}";
|
||||
return string.IsNullOrEmpty(deviceId)
|
||||
? $"{APIBase}/me/player/volume?volume_percent={volumePercent}"
|
||||
: $"{APIBase}/me/player/volume?volume_percent={volumePercent}&device_id={deviceId}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1126,9 +1120,9 @@ namespace SpotifyAPI.Web
|
||||
/// <returns></returns>
|
||||
public string SetShuffle(bool shuffle, string deviceId = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(deviceId))
|
||||
return $"{APIBase}/me/player/shuffle?state={shuffle}";
|
||||
return $"{APIBase}/me/player/shuffle?state={shuffle}&device_id={deviceId}";
|
||||
return string.IsNullOrEmpty(deviceId)
|
||||
? $"{APIBase}/me/player/shuffle?state={shuffle}"
|
||||
: $"{APIBase}/me/player/shuffle?state={shuffle}&device_id={deviceId}";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SpotifyAPI.Web.Models;
|
||||
using SpotifyAPI.Web.Enums;
|
||||
|
||||
namespace SpotifyAPI.Web
|
||||
{
|
||||
@ -211,14 +210,12 @@ namespace SpotifyAPI.Web
|
||||
UseProxy = false
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(proxyConfig?.Host))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(proxyConfig?.Host)) return clientHandler;
|
||||
WebProxy proxy = proxyConfig.CreateWebProxy();
|
||||
clientHandler.UseProxy = true;
|
||||
clientHandler.Proxy = proxy;
|
||||
clientHandler.UseDefaultCredentials = proxy.UseDefaultCredentials;
|
||||
clientHandler.PreAuthenticate = proxy.UseDefaultCredentials;
|
||||
}
|
||||
|
||||
return clientHandler;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user