Added AudioFeatures / Moved Several* to their own files

This commit is contained in:
Johnny @PC 2016-03-31 12:07:29 +02:00
parent 8d274164c4
commit c8637e32a9
9 changed files with 176 additions and 18 deletions

View File

@ -76,6 +76,7 @@
<Compile Include="Web\Enums\FollowType.cs" />
<Compile Include="Web\Auth\ImplicitGrantAuth.cs" />
<Compile Include="Web\Models\ArrayResponse.cs" />
<Compile Include="Web\Models\AudioFeatures.cs" />
<Compile Include="Web\Models\BasicModel.cs" />
<Compile Include="Web\Models\Category.cs" />
<Compile Include="Web\Models\CategoryList.cs" />
@ -92,6 +93,10 @@
<Compile Include="Web\Models\GeneralModels.cs" />
<Compile Include="Web\Models\FullPlaylist.cs" />
<Compile Include="Web\Models\PublicProfile.cs" />
<Compile Include="Web\Models\SeveralAlbums.cs" />
<Compile Include="Web\Models\SeveralArtists.cs" />
<Compile Include="Web\Models\SeveralAudioFeatures.cs" />
<Compile Include="Web\Models\SeveralTracks.cs" />
<Compile Include="Web\Models\SimpleAlbum.cs" />
<Compile Include="Web\Models\SimpleArtist.cs" />
<Compile Include="Web\Models\SimpleTrack.cs" />

View File

@ -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; }
}
}

View File

@ -88,24 +88,6 @@ namespace SpotifyAPI.Web.Models
}
}
public class SeveralTracks : BasicModel
{
[JsonProperty("tracks")]
public List<FullTrack> Tracks { get; set; }
}
public class SeveralArtists : BasicModel
{
[JsonProperty("artists")]
public List<FullArtist> Artists { get; set; }
}
public class SeveralAlbums : BasicModel
{
[JsonProperty("albums")]
public List<FullAlbum> Albums { get; set; }
}
public class Copyright
{
[JsonProperty("text")]

View File

@ -0,0 +1,11 @@
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{
public class SeveralAlbums : BasicModel
{
[JsonProperty("albums")]
public List<FullAlbum> Albums { get; set; }
}
}

View File

@ -0,0 +1,11 @@
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{
public class SeveralArtists : BasicModel
{
[JsonProperty("artists")]
public List<FullArtist> Artists { get; set; }
}
}

View File

@ -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> AudioFeatures { get; set; }
}
}

View File

@ -0,0 +1,11 @@
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{
public class SeveralTracks : BasicModel
{
[JsonProperty("tracks")]
public List<FullTrack> Tracks { get; set; }
}
}

View File

@ -1578,6 +1578,50 @@ namespace SpotifyAPI.Web
return await DownloadDataAsync<FullTrack>(_builder.GetTrack(id, market));
}
/// <summary>
/// Get audio feature information for a single track identified by its unique Spotify ID.
/// </summary>
/// <param name="id">The Spotify ID for the track.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public AudioFeatures GetAudioFeatures(string id)
{
return DownloadData<AudioFeatures>(_builder.GetAudioFeatures(id));
}
/// <summary>
/// Get audio feature information for a single track identified by its unique Spotify ID asynchronously.
/// </summary>
/// <param name="id">The Spotify ID for the track.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public async Task<AudioFeatures> GetAudioFeaturesAsync(string id)
{
return await DownloadDataAsync<AudioFeatures>(_builder.GetAudioFeatures(id));
}
/// <summary>
/// Get audio features for multiple tracks based on their Spotify IDs.
/// </summary>
/// <param name="ids">A list of Spotify Track-IDs. Maximum: 100 IDs.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public SeveralAudioFeatures GetSeveralAudioFeatures(List<string> ids)
{
return DownloadData<SeveralAudioFeatures>(_builder.GetSeveralAudioFeatures(ids));
}
/// <summary>
/// Get audio features for multiple tracks based on their Spotify IDs asynchronously.
/// </summary>
/// <param name="ids">A list of Spotify Track-IDs. Maximum: 100 IDs.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public async Task<SeveralAudioFeatures> GetSeveralAudioFeaturesAsync(List<string> ids)
{
return await DownloadDataAsync<SeveralAudioFeatures>(_builder.GetSeveralAudioFeatures(ids));
}
#endregion Tracks
#region Util

View File

@ -698,6 +698,28 @@ namespace SpotifyAPI.Web
return $"{APIBase}/tracks/{id}?market={market}";
}
/// <summary>
/// Get audio feature information for a single track identified by its unique Spotify ID.
/// </summary>
/// <param name="id">The Spotify ID for the track.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public string GetAudioFeatures(string id)
{
return $"{APIBase}/audio-features/{id}";
}
/// <summary>
/// Get audio features for multiple tracks based on their Spotify IDs.
/// </summary>
/// <param name="ids">A list of Spotify Track-IDs. Maximum: 100 IDs.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public string GetSeveralAudioFeatures(List<string> ids)
{
return $"{APIBase}/audio-features?ids={string.Join(",", ids.Take(100))}";
}
#endregion Tracks
}
}