Skip to content

Commit c8637e3

Browse files
author
Johnny @PC
committed
Added AudioFeatures / Moved Several* to their own files
1 parent 8d27416 commit c8637e3

9 files changed

Lines changed: 176 additions & 18 deletions

‎SpotifyAPI/SpotifyAPI.csproj‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
<Compile Include="Web\Enums\FollowType.cs" />
7777
<Compile Include="Web\Auth\ImplicitGrantAuth.cs" />
7878
<Compile Include="Web\Models\ArrayResponse.cs" />
79+
<Compile Include="Web\Models\AudioFeatures.cs" />
7980
<Compile Include="Web\Models\BasicModel.cs" />
8081
<Compile Include="Web\Models\Category.cs" />
8182
<Compile Include="Web\Models\CategoryList.cs" />
@@ -92,6 +93,10 @@
9293
<Compile Include="Web\Models\GeneralModels.cs" />
9394
<Compile Include="Web\Models\FullPlaylist.cs" />
9495
<Compile Include="Web\Models\PublicProfile.cs" />
96+
<Compile Include="Web\Models\SeveralAlbums.cs" />
97+
<Compile Include="Web\Models\SeveralArtists.cs" />
98+
<Compile Include="Web\Models\SeveralAudioFeatures.cs" />
99+
<Compile Include="Web\Models\SeveralTracks.cs" />
95100
<Compile Include="Web\Models\SimpleAlbum.cs" />
96101
<Compile Include="Web\Models\SimpleArtist.cs" />
97102
<Compile Include="Web\Models\SimpleTrack.cs" />
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using Newtonsoft.Json;
2+
3+
namespace SpotifyAPI.Web.Models
4+
{
5+
public class AudioFeatures : BasicModel
6+
{
7+
[JsonProperty("acousticness")]
8+
public float Acousticness { get; set; }
9+
10+
[JsonProperty("analysis_url")]
11+
public string AnalysisUrl { get; set; }
12+
13+
[JsonProperty("danceability")]
14+
public float Danceability { get; set; }
15+
16+
[JsonProperty("duration_ms")]
17+
public int DurationMs { get; set; }
18+
19+
[JsonProperty("energy")]
20+
public float Energy { get; set; }
21+
22+
[JsonProperty("id")]
23+
public string Id { get; set; }
24+
25+
[JsonProperty("instrumentalness")]
26+
public float Instrumentalness { get; set; }
27+
28+
[JsonProperty("key")]
29+
public int Key { get; set; }
30+
31+
[JsonProperty("liveness")]
32+
public float Liveness { get; set; }
33+
34+
[JsonProperty("loudness")]
35+
public float Loudness { get; set; }
36+
37+
[JsonProperty("mode")]
38+
public int Mode { get; set; }
39+
40+
[JsonProperty("speechiness")]
41+
public float Speechiness { get; set; }
42+
43+
[JsonProperty("tempo")]
44+
public float Tempo { get; set; }
45+
46+
[JsonProperty("time_signature")]
47+
public int TimeSignature { get; set; }
48+
49+
[JsonProperty("track_href")]
50+
public string TrackHref { get; set; }
51+
52+
[JsonProperty("type")]
53+
public string Type { get; set; }
54+
55+
[JsonProperty("uri")]
56+
public string Uri { get; set; }
57+
58+
[JsonProperty("valence")]
59+
public float Valence { get; set; }
60+
}
61+
}

‎SpotifyAPI/Web/Models/GeneralModels.cs‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,24 +88,6 @@ public bool ShouldSerializePositions()
8888
}
8989
}
9090

91-
public class SeveralTracks : BasicModel
92-
{
93-
[JsonProperty("tracks")]
94-
public List<FullTrack> Tracks { get; set; }
95-
}
96-
97-
public class SeveralArtists : BasicModel
98-
{
99-
[JsonProperty("artists")]
100-
public List<FullArtist> Artists { get; set; }
101-
}
102-
103-
public class SeveralAlbums : BasicModel
104-
{
105-
[JsonProperty("albums")]
106-
public List<FullAlbum> Albums { get; set; }
107-
}
108-
10991
public class Copyright
11092
{
11193
[JsonProperty("text")]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System.Collections.Generic;
2+
using Newtonsoft.Json;
3+
4+
namespace SpotifyAPI.Web.Models
5+
{
6+
public class SeveralAlbums : BasicModel
7+
{
8+
[JsonProperty("albums")]
9+
public List<FullAlbum> Albums { get; set; }
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System.Collections.Generic;
2+
using Newtonsoft.Json;
3+
4+
namespace SpotifyAPI.Web.Models
5+
{
6+
public class SeveralArtists : BasicModel
7+
{
8+
[JsonProperty("artists")]
9+
public List<FullArtist> Artists { get; set; }
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System.Collections.Generic;
2+
using Newtonsoft.Json;
3+
4+
namespace SpotifyAPI.Web.Models
5+
{
6+
public class SeveralAudioFeatures : BasicModel
7+
{
8+
[JsonProperty("audio_features")]
9+
public List<AudioFeatures> AudioFeatures { get; set; }
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System.Collections.Generic;
2+
using Newtonsoft.Json;
3+
4+
namespace SpotifyAPI.Web.Models
5+
{
6+
public class SeveralTracks : BasicModel
7+
{
8+
[JsonProperty("tracks")]
9+
public List<FullTrack> Tracks { get; set; }
10+
}
11+
}

‎SpotifyAPI/Web/SpotifyWebAPI.cs‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,50 @@ public async Task<FullTrack> GetTrackAsync(String id, String market = "")
15781578
return await DownloadDataAsync<FullTrack>(_builder.GetTrack(id, market));
15791579
}
15801580

1581+
/// <summary>
1582+
/// Get audio feature information for a single track identified by its unique Spotify ID.
1583+
/// </summary>
1584+
/// <param name="id">The Spotify ID for the track.</param>
1585+
/// <returns></returns>
1586+
/// <remarks>AUTH NEEDED</remarks>
1587+
public AudioFeatures GetAudioFeatures(string id)
1588+
{
1589+
return DownloadData<AudioFeatures>(_builder.GetAudioFeatures(id));
1590+
}
1591+
1592+
/// <summary>
1593+
/// Get audio feature information for a single track identified by its unique Spotify ID asynchronously.
1594+
/// </summary>
1595+
/// <param name="id">The Spotify ID for the track.</param>
1596+
/// <returns></returns>
1597+
/// <remarks>AUTH NEEDED</remarks>
1598+
public async Task<AudioFeatures> GetAudioFeaturesAsync(string id)
1599+
{
1600+
return await DownloadDataAsync<AudioFeatures>(_builder.GetAudioFeatures(id));
1601+
}
1602+
1603+
/// <summary>
1604+
/// Get audio features for multiple tracks based on their Spotify IDs.
1605+
/// </summary>
1606+
/// <param name="ids">A list of Spotify Track-IDs. Maximum: 100 IDs.</param>
1607+
/// <returns></returns>
1608+
/// <remarks>AUTH NEEDED</remarks>
1609+
public SeveralAudioFeatures GetSeveralAudioFeatures(List<string> ids)
1610+
{
1611+
return DownloadData<SeveralAudioFeatures>(_builder.GetSeveralAudioFeatures(ids));
1612+
}
1613+
1614+
/// <summary>
1615+
/// Get audio features for multiple tracks based on their Spotify IDs asynchronously.
1616+
/// </summary>
1617+
/// <param name="ids">A list of Spotify Track-IDs. Maximum: 100 IDs.</param>
1618+
/// <returns></returns>
1619+
/// <remarks>AUTH NEEDED</remarks>
1620+
public async Task<SeveralAudioFeatures> GetSeveralAudioFeaturesAsync(List<string> ids)
1621+
{
1622+
return await DownloadDataAsync<SeveralAudioFeatures>(_builder.GetSeveralAudioFeatures(ids));
1623+
}
1624+
15811625
#endregion Tracks
15821626

15831627
#region Util

‎SpotifyAPI/Web/SpotifyWebBuilder.cs‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,28 @@ public string GetTrack(String id, String market = "")
698698
return $"{APIBase}/tracks/{id}?market={market}";
699699
}
700700

701+
/// <summary>
702+
/// Get audio feature information for a single track identified by its unique Spotify ID.
703+
/// </summary>
704+
/// <param name="id">The Spotify ID for the track.</param>
705+
/// <returns></returns>
706+
/// <remarks>AUTH NEEDED</remarks>
707+
public string GetAudioFeatures(string id)
708+
{
709+
return $"{APIBase}/audio-features/{id}";
710+
}
711+
712+
/// <summary>
713+
/// Get audio features for multiple tracks based on their Spotify IDs.
714+
/// </summary>
715+
/// <param name="ids">A list of Spotify Track-IDs. Maximum: 100 IDs.</param>
716+
/// <returns></returns>
717+
/// <remarks>AUTH NEEDED</remarks>
718+
public string GetSeveralAudioFeatures(List<string> ids)
719+
{
720+
return $"{APIBase}/audio-features?ids={string.Join(",", ids.Take(100))}";
721+
}
722+
701723
#endregion Tracks
702724
}
703725
}

0 commit comments

Comments
 (0)