diff --git a/SpotifyAPI/SpotifyAPI.csproj b/SpotifyAPI/SpotifyAPI.csproj index 14acdb00..02d7c164 100644 --- a/SpotifyAPI/SpotifyAPI.csproj +++ b/SpotifyAPI/SpotifyAPI.csproj @@ -76,6 +76,7 @@ + @@ -92,6 +93,10 @@ + + + + diff --git a/SpotifyAPI/Web/Models/AudioFeatures.cs b/SpotifyAPI/Web/Models/AudioFeatures.cs new file mode 100644 index 00000000..a3b029f9 --- /dev/null +++ b/SpotifyAPI/Web/Models/AudioFeatures.cs @@ -0,0 +1,61 @@ +using Newtonsoft.Json; + +namespace SpotifyAPI.Web.Models +{ + public class AudioFeatures : BasicModel + { + [JsonProperty("acousticness")] + public float Acousticness { get; set; } + + [JsonProperty("analysis_url")] + public string AnalysisUrl { get; set; } + + [JsonProperty("danceability")] + public float Danceability { get; set; } + + [JsonProperty("duration_ms")] + public int DurationMs { get; set; } + + [JsonProperty("energy")] + public float Energy { get; set; } + + [JsonProperty("id")] + public string Id { get; set; } + + [JsonProperty("instrumentalness")] + public float Instrumentalness { get; set; } + + [JsonProperty("key")] + public int Key { get; set; } + + [JsonProperty("liveness")] + public float Liveness { get; set; } + + [JsonProperty("loudness")] + public float Loudness { get; set; } + + [JsonProperty("mode")] + public int Mode { get; set; } + + [JsonProperty("speechiness")] + public float Speechiness { get; set; } + + [JsonProperty("tempo")] + public float Tempo { get; set; } + + [JsonProperty("time_signature")] + public int TimeSignature { get; set; } + + [JsonProperty("track_href")] + public string TrackHref { get; set; } + + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("uri")] + public string Uri { get; set; } + + [JsonProperty("valence")] + public float Valence { get; set; } + } +} \ No newline at end of file diff --git a/SpotifyAPI/Web/Models/GeneralModels.cs b/SpotifyAPI/Web/Models/GeneralModels.cs index 72443ed8..814f7a5f 100644 --- a/SpotifyAPI/Web/Models/GeneralModels.cs +++ b/SpotifyAPI/Web/Models/GeneralModels.cs @@ -88,24 +88,6 @@ namespace SpotifyAPI.Web.Models } } - public class SeveralTracks : BasicModel - { - [JsonProperty("tracks")] - public List Tracks { get; set; } - } - - public class SeveralArtists : BasicModel - { - [JsonProperty("artists")] - public List Artists { get; set; } - } - - public class SeveralAlbums : BasicModel - { - [JsonProperty("albums")] - public List Albums { get; set; } - } - public class Copyright { [JsonProperty("text")] diff --git a/SpotifyAPI/Web/Models/SeveralAlbums.cs b/SpotifyAPI/Web/Models/SeveralAlbums.cs new file mode 100644 index 00000000..74025da0 --- /dev/null +++ b/SpotifyAPI/Web/Models/SeveralAlbums.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace SpotifyAPI.Web.Models +{ + public class SeveralAlbums : BasicModel + { + [JsonProperty("albums")] + public List Albums { get; set; } + } +} \ No newline at end of file diff --git a/SpotifyAPI/Web/Models/SeveralArtists.cs b/SpotifyAPI/Web/Models/SeveralArtists.cs new file mode 100644 index 00000000..28df5db5 --- /dev/null +++ b/SpotifyAPI/Web/Models/SeveralArtists.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace SpotifyAPI.Web.Models +{ + public class SeveralArtists : BasicModel + { + [JsonProperty("artists")] + public List Artists { get; set; } + } +} \ No newline at end of file diff --git a/SpotifyAPI/Web/Models/SeveralAudioFeatures.cs b/SpotifyAPI/Web/Models/SeveralAudioFeatures.cs new file mode 100644 index 00000000..34ea6515 --- /dev/null +++ b/SpotifyAPI/Web/Models/SeveralAudioFeatures.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace SpotifyAPI.Web.Models +{ + public class SeveralAudioFeatures : BasicModel + { + [JsonProperty("audio_features")] + public List AudioFeatures { get; set; } + } +} \ No newline at end of file diff --git a/SpotifyAPI/Web/Models/SeveralTracks.cs b/SpotifyAPI/Web/Models/SeveralTracks.cs new file mode 100644 index 00000000..a72c216e --- /dev/null +++ b/SpotifyAPI/Web/Models/SeveralTracks.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace SpotifyAPI.Web.Models +{ + public class SeveralTracks : BasicModel + { + [JsonProperty("tracks")] + public List Tracks { get; set; } + } +} \ No newline at end of file diff --git a/SpotifyAPI/Web/SpotifyWebAPI.cs b/SpotifyAPI/Web/SpotifyWebAPI.cs index c99dfd7a..b6f66ae5 100644 --- a/SpotifyAPI/Web/SpotifyWebAPI.cs +++ b/SpotifyAPI/Web/SpotifyWebAPI.cs @@ -1578,6 +1578,50 @@ namespace SpotifyAPI.Web return await DownloadDataAsync(_builder.GetTrack(id, market)); } + /// + /// Get audio feature information for a single track identified by its unique Spotify ID. + /// + /// The Spotify ID for the track. + /// + /// AUTH NEEDED + public AudioFeatures GetAudioFeatures(string id) + { + return DownloadData(_builder.GetAudioFeatures(id)); + } + + /// + /// Get audio feature information for a single track identified by its unique Spotify ID asynchronously. + /// + /// The Spotify ID for the track. + /// + /// AUTH NEEDED + public async Task GetAudioFeaturesAsync(string id) + { + return await DownloadDataAsync(_builder.GetAudioFeatures(id)); + } + + /// + /// Get audio features for multiple tracks based on their Spotify IDs. + /// + /// A list of Spotify Track-IDs. Maximum: 100 IDs. + /// + /// AUTH NEEDED + public SeveralAudioFeatures GetSeveralAudioFeatures(List ids) + { + return DownloadData(_builder.GetSeveralAudioFeatures(ids)); + } + + /// + /// Get audio features for multiple tracks based on their Spotify IDs asynchronously. + /// + /// A list of Spotify Track-IDs. Maximum: 100 IDs. + /// + /// AUTH NEEDED + public async Task GetSeveralAudioFeaturesAsync(List ids) + { + return await DownloadDataAsync(_builder.GetSeveralAudioFeatures(ids)); + } + #endregion Tracks #region Util diff --git a/SpotifyAPI/Web/SpotifyWebBuilder.cs b/SpotifyAPI/Web/SpotifyWebBuilder.cs index f978fe2f..ef528d48 100644 --- a/SpotifyAPI/Web/SpotifyWebBuilder.cs +++ b/SpotifyAPI/Web/SpotifyWebBuilder.cs @@ -698,6 +698,28 @@ namespace SpotifyAPI.Web return $"{APIBase}/tracks/{id}?market={market}"; } + /// + /// Get audio feature information for a single track identified by its unique Spotify ID. + /// + /// The Spotify ID for the track. + /// + /// AUTH NEEDED + public string GetAudioFeatures(string id) + { + return $"{APIBase}/audio-features/{id}"; + } + + /// + /// Get audio features for multiple tracks based on their Spotify IDs. + /// + /// A list of Spotify Track-IDs. Maximum: 100 IDs. + /// + /// AUTH NEEDED + public string GetSeveralAudioFeatures(List ids) + { + return $"{APIBase}/audio-features?ids={string.Join(",", ids.Take(100))}"; + } + #endregion Tracks } }