Albums can now be seen per artist from search.

pull/6/head
Joseph Milazzo 8 years ago
parent de21685896
commit 5b0f11b19a

@ -12,7 +12,9 @@ namespace NzbDrone.Api.Music
public string AlbumName { get; set; }
public bool Monitored { get; set; }
public int Year { get; set; }
public List<string> Genre { get; set; }
public List<string> Genres { get; set; }
public string ArtworkUrl { get; set; }
}
public static class AlbumResourceMapper
@ -26,7 +28,9 @@ namespace NzbDrone.Api.Music
AlbumId = model.AlbumId,
Monitored = model.Monitored,
Year = model.Year,
AlbumName = model.Title
AlbumName = model.Title,
Genres = model.Genres,
ArtworkUrl = model.ArtworkUrl
};
}
@ -39,7 +43,9 @@ namespace NzbDrone.Api.Music
AlbumId = resource.AlbumId,
Monitored = resource.Monitored,
Year = resource.Year,
Title = resource.AlbumName
Title = resource.AlbumName,
Genres = resource.Genres,
ArtworkUrl = resource.ArtworkUrl
};
}

@ -16,6 +16,14 @@ namespace NzbDrone.Core.MetadataSource.SkyHook.Resource
public int ArtistId { get; set; }
public string CollectionName { get; set; }
public int CollectionId { get; set; }
public string PrimaryGenreName { get; set; }
public string ArtworkUrl100 { get; set; }
public string Country { get; set; }
public string CollectionExplicitness { get; set; }
public int TrackCount { get; set; }
public string Copyright { get; set; }
public DateTime ReleaseDate { get; set; }
}
public class ArtistResource

@ -163,32 +163,12 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
var httpResponse = _httpClient.Get<ArtistResource>(httpRequest);
//Console.WriteLine("Response: ", httpResponse.GetType());
//_logger.Info("Response: ", httpResponse.Resource.ResultCount);
//_logger.Info("HTTP Response: ", httpResponse.Resource.ResultCount);
//var tempList = new List<Artist>();
//var tempSeries = new Artist();
//tempSeries.ArtistName = "AFI";
//tempList.Add(tempSeries);
//return tempList;
Album tempAlbum;
List<Artist> artists = new List<Artist>();
ArtistComparer artistComparer = new ArtistComparer();
foreach (var album in httpResponse.Resource.Results)
{
tempAlbum = new Album();
// TODO: Perform MapAlbum call here
tempAlbum.AlbumId = album.CollectionId;
tempAlbum.Title = album.CollectionName;
int index = artists.FindIndex(a => a.ItunesId == album.ArtistId);
tempAlbum = MapAlbum(album);
if (index >= 0)
{
@ -200,6 +180,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
// TODO: Perform the MapArtist call here
tempArtist.ItunesId = album.ArtistId;
tempArtist.ArtistName = album.ArtistName;
tempArtist.Genres.Add(album.PrimaryGenreName);
tempArtist.Albums.Add(tempAlbum);
artists.Add(tempArtist);
}
@ -207,10 +188,6 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
}
return artists;
// I need to return a list of mapped artists.
//return httpResponse.Resource.Results.SelectList(MapArtist);
}
catch (HttpException)
{
@ -223,15 +200,16 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
}
}
private static Artist MapArtist(ArtistResource artistQuery)
private Album MapAlbum(AlbumResource albumQuery)
{
var artist = new Artist();
//artist.ItunesId = artistQuery.ItunesId; ;
// artist.ArtistName = artistQuery.ArtistName;
return artist;
Album album = new Album();
album.AlbumId = albumQuery.CollectionId;
album.Title = albumQuery.CollectionName;
album.Year = albumQuery.ReleaseDate.Year;
album.ArtworkUrl = albumQuery.ArtworkUrl100;
album.Explicitness = albumQuery.CollectionExplicitness;
return album;
}
private static Series MapSeries(ShowResource show)

@ -22,5 +22,8 @@ namespace NzbDrone.Core.Music
public bool Monitored { get; set; }
public List<MediaCover.MediaCover> Images { get; set; }
public List<Actor> Actors { get; set; } // These are band members. TODO: Refactor
public List<string> Genres { get; set; }
public string ArtworkUrl { get; set; }
public string Explicitness { get; set; }
}
}

@ -9,20 +9,6 @@ using System.Text;
namespace NzbDrone.Core.Music
{
public class ArtistComparer : IEqualityComparer<Artist>
{
public bool Equals(Artist x, Artist y)
{
return x.ItunesId == y.ItunesId;
}
public int GetHashCode(Artist obj)
{
throw new NotImplementedException();
}
}
public class Artist : ModelBase
{
public Artist()
@ -46,7 +32,6 @@ namespace NzbDrone.Core.Music
//public SeriesStatusType Status { get; set; }
public string Overview { get; set; }
public bool Monitored { get; set; }
//public int ProfileId { get; set; }
public bool AlbumFolder { get; set; }
public DateTime? LastInfoSync { get; set; }
//public int Runtime { get; set; }

@ -15,9 +15,8 @@ module.exports = Backbone.Collection.extend({
if (self.unmappedFolderModel) {
model.path = self.unmappedFolderModel.get('folder').path;
}
console.log('model: ', model);
});
console.log('response: ', response); // Note: this gets called after api responds with artist model
console.log('response: ', response);
return response;
}

@ -6,8 +6,7 @@ var Marionette = require('marionette');
var Profiles = require('../Profile/ProfileCollection');
var RootFolders = require('./RootFolders/RootFolderCollection');
var RootFolderLayout = require('./RootFolders/RootFolderLayout');
//var SeriesCollection = require('../Series/SeriesCollection');
var SeriesCollection = require('../Artist/ArtistCollection');
var ArtistCollection = require('../Artist/ArtistCollection');
var Config = require('../Config');
var Messenger = require('../Shared/Messenger');
var AsValidatedView = require('../Mixins/AsValidatedView');
@ -94,7 +93,7 @@ var view = Marionette.ItemView.extend({
},
_configureTemplateHelpers : function() {
var existingSeries = SeriesCollection.where({ tvdbId : this.model.get('tvdbId') });
var existingSeries = ArtistCollection.where({ iTunesId : this.model.get('itunesId') });
if (existingSeries.length > 0) {
this.templateHelpers.existing = existingSeries[0].toJSON();
@ -170,20 +169,22 @@ var view = Marionette.ItemView.extend({
this._addSeries(true);
},
_addSeries : function(searchForMissingEpisodes) {
var addButton = this.ui.addButton;
var addSearchButton = this.ui.addSearchButton;
_addSeries : function(searchForMissing) {
// TODO: Refactor to handle multiple add buttons/albums
var addButton = this.ui.addButton[0];
var addSearchButton = this.ui.addSearchButton[0];
console.log('_addSeries, searchForMissing=', searchForMissing);
addButton.addClass('disabled');
addSearchButton.addClass('disabled');
var profile = this.ui.profile.val();
var rootFolderPath = this.ui.rootFolder.children(':selected').text();
var seriesType = this.ui.seriesType.val();
var seriesType = this.ui.seriesType.val(); // Perhaps make this a differnitator between artist or Album?
var seasonFolder = this.ui.seasonFolder.prop('checked');
var options = this._getAddSeriesOptions();
options.searchForMissingEpisodes = searchForMissingEpisodes;
options.searchForMissing = searchForMissing;
this.model.set({
profileId : profile,
@ -197,7 +198,7 @@ var view = Marionette.ItemView.extend({
var self = this;
var promise = this.model.save();
if (searchForMissingEpisodes) {
if (searchForMissing) {
this.ui.addSearchButton.spinForPromise(promise);
}
@ -212,7 +213,7 @@ var view = Marionette.ItemView.extend({
promise.done(function() {
console.log('[SearchResultView] _addSeries promise resolve:', self.model);
SeriesCollection.add(self.model);
ArtistCollection.add(self.model);
self.close();
@ -222,7 +223,7 @@ var view = Marionette.ItemView.extend({
goToSeries : {
label : 'Go to Series',
action : function() {
Backbone.history.navigate('/series/' + self.model.get('titleSlug'), { trigger : true });
Backbone.history.navigate('/artist/' + self.model.get('titleSlug'), { trigger : true });
}
}
},
@ -241,6 +242,7 @@ var view = Marionette.ItemView.extend({
_getAddSeriesOptions : function() {
var monitor = this.ui.monitor.val();
//[TODO]: Refactor for albums
var lastSeason = _.max(this.model.get('seasons'), 'seasonNumber');
var firstSeason = _.min(_.reject(this.model.get('seasons'), { seasonNumber : 0 }), 'seasonNumber');

@ -1,31 +1,26 @@
<div class="search-item {{#unless isExisting}}search-item-new{{/unless}}">
<div class="row">
<div class="col-md-2">
<a href="{{tvdbUrl}}" target="_blank">
{{poster}}
</a>
</div>
<div class="col-md-10">
<div class="row">
<div class="col-md-12">
<h2 class="series-title">
{{titleWithYear}}
<!--{{titleWithYear}}-->
{{artistName}}
<span class="labels">
<!--<span class="labels">
<span class="label label-default">{{network}}</span>
{{#unless_eq status compare="continuing"}}
<span class="label label-danger">Ended</span>
{{/unless_eq}}
</span>
</span>-->
</h2>
</div>
</div>
<div class="row new-series-overview x-overview">
<!-- <div class="row new-series-overview x-overview">
<div class="col-md-12 overview-internal">
{{overview}}
</div>
</div>
</div> -->
<div class="row">
{{#unless existing}}
{{#unless path}}
@ -56,7 +51,7 @@
</div>-->
<div class="form-group col-md-2">
<label>Season Folders</label>
<label>Album Folders</label>
<div class="input-group">
<label class="checkbox toggle well">
@ -73,7 +68,7 @@
</div>
<div class="row">
{{#unless existing}}
{{#if title}}
{{#if artistName}}
<div class="form-group col-md-2 col-md-offset-10">
<!--Uncomment if we need to add even more controls to add series-->
<!--<label style="visibility: hidden">Add</label>-->
@ -82,13 +77,56 @@
<i class="icon-sonarr-add"></i>
</button>
<button class="btn btn-success add x-add-search" title="Add and Search for missing episodes">
<button class="btn btn-success add x-add-search" title="Add and Search for missing tracks">
<i class="icon-sonarr-search"></i>
</button>
</div>
</div>
{{else}}
<div class="col-md-2 col-md-offset-10">
<button class="btn add-series disabled">
Add
</button>
</div>
{{/if}}
{{else}}
<div class="col-md-2 col-md-offset-10">
<a class="btn btn-default" href="{{route}}">
Already Exists
</a>
</div>
{{/unless}}
</div>
</div>
</div>
<div class="row">
{{#each albums}}
<div class="col-md-12" style="border:1px dashed black;">
<div class="col-md-2">
<a href="{{artworkUrl}}" target="_blank">
<!-- {{poster}} -->
<img class="album-poster" src="{{artworkUrl}}">
</a>
</div>
<div class="col-md-8">
<h2>{{albumName}} ({{year}})</h2>
{{#unless existing}}
{{#if albumName}}
<div class="form-group col-md-offset-10">
<!--Uncomment if we need to add even more controls to add series-->
<!--<label style="visibility: hidden">Add</label>-->
<div class="btn-group">
<button class="btn btn-success add x-add" title="Add">
<i class="icon-sonarr-add"></i>
</button>
<button class="btn btn-success add x-add-search" title="Add and Search for missing tracks">
<i class="icon-sonarr-search"></i>
</button>
</div>
</div>
{{else}}
<div class="col-md-2 col-md-offset-10" title="Series requires an English title">
<div class="col-md-2 col-md-offset-10">
<button class="btn add-series disabled">
Add
</button>
@ -103,5 +141,6 @@
{{/unless}}
</div>
</div>
{{/each}}
</div>
</div>

@ -75,6 +75,14 @@
margin : 10px;
}
.album-poster {
min-width : 100px;
min-height : 100px;
max-width : 138px;
max-height : 203px;
margin : 10px;
}
a {
color : #343434;
}

@ -2,14 +2,14 @@
<div class="row">
<div class="well col-md-12">
<i class="icon-sonarr-comment"/>
You must be new around here, You should add some series.
You must be new around here, You should add some music.
</div>
</div>
<div class="row">
<div class="col-md-4 col-md-offset-4">
<a href="/addseries" class='btn btn-lg btn-block btn-success x-add-series'>
<i class='icon-sonarr-add'></i>
Add Series
Add Music
</a>
</div>
</div>

Loading…
Cancel
Save