From a779063f763870192bc23cbe35d1c24f823ca779 Mon Sep 17 00:00:00 2001 From: "Johnny @PC" Date: Sat, 1 Feb 2014 20:34:23 +0100 Subject: [PATCH] Changed WebClient handling/Added Exceptions --- SpotifyAPI.dll | Bin 25088 -> 24576 bytes SpotifyAPI/Track.cs | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/SpotifyAPI.dll b/SpotifyAPI.dll index fabeebbedc1c1438bf580cd219c99ea99deaa8c8..c7b23b6d3c180c06b63acc640c7ad22ba8cb072a 100644 GIT binary patch delta 1265 zcmYk6TTC2P7{~u-c6MgFyNvA4?#!~>Z)NQQfk43&FGVSZ0Ag66fRwVZY77Q6OI=JM ztdZ0UO@O?r~^Kj-)V zzMRX!s?i?Yji0S};jfL3||A1)@a%&C@u>R~TVH z4)tFwrE{z2w|omdRV@+q#bpa4AquyQ~b{n?0OajJyxXtr2jRKM|;&mpoFHT9l-* z(-QBZB-Nhk@wp+%Q%8y1NQqhIo*e1zs3JUKsFwoM^cxuE?)8YiU8b5NIXvQ2ErqZl z-LYiJa^SJk%wQpNrOj}6L2O3Q+}0306Y!a~02wp$@S1(TC1^%Tj>7WS?LcW?1Pk{8 z*%T=~+}GYh?d!xFMpy7JR{oUsfk(nGnyM=JL)&pnxJ`X0%JfZHLajba(RSnMygfGg zxc0M+VZnHzFyffs*>6sD63(nMY#40~8OqH%$Bx2B|DR%k140Exke4CHKUsdFI*aT| z4$=J#oc( ztXi=Tl>&_63yZEOB}89Yv_Y|P{9w^G#m4b#hSKxJuv*8jhTLq^xDgr`*lD9F{0$pf z)^6F#u&O!5N~~!GsK;fkjQT09N!(@!goENOCg`nVJ+ky}(xBcidIa+u)nnIx-IhcB zIr3w=LAvJsjC4Z3Dz;-kT&6Q(g~a=t-~SGm+&cR7=5IVq&1S( z6EMhe;kH;!7r@NSP5Y(jGybhw6xf&i)tWB$3BOU(#QrqY+IvK{W|Zz9)5KVGI?5M2 zUgm|Jr<9hd#N;zm(O3(afU(lKZl}|>`tg$|Kff91es{Lv`-O`?J!<$OKZ>qwS@xDI z`F8J%cK+Xyt*Sc@k$DmG=!zxjWl7RQ)DvlmT&h-_hkFC9i@gn-^_OQnDJGUMy7dK2~9Uy_cjSYW@5T=3|HWRaU{me1(^qS|AHAk4G?;_(|sOhiL~HPK2G zD-=JYTCoG9W%}R)%-(MPw=`JPLkdU(H*C-tM$=Tom1Rj;JhN7_mLx$MllNS502NUfrgyVH3M-ah_|T+W{3uACj)52sgS z-U)bu0_J&pPGC;V68+glNlK|ftet}FD~%?zwjpf?HdwsfB**DGn0=+p;@VW)m9aS@QNOFXd+#%u~`& z28IP?zA$8&v+Y(VUZ72#VTTabna6&C9fnQ4cr4`93l$iEE6psMb~iDf&Ww&+VzoMR zINUgbR-H-YJAwl`D{y?s!Z@lkpW|a<@wqhBrifrxcb=v+5pbQIqcjn`^S{VJyr=t? z9R(P~Cp!DWQ9|sN&hC(J2tVj-gM34{muA|0!}zGiuI_M+{o$^_FgBG{?~uS!%3j}h zY~Z}~&`^d;l2xq4b*TWg_);n(`>xa=w&1>$5H?u7&?r7+S#q;ji+s6*aEII@W(n$v z)ndzi+mK6kg7lcI5MImvl<;NwE0Le@H+GC01Bl^$!UpsZ9>saW8Z;8VhHHdAbQ12> zFr?uOE|HRnKg9rj_-dp_(@W8*7z1w#>^4sY+u2RN8f;)2il=&;$gV5CxCqzBy1(|~@~cnJUt!-~zG2@~PIdh#nljDC>~aU6KKNSz|Na`)m!D5V zEK}6_fUZzeXuTuv?F;dx{a2Tk66Y3|ON`3dUNg&X)Bken2QaSMMX6#*2v4VqUHqHA Z$CaXi38pyu|1t>4N0qFBUs)<>{s#*H8!P|- diff --git a/SpotifyAPI/Track.cs b/SpotifyAPI/Track.cs index 3a7aac14..26d5c16e 100644 --- a/SpotifyAPI/Track.cs +++ b/SpotifyAPI/Track.cs @@ -88,16 +88,16 @@ namespace SpotifyAPIv1 String url = GetAlbumArtURL(size); if (url == "") return new Bitmap(640, 640); - byte[] stream = null; + byte[] data = null; try { - stream = await wc.DownloadDataTaskAsync(url); + data = await wc.DownloadDataTaskAsync(url); } catch(WebException e) { - stream = wc.DownloadData(@"http://www.51allout.co.uk/wp-content/uploads/2012/02/Image-not-found.gif"); + throw; } - using (MemoryStream ms = new MemoryStream(stream)) + using (MemoryStream ms = new MemoryStream(data)) { return (Bitmap)Image.FromStream(ms); } @@ -111,7 +111,16 @@ namespace SpotifyAPIv1 String url = GetAlbumArtURL(size); if (url == "") return new Bitmap(640,640); - using (MemoryStream ms = new MemoryStream(wc.DownloadData(url))) + byte[] data = null; + try + { + data = wc.DownloadData(url); + } + catch (WebException e) + { + throw; + } + using (MemoryStream ms = new MemoryStream(data)) { return (Bitmap)Image.FromStream(ms); }