From 0cda8e2219c3b101bd9ea869f59da909e5eaee57 Mon Sep 17 00:00:00 2001 From: eltoncezar Date: Thu, 17 Mar 2016 11:46:12 -0300 Subject: [PATCH 1/5] Typo fix Changed SpotifyAPI.Web.Enums.Scope.UserLibrarayRead to UserLibraryRead --- SpotifyAPI/Web/Enums/Scope.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpotifyAPI/Web/Enums/Scope.cs b/SpotifyAPI/Web/Enums/Scope.cs index 0240450a..5e5d8ea6 100644 --- a/SpotifyAPI/Web/Enums/Scope.cs +++ b/SpotifyAPI/Web/Enums/Scope.cs @@ -27,7 +27,7 @@ namespace SpotifyAPI.Web.Enums UserReadEmail = 64, [String("user-library-read")] - UserLibrarayRead = 128, + UserLibraryRead = 128, [String("user-library-modify")] UserLibraryModify = 256, From fd8572bf93f442e02be6525899b1ee71682f9dd9 Mon Sep 17 00:00:00 2001 From: eltoncezar Date: Thu, 17 Mar 2016 18:58:10 -0300 Subject: [PATCH 2/5] Typo fix Forgot to include this in the last commit --- SpotifyAPI.Example/WebControl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpotifyAPI.Example/WebControl.cs b/SpotifyAPI.Example/WebControl.cs index 8fc82080..7670ee2a 100644 --- a/SpotifyAPI.Example/WebControl.cs +++ b/SpotifyAPI.Example/WebControl.cs @@ -30,7 +30,7 @@ namespace SpotifyAPI.Example { RedirectUri = "http://localhost:8000", ClientId = "26d287105e31491889f3cd293d85bfea", - Scope = Scope.UserReadPrivate | Scope.UserReadEmail | Scope.PlaylistReadPrivate | Scope.UserLibrarayRead | Scope.UserReadPrivate | Scope.UserFollowRead | Scope.UserReadBirthdate, + Scope = Scope.UserReadPrivate | Scope.UserReadEmail | Scope.PlaylistReadPrivate | Scope.UserLibraryRead | Scope.UserReadPrivate | Scope.UserFollowRead | Scope.UserReadBirthdate, State = "XSS" }; _auth.OnResponseReceivedEvent += _auth_OnResponseReceivedEvent; From a13aadc986a18ec9eb414020d21837fa291277f1 Mon Sep 17 00:00:00 2001 From: eltoncezar Date: Thu, 17 Mar 2016 19:03:01 -0300 Subject: [PATCH 3/5] New method GetId Just a simple way to get the track id to use in the Web API. --- SpotifyAPI/Local/Models/Track.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SpotifyAPI/Local/Models/Track.cs b/SpotifyAPI/Local/Models/Track.cs index 8c18ac0e..22889017 100644 --- a/SpotifyAPI/Local/Models/Track.cs +++ b/SpotifyAPI/Local/Models/Track.cs @@ -157,5 +157,10 @@ namespace SpotifyAPI.Local.Models return wc.DownloadData(url); } } + + public string GetId() + { + return this.TrackResource.Uri.Substring(14); + } } } \ No newline at end of file From 1c5f6899eb511c33109c4146005d8d45046fb56c Mon Sep 17 00:00:00 2001 From: eltoncezar Date: Sun, 20 Mar 2016 01:02:15 -0300 Subject: [PATCH 4/5] First Implementation of SpotifyUri Following JohnnyCrazy's directives. --- SpotifyAPI/Local/Models/SpotifyResource.cs | 5 +++++ SpotifyAPI/Local/Models/SpotifyUri.cs | 23 ++++++++++++++++++++++ SpotifyAPI/Local/Models/Track.cs | 5 ----- SpotifyAPI/SpotifyAPI.csproj | 1 + 4 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 SpotifyAPI/Local/Models/SpotifyUri.cs 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 + From c1dc2313cbb1ce9285e616379cdc235ec55b17e5 Mon Sep 17 00:00:00 2001 From: eltoncezar Date: Mon, 21 Mar 2016 08:56:06 -0300 Subject: [PATCH 5/5] Error Handling --- SpotifyAPI/Local/Models/SpotifyUri.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/SpotifyAPI/Local/Models/SpotifyUri.cs b/SpotifyAPI/Local/Models/SpotifyUri.cs index 0e4d58dc..54df6dcc 100644 --- a/SpotifyAPI/Local/Models/SpotifyUri.cs +++ b/SpotifyAPI/Local/Models/SpotifyUri.cs @@ -12,12 +12,19 @@ namespace SpotifyAPI.Local.Models public string Type { get; internal set; } public string Id { get; internal set; } - public SpotifyUri(string Uri) + public SpotifyUri(string uri) { - string[] props = Uri.Split(':'); - this.Base = props[0]; - this.Type = props[1]; - this.Id = props[2]; + if (String.IsNullOrEmpty(uri)) + throw new ArgumentNullException("Uri"); + + string[] props = uri.Split(':'); + + if (props.Length != 3) + throw new ArgumentException("Unexpected Uri"); + + Base = props[0]; + Type = props[1]; + Id = props[2]; } } }