diff --git a/IF.Lastfm.Core/Api/Commands/AlbumApi/GetAbumInfoCommand.cs b/IF.Lastfm.Core/Api/Commands/AlbumApi/GetAlbumInfoCommand.cs similarity index 97% rename from IF.Lastfm.Core/Api/Commands/AlbumApi/GetAbumInfoCommand.cs rename to IF.Lastfm.Core/Api/Commands/AlbumApi/GetAlbumInfoCommand.cs index 77bff37..12934d7 100644 --- a/IF.Lastfm.Core/Api/Commands/AlbumApi/GetAbumInfoCommand.cs +++ b/IF.Lastfm.Core/Api/Commands/AlbumApi/GetAlbumInfoCommand.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Net.Http; -using System.Text; using System.Threading.Tasks; using IF.Lastfm.Core.Api.Enums; using IF.Lastfm.Core.Api.Helpers; @@ -34,6 +32,8 @@ public override Uri BuildRequestUrl() {"autocorrect", Convert.ToInt32(Autocorrect).ToString()} }; + base.DisableCaching(parameters); + var apiUrl = LastFm.FormatApiUrl(Method, Auth.ApiKey, parameters); return new Uri(apiUrl, UriKind.Absolute); } diff --git a/IF.Lastfm.Core/Api/Commands/ArtistApi/GetArtistInfoCommand.cs b/IF.Lastfm.Core/Api/Commands/ArtistApi/GetArtistInfoCommand.cs index 3295fec..8ea9a7f 100644 --- a/IF.Lastfm.Core/Api/Commands/ArtistApi/GetArtistInfoCommand.cs +++ b/IF.Lastfm.Core/Api/Commands/ArtistApi/GetArtistInfoCommand.cs @@ -33,6 +33,8 @@ public override Uri BuildRequestUrl() {"autocorrect", Convert.ToInt32(Autocorrect).ToString()} }; + base.DisableCaching(parameters); + var apiUrl = LastFm.FormatApiUrl(Method, Auth.ApiKey, parameters); return new Uri(apiUrl, UriKind.Absolute); } diff --git a/IF.Lastfm.Core/Api/Commands/GetAsyncCommandBase.cs b/IF.Lastfm.Core/Api/Commands/GetAsyncCommandBase.cs index 26ae384..6d01777 100644 --- a/IF.Lastfm.Core/Api/Commands/GetAsyncCommandBase.cs +++ b/IF.Lastfm.Core/Api/Commands/GetAsyncCommandBase.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Net.Http; +using System.Net.Http.Headers; using System.Threading.Tasks; namespace IF.Lastfm.Core.Api.Commands @@ -37,5 +38,15 @@ protected void AddPagingParameters(Dictionary parameters) parameters.Add("page", Page.ToString()); parameters.Add("limit", Count.ToString()); } + + /// + /// Annoying workaround for Windows Phone's caching... + /// see http://stackoverflow.com/questions/6334788/windows-phone-7-webrequest-caching + /// + /// + protected void DisableCaching(Dictionary parameters) + { + parameters.Add("disablecachetoken", DateTime.UtcNow.Ticks.ToString()); + } } } \ No newline at end of file diff --git a/IF.Lastfm.Core/Api/Commands/TrackApi/GetTrackInfoCommand.cs b/IF.Lastfm.Core/Api/Commands/TrackApi/GetTrackInfoCommand.cs index 2503d69..d5ccf4c 100644 --- a/IF.Lastfm.Core/Api/Commands/TrackApi/GetTrackInfoCommand.cs +++ b/IF.Lastfm.Core/Api/Commands/TrackApi/GetTrackInfoCommand.cs @@ -41,6 +41,8 @@ public override Uri BuildRequestUrl() parameters.Add("username", Username); } + DisableCaching(parameters); + var apiUrl = LastFm.FormatApiUrl(Method, Auth.ApiKey, parameters); return new Uri(apiUrl, UriKind.Absolute); } diff --git a/IF.Lastfm.Core/Api/Commands/TrackApi/GetTrackShoutsCommand.cs b/IF.Lastfm.Core/Api/Commands/TrackApi/GetTrackShoutsCommand.cs index 1aaa36a..3ca0360 100644 --- a/IF.Lastfm.Core/Api/Commands/TrackApi/GetTrackShoutsCommand.cs +++ b/IF.Lastfm.Core/Api/Commands/TrackApi/GetTrackShoutsCommand.cs @@ -35,6 +35,7 @@ public override Uri BuildRequestUrl() }; base.AddPagingParameters(parameters); + base.DisableCaching(parameters); var apiUrl = LastFm.FormatApiUrl(Method, Auth.ApiKey, parameters); return new Uri(apiUrl, UriKind.Absolute); diff --git a/IF.Lastfm.Core/Api/Commands/UserApi/GetRecentScrobblesCommand.cs b/IF.Lastfm.Core/Api/Commands/UserApi/GetRecentScrobblesCommand.cs index 8ca8315..c651bb6 100644 --- a/IF.Lastfm.Core/Api/Commands/UserApi/GetRecentScrobblesCommand.cs +++ b/IF.Lastfm.Core/Api/Commands/UserApi/GetRecentScrobblesCommand.cs @@ -31,6 +31,7 @@ public override Uri BuildRequestUrl() }; base.AddPagingParameters(parameters); + base.DisableCaching(parameters); var uristring = LastFm.FormatApiUrl(Method, Auth.ApiKey, parameters); return new Uri(uristring, UriKind.Absolute); diff --git a/IF.Lastfm.Core/Api/Commands/UserApi/GetTopAlbumsCommand.cs b/IF.Lastfm.Core/Api/Commands/UserApi/GetTopAlbumsCommand.cs index 7792f8e..e00adbc 100644 --- a/IF.Lastfm.Core/Api/Commands/UserApi/GetTopAlbumsCommand.cs +++ b/IF.Lastfm.Core/Api/Commands/UserApi/GetTopAlbumsCommand.cs @@ -32,6 +32,7 @@ public override Uri BuildRequestUrl() }; base.AddPagingParameters(parameters); + base.DisableCaching(parameters); var uristring = LastFm.FormatApiUrl(Method, Auth.ApiKey, parameters); return new Uri(uristring, UriKind.Absolute); diff --git a/IF.Lastfm.Core/IF.Lastfm.Core.csproj b/IF.Lastfm.Core/IF.Lastfm.Core.csproj index d32d932..dda8df6 100644 --- a/IF.Lastfm.Core/IF.Lastfm.Core.csproj +++ b/IF.Lastfm.Core/IF.Lastfm.Core.csproj @@ -41,7 +41,7 @@ - +