From 76f3a8716b21c8c6bdf897e420d7b5d7f44f1a9f Mon Sep 17 00:00:00 2001 From: "Johnny @PC" Date: Mon, 17 Feb 2014 12:58:15 +0100 Subject: [PATCH] Fixxed GetCFID (null-object check) | Implemented ExtendedWebClient with Timeout var | Example App updated | Fixxed Event Timer stopping randomly --- SpotifyAPI.dll | Bin 24576 -> 25088 bytes SpotifyAPI/ExtendedWebClient.cs | 21 ++++++++++++++++++++ SpotifyAPI/RemoteHandler.cs | 20 +++++++++++-------- SpotifyAPI/SpotifyAPI.csproj | 3 +++ SpotifyAPI/SpotifyEventHandler.cs | 10 +++++++++- SpotifyAPI_Example/Form1.cs | 31 ++++++++++++++++++++++++++++-- 6 files changed, 74 insertions(+), 11 deletions(-) create mode 100644 SpotifyAPI/ExtendedWebClient.cs diff --git a/SpotifyAPI.dll b/SpotifyAPI.dll index 19fdcf2f754a263dadb828489185a54b72129479..40a7043e03f4ffc93328e20210f721b3f642f3fe 100644 GIT binary patch literal 25088 zcmeHvd3apamFIb{R+XfZs!FSE+2sYhY+15w%f^6gOO|9?U|U9#7r-EuR8Ml@Qa$BW z$qSBx9Ee%s5FmtfAY=@r15AJbADu9Pyf0;}}?4S1~ zKRsFU{QRf1ZO_ji*dI@YCoFT!ijIdzqRFJ04i6h)Ycd&*C&OL6{o!#lW;BPX(EUmlt-W;c22e4#dpYNuo0FUN}TFXQu2g;V^9H$-Tf^^Kf(8IGhHKT?PV~ z^i}x{B(E^hP_vb?Mu5b(X%u*%_TioPYR7OjTSmf!BKt}w@n%~?c;~&^i8kdyDYkQ5 z@nYX}a?u^@h}t$1X~KQ)B-El2Mvm(T^rN6oUn9AfEzliP43=f&a1V0OoSeZ7IR+#r zXD~yKVC3WsvT`WHzAInOVA)(f5+w3v^=v*11wii7M)I(|YTGXdwIF_Q0`_Xyp1aiJh@j+4Bcb#%{r$}K zdLoEtqtER*tJR#<%1fGFL|f;sTlXI7qH}1swy@n2yItm@U4-o1?ar(#?f#8*(KWP- z8u|V8+3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&&vQ_VC(CAF{?E@ayIM~#H8ymw1>i$C7k0(Od%h%Y;Mm$&xuP~p3170|f zUW6&=aRdkKWu&~X^msyNVD^NLy5LQyUM6mTmqzm&c6IjW?g_0{w=Xu~m)B=&)E}tI ziTKhD-zo4_QHbkAbCM`@=iou7dw7z~Q-e}a1oYgqexc{7W#t1F|sazvZ6Mh7afB5+{fY?RB%l7dI zDl(&fJ#rDAxY%W;atS;lgtLaIiy_^h`b@4b+m;7O!jCv;3?+JmHO5VRA|+w~z)?#45ngZSKqw7FX}|Eu#? zr|hT2xCMUMpGa%v#VJF9S>bhnYOu;F)>foCoUC^tb={BThhNKyYxP4K2RALrDyL$c z-rBE+oKYCn;1j2Ed|fws8cT1$6@KC{`>z>^9%4YP#Lp~dTkb&XoJz5s3E0cGQ=F8x z;rYWZX}(dOh0NC9gZiA(=j%1$f+c(XX}8C}BIX|2i909pNyIQNsUVdku68@QD`>R1 z9nW&&m(OTtRBE;(5)()l?WAB9)L>_@gA>=mb` zf7_q+62Bg_Zz2JmMC>vJy*Yh-n1v7g3~6z_(&&}OZoSlLLwxzNmao*4=y?>gr#R}R c^|-zN6t4;U?{nNJzsLGd(c}N$$$|*{FI8*tk^lez diff --git a/SpotifyAPI/ExtendedWebClient.cs b/SpotifyAPI/ExtendedWebClient.cs new file mode 100644 index 00000000..e7485210 --- /dev/null +++ b/SpotifyAPI/ExtendedWebClient.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Net; + +namespace SpotifyAPIv1 +{ + class ExtendedWebClient : WebClient + { + public int Timeout { get; set; } + + protected override WebRequest GetWebRequest(Uri address) + { + WebRequest webRequest = base.GetWebRequest(address); + webRequest.Timeout = Timeout; + return webRequest; + } + } +} diff --git a/SpotifyAPI/RemoteHandler.cs b/SpotifyAPI/RemoteHandler.cs index 6eff3477..96f4a044 100644 --- a/SpotifyAPI/RemoteHandler.cs +++ b/SpotifyAPI/RemoteHandler.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; +using System.Threading.Tasks; +using System.Threading; using Newtonsoft.Json; namespace SpotifyAPIv1 @@ -16,8 +18,7 @@ namespace SpotifyAPIv1 public String host = "127.0.0.1"; - WebClient wc; - SpotifyMusicHandler mh; + ExtendedWebClient wc; internal static RemoteHandler GetInstance() { return instance; @@ -25,8 +26,9 @@ namespace SpotifyAPIv1 internal RemoteHandler() { - - wc = new WebClient(); + + wc = new ExtendedWebClient(); + wc.Timeout = 2000; wc.Proxy = null; wc.Headers.Add("Origin", "https://embed.spotify.com"); wc.Headers.Add("Referer", "https://embed.spotify.com/?uri=spotify:track:5Zp4SWOpbuOdnsxLqwgutt"); @@ -81,13 +83,15 @@ namespace SpotifyAPIv1 string a = query("simplecsrf/token.json", false, false, -1); a = a.Replace(@"\", ""); List d = (List)JsonConvert.DeserializeObject(a, typeof(List)); + if (d == null) + return ""; if (d.Count != 1) throw new Exception("CFID couldn't be loaded"); if (d[0].error != null) return ""; return d[0].token; } - internal string query(string request, bool oauth, bool cfid, int wait) + internal String query(string request, bool oauth, bool cfid, int wait) { string parameters = "?&ref=&cors=&_=" + GetTimestamp(); if (request.Contains("?")) @@ -114,13 +118,13 @@ namespace SpotifyAPIv1 string response = ""; try { - //Need to find a better solution... - if(SpotifyAPI.IsSpotifyRunning()) + //Need to find a better solution + if (SpotifyAPI.IsSpotifyRunning()) response = "[ " + wc.DownloadString(a) + " ]"; } catch (Exception z) { - throw; + return ""; } return response; } diff --git a/SpotifyAPI/SpotifyAPI.csproj b/SpotifyAPI/SpotifyAPI.csproj index 0f795160..5c3d135e 100644 --- a/SpotifyAPI/SpotifyAPI.csproj +++ b/SpotifyAPI/SpotifyAPI.csproj @@ -47,6 +47,9 @@ + + Component + diff --git a/SpotifyAPI/SpotifyEventHandler.cs b/SpotifyAPI/SpotifyEventHandler.cs index 3b4cecbb..8f1c84a9 100644 --- a/SpotifyAPI/SpotifyEventHandler.cs +++ b/SpotifyAPI/SpotifyEventHandler.cs @@ -61,8 +61,16 @@ namespace SpotifyAPIv1 return; } StatusResponse new_response = mh.GetStatusResponse(); - if (!new_response.running && new_response.track == null) + if(new_response == null) + { + timer.Start(); return; + } + if (!new_response.running && new_response.track == null) + { + timer.Start(); + return; + } if (new_response.track != null && response.track != null) { if (new_response.track.GetTrackName() != response.track.GetTrackName() && OnTrackChange != null) diff --git a/SpotifyAPI_Example/Form1.cs b/SpotifyAPI_Example/Form1.cs index cb69410e..8c957c4f 100644 --- a/SpotifyAPI_Example/Form1.cs +++ b/SpotifyAPI_Example/Form1.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using SpotifyAPIv1; +using System.Threading; using SpotifyEventHandler = SpotifyAPIv1.SpotifyEventHandler; @@ -22,11 +23,37 @@ namespace SpotifyAPI_Example { InitializeComponent(); spotify = new SpotifyAPI(); - if(!SpotifyAPI.IsSpotifyRunning()) + if (!SpotifyAPI.IsSpotifyRunning()) + { spotify.RunSpotify(); + Thread.Sleep(4000); + } + if (!SpotifyAPI.IsSpotifyWebHelperRunning()) + { spotify.RunSpotifyWebHelper(); - spotify.Connect(); + Thread.Sleep(4000); + } + + if(!spotify.Connect()) + { + Boolean retry = true; + while(retry) + { + if (MessageBox.Show("SpotifyAPI could'nt load!", "Error", MessageBoxButtons.RetryCancel) == System.Windows.Forms.DialogResult.Retry) + { + if(spotify.Connect()) + retry = false; + else + retry = true; + } + else + { + this.Close(); + return; + } + } + } mh = spotify.GetMusicHandler(); eh = spotify.GetEventHandler(); }