diff --git a/SpotifyAPI/Local/Models/SpotifyResource.cs b/SpotifyAPI/Local/Models/SpotifyResource.cs index 39d501a4..e2b733cb 100644 --- a/SpotifyAPI/Local/Models/SpotifyResource.cs +++ b/SpotifyAPI/Local/Models/SpotifyResource.cs @@ -13,5 +13,10 @@ namespace SpotifyAPI.Local.Models [JsonProperty("location")] public TrackResourceLocation Location { get; set; } + + public SpotifyUri ParseUri() + { + return new SpotifyUri(this.Uri); + } } } \ No newline at end of file diff --git a/SpotifyAPI/Local/Models/SpotifyUri.cs b/SpotifyAPI/Local/Models/SpotifyUri.cs new file mode 100644 index 00000000..0e4d58dc --- /dev/null +++ b/SpotifyAPI/Local/Models/SpotifyUri.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SpotifyAPI.Local.Models +{ + public class SpotifyUri + { + public string Base { get; internal set; } + public string Type { get; internal set; } + public string Id { get; internal set; } + + public SpotifyUri(string Uri) + { + string[] props = Uri.Split(':'); + this.Base = props[0]; + this.Type = props[1]; + this.Id = props[2]; + } + } +} diff --git a/SpotifyAPI/Local/Models/Track.cs b/SpotifyAPI/Local/Models/Track.cs index 22889017..8c18ac0e 100644 --- a/SpotifyAPI/Local/Models/Track.cs +++ b/SpotifyAPI/Local/Models/Track.cs @@ -157,10 +157,5 @@ namespace SpotifyAPI.Local.Models return wc.DownloadData(url); } } - - public string GetId() - { - return this.TrackResource.Uri.Substring(14); - } } } \ No newline at end of file diff --git a/SpotifyAPI/SpotifyAPI.csproj b/SpotifyAPI/SpotifyAPI.csproj index ed3dcfd8..14acdb00 100644 --- a/SpotifyAPI/SpotifyAPI.csproj +++ b/SpotifyAPI/SpotifyAPI.csproj @@ -56,6 +56,7 @@ Component +