mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-23 14:46:26 +00:00
Added FeaturedPlaylists
This commit is contained in:
parent
8074ff6331
commit
2b5a826181
@ -11,11 +11,8 @@ namespace SpotifyAPI.Web
|
||||
[Test]
|
||||
public async Task TestingYo()
|
||||
{
|
||||
var config = SpotifyClientConfig.CreateDefault("BQAODnY4uqYj_KCddlDm10KLPDZSpZhVUtMDjdh1zfG-xd5pAV3htRjnaGfO7ob92HHzNP05a-4mDnts337gdnZlRtjrDPnuWNFx75diY540H0cD1bS9UzI5cfO27N2O6lmzKb_jAYTaRoqPKHoG93KGiXxwg4vblGKSBY1vIloP");
|
||||
var config = SpotifyClientConfig.CreateDefault("");
|
||||
var spotify = new SpotifyClient(config);
|
||||
|
||||
var playlists = await spotify.Browse.GetCategoryPlaylists("toplists", new CategoriesPlaylistsRequest() { Offset = 1 });
|
||||
Console.WriteLine(playlists.Playlists.Items[0].Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,5 +75,17 @@ namespace SpotifyAPI.Web
|
||||
|
||||
return API.Get<NewReleasesResponse>(URLs.NewReleases(), request.BuildQueryParams());
|
||||
}
|
||||
|
||||
public Task<FeaturedPlaylistsResponse> GetFeaturedPlaylists()
|
||||
{
|
||||
return API.Get<FeaturedPlaylistsResponse>(URLs.FeaturedPlaylists());
|
||||
}
|
||||
|
||||
public Task<FeaturedPlaylistsResponse> GetFeaturedPlaylists(FeaturedPlaylistsRequest request)
|
||||
{
|
||||
Ensure.ArgumentNotNull(request, nameof(request));
|
||||
|
||||
return API.Get<FeaturedPlaylistsResponse>(URLs.FeaturedPlaylists(), request.BuildQueryParams());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,5 +18,8 @@ namespace SpotifyAPI.Web
|
||||
|
||||
Task<NewReleasesResponse> GetNewReleases();
|
||||
Task<NewReleasesResponse> GetNewReleases(NewReleasesRequest request);
|
||||
|
||||
Task<FeaturedPlaylistsResponse> GetFeaturedPlaylists();
|
||||
Task<FeaturedPlaylistsResponse> GetFeaturedPlaylists(FeaturedPlaylistsRequest request);
|
||||
}
|
||||
}
|
||||
|
22
SpotifyAPI.Web/Models/Request/FeaturedPlaylistsRequest.cs
Normal file
22
SpotifyAPI.Web/Models/Request/FeaturedPlaylistsRequest.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
namespace SpotifyAPI.Web
|
||||
{
|
||||
public class FeaturedPlaylistsRequest : RequestParams
|
||||
{
|
||||
[QueryParam("country")]
|
||||
public string Country { get; set; }
|
||||
[QueryParam("locale")]
|
||||
public string Locale { get; set; }
|
||||
[QueryParam("limit")]
|
||||
public int? Limit { get; set; }
|
||||
[QueryParam("offset")]
|
||||
public int? Offset { get; set; }
|
||||
public DateTime? Timestamp { get; set; }
|
||||
|
||||
[QueryParam("timestamp")]
|
||||
protected string _Timestamp
|
||||
{
|
||||
get => Timestamp?.ToString("o");
|
||||
}
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ namespace SpotifyAPI.Web
|
||||
// Make sure everything is okay before building query params
|
||||
Ensure();
|
||||
|
||||
var queryProps = GetType().GetProperties()
|
||||
var queryProps = GetType().GetProperties(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public)
|
||||
.Where(prop => prop.GetCustomAttributes(typeof(QueryParamAttribute), true).Length > 0);
|
||||
|
||||
var queryParams = new Dictionary<string, string>();
|
||||
@ -36,7 +36,7 @@ namespace SpotifyAPI.Web
|
||||
|
||||
public class QueryParamAttribute : Attribute
|
||||
{
|
||||
public string Key { get; set; }
|
||||
public string Key { get; }
|
||||
|
||||
public QueryParamAttribute() { }
|
||||
public QueryParamAttribute(string key)
|
||||
|
@ -0,0 +1,8 @@
|
||||
namespace SpotifyAPI.Web
|
||||
{
|
||||
public class FeaturedPlaylistsResponse
|
||||
{
|
||||
public string Message { get; set; }
|
||||
public Paging<SimplePlaylist> Playlists { get; set; }
|
||||
}
|
||||
}
|
@ -23,6 +23,8 @@ namespace SpotifyAPI.Web
|
||||
|
||||
public static Uri NewReleases() => EUri($"browse/new-releases");
|
||||
|
||||
public static Uri FeaturedPlaylists() => EUri($"browse/featured-playlists");
|
||||
|
||||
private static Uri EUri(FormattableString path) => new Uri(path.ToString(_provider), UriKind.Relative);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ namespace SpotifyAPI.Web
|
||||
newParameters.Add(parameter.Key, HttpUtility.UrlEncode(parameter.Value));
|
||||
}
|
||||
|
||||
var queryString = String.Join("&", newParameters.Select((parameter) => $"{parameter.Key}={parameter.Value}"));
|
||||
var queryString = string.Join("&", newParameters.Select((parameter) => $"{parameter.Key}={parameter.Value}"));
|
||||
var query = string.IsNullOrEmpty(queryString) ? null : $"?{queryString}";
|
||||
|
||||
var uriBuilder = new UriBuilder(uri)
|
||||
|
Loading…
Reference in New Issue
Block a user