Added Artist Overview.

This commit is contained in:
Joseph Milazzo
2017-05-05 14:33:46 -05:00
parent 3662bb933b
commit 6aff6de378
6 changed files with 64 additions and 19 deletions
@@ -182,7 +182,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
httpRequest1.SuppressHttpError = true;
var httpResponse = _httpClient.Get<ArtistResource>(httpRequest1);
var httpResponse2 = _httpClient.Get<ArtistResource>(httpRequest2);
if (httpResponse.HasHttpError)
{
@@ -197,18 +197,18 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
}
List<Artist> artists = MapArtists(httpResponse.Resource);
if (httpResponse2.HasHttpError)
List<Artist> newArtists = new List<Artist>(artists.Count);
int count = 0;
foreach (var artist in artists)
{
if (artists.Count == 1)
{
artists[0].Overview = httpResponse2.Resource.StorePlatformData.Artist.Results[itunesId].artistBio;
}
newArtists.Add(AddOverview(artist));
count++;
}
// I don't know how we are getting tracks from iTunes yet.
return new Tuple<Artist, List<Track>>(artists[0], new List<Track>());
return new Tuple<Artist, List<Track>>(newArtists[0], new List<Track>());
}
public List<Artist> SearchForNewArtist(string title)
{
try
@@ -247,7 +247,18 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
var httpResponse = _httpClient.Get<ArtistResource>(httpRequest);
return MapArtists(httpResponse.Resource);
List<Artist> artists = MapArtists(httpResponse.Resource);
List<Artist> newArtists = new List<Artist>(artists.Count);
int count = 0;
foreach (var artist in artists)
{
newArtists.Add(AddOverview(artist));
count++;
}
return newArtists;
}
catch (HttpException)
{
@@ -260,6 +271,24 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
}
}
private Artist AddOverview(Artist artist)
{
var httpRequest = _internalRequestBuilder.Create()
.SetSegment("route", "viewArtist")
.AddQueryParam("id", artist.ItunesId.ToString())
.Build();
httpRequest.Headers.Add("X-Apple-Store-Front", "143459-2,32 t:music3");
httpRequest.Headers.ContentType = "application/json";
var httpResponse = _httpClient.Get<ArtistResource>(httpRequest);
if (!httpResponse.HasHttpError)
{
artist.Overview = httpResponse.Resource.StorePlatformData.Artist.Results[artist.ItunesId].artistBio;
}
return artist;
}
private Artist MapArtistInfo(ArtistInfoResource resource)
{
// This expects ArtistInfoResource, thus just need to populate one artist