mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-24 15:06:26 +00:00
OpenBrowser returns false if it was unsuccessful
This commit is contained in:
parent
89c33bc728
commit
22d800d487
@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
@ -5,26 +6,34 @@ namespace SpotifyAPI.Web.Auth
|
|||||||
{
|
{
|
||||||
internal static class AuthUtil
|
internal static class AuthUtil
|
||||||
{
|
{
|
||||||
public static void OpenBrowser(string url)
|
public static bool OpenBrowser(string url)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
#if NETSTANDARD2_0
|
#if NETSTANDARD2_0
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
{
|
{
|
||||||
url = url.Replace("&", "^&");
|
url = url.Replace("&", "^&");
|
||||||
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}"));
|
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}"));
|
||||||
}
|
}
|
||||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||||
{
|
{
|
||||||
Process.Start("xdg-open", url);
|
Process.Start("xdg-open", url);
|
||||||
}
|
}
|
||||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||||
{
|
{
|
||||||
Process.Start("open", url);
|
Process.Start("open", url);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
url = url.Replace("&", "^&");
|
url = url.Replace("&", "^&");
|
||||||
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}"));
|
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}"));
|
||||||
#endif
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -27,7 +27,7 @@ namespace SpotifyAPI.Web
|
|||||||
JsonSettings =
|
JsonSettings =
|
||||||
new JsonSerializerSettings
|
new JsonSerializerSettings
|
||||||
{
|
{
|
||||||
NullValueHandling = NullValueHandling.Ignore
|
NullValueHandling = NullValueHandling.Ignore
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ namespace SpotifyAPI.Web
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Error codes that will trigger auto-retry if <see cref="UseAutoRetry"/> is enabled.
|
/// Error codes that will trigger auto-retry if <see cref="UseAutoRetry"/> is enabled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<int> RetryErrorCodes { get; set; } = new [] { 500, 502, 503 };
|
public IEnumerable<int> RetryErrorCodes { get; set; } = new[] { 500, 502, 503 };
|
||||||
|
|
||||||
#endregion Configuration
|
#endregion Configuration
|
||||||
|
|
||||||
@ -2873,7 +2873,7 @@ namespace SpotifyAPI.Web
|
|||||||
private int GetTooManyRequests(ResponseInfo info)
|
private int GetTooManyRequests(ResponseInfo info)
|
||||||
{
|
{
|
||||||
// 429 is "TooManyRequests" value specified in Spotify API
|
// 429 is "TooManyRequests" value specified in Spotify API
|
||||||
if (429 != (int) info.StatusCode)
|
if (429 != (int)info.StatusCode)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user