mirror of https://github.com/lidarr/Lidarr
Added Artist Overview.
This commit is contained in:
parent
3662bb933b
commit
6aff6de378
|
@ -182,7 +182,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
httpRequest1.SuppressHttpError = true;
|
httpRequest1.SuppressHttpError = true;
|
||||||
|
|
||||||
var httpResponse = _httpClient.Get<ArtistResource>(httpRequest1);
|
var httpResponse = _httpClient.Get<ArtistResource>(httpRequest1);
|
||||||
var httpResponse2 = _httpClient.Get<ArtistResource>(httpRequest2);
|
|
||||||
|
|
||||||
if (httpResponse.HasHttpError)
|
if (httpResponse.HasHttpError)
|
||||||
{
|
{
|
||||||
|
@ -197,18 +197,18 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Artist> artists = MapArtists(httpResponse.Resource);
|
List<Artist> artists = MapArtists(httpResponse.Resource);
|
||||||
|
List<Artist> newArtists = new List<Artist>(artists.Count);
|
||||||
if (httpResponse2.HasHttpError)
|
int count = 0;
|
||||||
|
foreach (var artist in artists)
|
||||||
{
|
{
|
||||||
if (artists.Count == 1)
|
newArtists.Add(AddOverview(artist));
|
||||||
{
|
count++;
|
||||||
artists[0].Overview = httpResponse2.Resource.StorePlatformData.Artist.Results[itunesId].artistBio;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// I don't know how we are getting tracks from iTunes yet.
|
// 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)
|
public List<Artist> SearchForNewArtist(string title)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -247,7 +247,18 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
|
|
||||||
var httpResponse = _httpClient.Get<ArtistResource>(httpRequest);
|
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)
|
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)
|
private Artist MapArtistInfo(ArtistInfoResource resource)
|
||||||
{
|
{
|
||||||
// This expects ArtistInfoResource, thus just need to populate one artist
|
// This expects ArtistInfoResource, thus just need to populate one artist
|
||||||
|
|
|
@ -79,18 +79,17 @@ namespace NzbDrone.Core.Music
|
||||||
}
|
}
|
||||||
catch (SeriesNotFoundException)
|
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>
|
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;
|
var artist = tuple.Item1;
|
||||||
|
|
||||||
// If seasons were passed in on the new series use them, otherwise use the seasons from Skyhook
|
// If albums were passed in on the new artist use them, otherwise use the albums from Skyhook
|
||||||
// TODO: Refactor for albums
|
|
||||||
newArtist.Albums = newArtist.Albums != null && newArtist.Albums.Any() ? newArtist.Albums : artist.Albums;
|
newArtist.Albums = newArtist.Albums != null && newArtist.Albums.Any() ? newArtist.Albums : artist.Albums;
|
||||||
|
|
||||||
artist.ApplyChanges(newArtist);
|
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));
|
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() {
|
Handlebars.registerHelper('albumCountHelper', function() {
|
||||||
var albumCount = this.albumCount;
|
var albumCount = this.albumCount;
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12 col-xs-12">
|
<div class="col-md-10 col-xs-12">
|
||||||
<a href="{{route}}">
|
<div>
|
||||||
<div>
|
{{truncate overview 600}}
|
||||||
{{overview}}
|
</div>
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
|
@ -20,6 +20,7 @@ require('../../Mixins/backbone.signalr.mixin');
|
||||||
module.exports = Marionette.Layout.extend({
|
module.exports = Marionette.Layout.extend({
|
||||||
template : 'Series/Index/SeriesIndexLayoutTemplate',
|
template : 'Series/Index/SeriesIndexLayoutTemplate',
|
||||||
|
|
||||||
|
|
||||||
regions : {
|
regions : {
|
||||||
seriesRegion : '#x-series',
|
seriesRegion : '#x-series',
|
||||||
toolbar : '#x-toolbar',
|
toolbar : '#x-toolbar',
|
||||||
|
|
|
@ -8,6 +8,12 @@
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.truncate {
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
.edit-series-modal, .delete-series-modal {
|
.edit-series-modal, .delete-series-modal {
|
||||||
overflow : visible;
|
overflow : visible;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue