Added Artist Overview.

pull/6/head
Joseph Milazzo 8 years ago
parent 3662bb933b
commit 6aff6de378

@ -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

@ -79,18 +79,17 @@ namespace NzbDrone.Core.Music
}
catch (SeriesNotFoundException)
{
_logger.Error("tvdbid {1} was not found, it may have been removed from TheTVDB.", newArtist.ItunesId);
_logger.Error("iTunesId {1} was not found, it may have been removed from iTunes.", newArtist.ItunesId);
throw new ValidationException(new List<ValidationFailure>
{
new ValidationFailure("TvdbId", "A series with this ID was not found", newArtist.ItunesId)
new ValidationFailure("iTunesId", "An artist with this ID was not found", newArtist.ItunesId)
});
}
var artist = tuple.Item1;
// If seasons were passed in on the new series use them, otherwise use the seasons from Skyhook
// TODO: Refactor for albums
// If albums were passed in on the new artist use them, otherwise use the albums from Skyhook
newArtist.Albums = newArtist.Albums != null && newArtist.Albums.Any() ? newArtist.Albums : artist.Albums;
artist.ApplyChanges(newArtist);

@ -71,6 +71,18 @@ Handlebars.registerHelper('seasonCountHelper', function() {
return new Handlebars.SafeString('<span class="label label-info">{0} Seasons</span>'.format(seasonCount));
});
Handlebars.registerHelper ('truncate', function (str, len) {
if (str && str.length > len && str.length > 0) {
var new_str = str + " ";
new_str = str.substr (0, len);
new_str = str.substr (0, new_str.lastIndexOf(" "));
new_str = (new_str.length > 0) ? new_str : str.substr (0, len);
return new Handlebars.SafeString ( new_str +'...' );
}
return str;
});
Handlebars.registerHelper('albumCountHelper', function() {
var albumCount = this.albumCount;

@ -20,12 +20,10 @@
</div>
</div>
<div class="row">
<div class="col-md-12 col-xs-12">
<a href="{{route}}">
<div>
{{overview}}
</div>
</a>
<div class="col-md-10 col-xs-12">
<div>
{{truncate overview 600}}
</div>
</div>
</div>
<div class="row">

@ -20,6 +20,7 @@ require('../../Mixins/backbone.signalr.mixin');
module.exports = Marionette.Layout.extend({
template : 'Series/Index/SeriesIndexLayoutTemplate',
regions : {
seriesRegion : '#x-series',
toolbar : '#x-toolbar',

@ -8,6 +8,12 @@
max-width: 100%;
}
.truncate {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.edit-series-modal, .delete-series-modal {
overflow : visible;

Loading…
Cancel
Save