More Work on Album Filtering per Artist

pull/94/head
Qstick 7 years ago
parent 6a4fb9adf3
commit f812302aa5

@ -167,28 +167,6 @@ class AddNewArtistModalContent extends Component {
/>
</FormGroup>
<FormGroup>
<FormLabel>Primary Album Types</FormLabel>
<FormInputGroup
type={inputTypes.TEXT}
name="primaryAlbumTypes"
onChange={onInputChange}
{...primaryAlbumTypes}
/>
</FormGroup>
<FormGroup>
<FormLabel>Secondary Album Types</FormLabel>
<FormInputGroup
type={inputTypes.TEXT}
name="secondaryAlbumTypes"
onChange={onInputChange}
{...secondaryAlbumTypes}
/>
</FormGroup>
<FormGroup>
<FormLabel>Tags</FormLabel>

@ -23,8 +23,8 @@ export const defaultState = {
qualityProfileId: 0,
languageProfileId: 0,
seriesType: 'standard',
primaryAlbumTypes: 'Studio, Single',
secondaryAlbumTypes: '',
primaryAlbumTypes: ['Album'],
secondaryAlbumTypes: ['Studio'],
albumFolder: true,
tags: []
}

@ -29,8 +29,8 @@ namespace Lidarr.Api.V3.Artist
public string Overview { get; set; }
public string ArtistType { get; set; }
public string Disambiguation { get; set; }
public string PrimaryAlbumTypes { get; set; }
public string SecondaryAlbumTypes { get; set; }
public List<string> PrimaryAlbumTypes { get; set; }
public List<string> SecondaryAlbumTypes { get; set; }
public List<Links> Links { get; set; }
public int? AlbumCount { get; set; }

@ -26,7 +26,7 @@ namespace NzbDrone.Core.Test.MetadataSource.SkyHook
[TestCase("66c662b6-6e2f-4930-8610-912e24c63ed1", "AC/DC")]
public void should_be_able_to_get_artist_detail(string mbId, string name)
{
var details = Subject.GetArtistInfo(mbId);
var details = Subject.GetArtistInfo(mbId, new List<string> { "Album" }, new List<string> { "Studio" });
ValidateArtist(details.Item1);
ValidateAlbums(details.Item2);
@ -37,13 +37,13 @@ namespace NzbDrone.Core.Test.MetadataSource.SkyHook
[Test]
public void getting_details_of_invalid_artist()
{
Assert.Throws<ArtistNotFoundException>(() => Subject.GetArtistInfo("aaaaaa-aaa-aaaa-aaaa"));
Assert.Throws<ArtistNotFoundException>(() => Subject.GetArtistInfo("aaaaaa-aaa-aaaa-aaaa", new List<string> { "Album" }, new List<string> { "Studio" }));
}
[Test]
public void should_not_have_period_at_start_of_name_slug()
{
var details = Subject.GetArtistInfo("f59c5520-5f46-4d2c-b2c4-822eabf53419");
var details = Subject.GetArtistInfo("b6db95cd-88d9-492f-bbf6-a34e0e89b2e5", new List<string> { "Album" }, new List<string> { "Studio" });
details.Item1.NameSlug.Should().Be("dothack");
}
@ -65,10 +65,6 @@ namespace NzbDrone.Core.Test.MetadataSource.SkyHook
{
albums.Should().NotBeEmpty();
var episodeGroup = albums.GroupBy(e => e.AlbumType + e.Title);
episodeGroup.Should().OnlyContain(c => c.Count() == 1);
foreach (var episode in albums)
{
ValidateAlbum(episode);

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using FizzWare.NBuilder;
@ -33,7 +33,7 @@ namespace NzbDrone.Core.Test.MusicTests
private void GivenValidArtist(string lidarrId)
{
Mocker.GetMock<IProvideArtistInfo>()
.Setup(s => s.GetArtistInfo(lidarrId))
.Setup(s => s.GetArtistInfo(lidarrId, It.IsAny<List<string>>(), It.IsAny<List<string>>()))
.Returns(new Tuple<Artist, List<Album>>(_fakeArtist, new List<Album>()));
}
@ -53,7 +53,7 @@ namespace NzbDrone.Core.Test.MusicTests
{
var newArtist = new Artist
{
ForeignArtistId = "123456",
ForeignArtistId = "ce09ea31-3d4a-4487-a797-e315175457a0",
RootFolderPath = @"C:\Test\Music"
};
@ -70,7 +70,7 @@ namespace NzbDrone.Core.Test.MusicTests
{
var newArtist = new Artist
{
ForeignArtistId = "123456",
ForeignArtistId = "ce09ea31-3d4a-4487-a797-e315175457a0",
RootFolderPath = @"C:\Test\Music"
};
@ -87,7 +87,7 @@ namespace NzbDrone.Core.Test.MusicTests
{
var newArtist = new Artist
{
ForeignArtistId = "123456",
ForeignArtistId = "ce09ea31-3d4a-4487-a797-e315175457a0",
Path = @"C:\Test\Music\Name1"
};
@ -108,12 +108,12 @@ namespace NzbDrone.Core.Test.MusicTests
{
var newArtist = new Artist
{
ForeignArtistId = "123456",
ForeignArtistId = "ce09ea31-3d4a-4487-a797-e315175457a0",
Path = @"C:\Test\Music\Name1"
};
Mocker.GetMock<IProvideArtistInfo>()
.Setup(s => s.GetArtistInfo(newArtist.ForeignArtistId))
.Setup(s => s.GetArtistInfo(newArtist.ForeignArtistId, newArtist.PrimaryAlbumTypes, newArtist.SecondaryAlbumTypes))
.Throws(new ArtistNotFoundException(newArtist.ForeignArtistId));
Mocker.GetMock<IAddArtistValidator>()
@ -128,4 +128,4 @@ namespace NzbDrone.Core.Test.MusicTests
ExceptionVerification.ExpectedErrors(1);
}
}
}
}

@ -38,14 +38,14 @@ namespace NzbDrone.Core.Test.MusicTests
.Returns(_artist);
Mocker.GetMock<IProvideArtistInfo>()
.Setup(s => s.GetArtistInfo(It.IsAny<string>()))
.Callback<string>(p => { throw new ArtistNotFoundException(p); });
.Setup(s => s.GetArtistInfo(It.IsAny<string>(), It.IsAny<List<string>>(), It.IsAny<List<string>>()))
.Callback(() => { throw new ArtistNotFoundException(_artist.ForeignArtistId); });
}
private void GivenNewArtistInfo(Artist artist)
{
Mocker.GetMock<IProvideArtistInfo>()
.Setup(s => s.GetArtistInfo(_artist.ForeignArtistId))
.Setup(s => s.GetArtistInfo(_artist.ForeignArtistId, _artist.PrimaryAlbumTypes, _artist.SecondaryAlbumTypes))
.Returns(new Tuple<Artist, List<Album>>(artist, new List<Album>()));
}

@ -0,0 +1,14 @@
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(121)]
public class update_types_existing_artist : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Execute.Sql("UPDATE Artists SET PrimaryAlbumTypes = '[]', SecondaryAlbumTypes = '[]'");
}
}
}

@ -1,4 +1,4 @@
using NzbDrone.Core.Music;
using NzbDrone.Core.Music;
using System;
using System.Collections.Generic;
@ -6,6 +6,6 @@ namespace NzbDrone.Core.MetadataSource
{
public interface IProvideArtistInfo
{
Tuple<Artist, List<Album>> GetArtistInfo(string lidarrId);
Tuple<Artist, List<Album>> GetArtistInfo(string lidarrId, List<string> primaryAlbumTypes, List<string> secondaryAlbumTypes);
}
}

@ -37,7 +37,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
_logger = logger;
}
public Tuple<Artist, List<Album>> GetArtistInfo(string foreignArtistId)
public Tuple<Artist, List<Album>> GetArtistInfo(string foreignArtistId, List<string> primaryAlbumTypes, List<string> secondaryAlbumTypes)
{
_logger.Debug("Getting Artist with LidarrAPI.MetadataID of {0}", foreignArtistId);
@ -46,10 +46,10 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
var httpRequest = customerRequestBuilder.Create()
.SetSegment("route", "artists/" + foreignArtistId)
.AddQueryParam("primTypes", string.Join("|",primaryAlbumTypes))
.AddQueryParam("secTypes", string.Join("|", secondaryAlbumTypes))
.Build();
httpRequest.AllowAutoRedirect = true;
httpRequest.SuppressHttpError = true;
@ -92,7 +92,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
try
{
return new List<Artist> { GetArtistInfo(slug).Item1 };
return new List<Artist> { GetArtistInfo(slug, new List<string>{"Album"}, new List<string>{"Studio"}).Item1 };
}
catch (ArtistNotFoundException)
{

@ -86,7 +86,7 @@ namespace NzbDrone.Core.Music
try
{
tuple = _artistInfo.GetArtistInfo(newArtist.ForeignArtistId);
tuple = _artistInfo.GetArtistInfo(newArtist.ForeignArtistId, newArtist.PrimaryAlbumTypes, newArtist.SecondaryAlbumTypes);
}
catch (ArtistNotFoundException)
{

@ -36,8 +36,8 @@ namespace NzbDrone.Core.Music
public string Overview { get; set; }
public string Disambiguation { get; set; }
public string ArtistType { get; set; }
public string PrimaryAlbumTypes { get; set; }
public string SecondaryAlbumTypes { get; set; }
public List<string> PrimaryAlbumTypes { get; set; }
public List<string> SecondaryAlbumTypes { get; set; }
public bool Monitored { get; set; }
public bool AlbumFolder { get; set; }
public DateTime? LastInfoSync { get; set; }

@ -54,7 +54,7 @@ namespace NzbDrone.Core.Music
try
{
tuple = _artistInfo.GetArtistInfo(artist.ForeignArtistId);
tuple = _artistInfo.GetArtistInfo(artist.ForeignArtistId, artist.PrimaryAlbumTypes, artist.SecondaryAlbumTypes);
}
catch (ArtistNotFoundException)
{

@ -252,6 +252,7 @@
<Compile Include="Datastore\Migration\068_add_release_restrictions.cs" />
<Compile Include="Datastore\Migration\069_quality_proper.cs" />
<Compile Include="Datastore\Migration\070_delay_profile.cs" />
<Compile Include="Datastore\Migration\121_update_types_existing_artist.cs" />
<Compile Include="Datastore\Migration\102_add_language_to_episodeFiles_history_and_blacklist.cs" />
<Compile Include="Datastore\Migration\110_fix_extra_files_config.cs" />
<Compile Include="Datastore\Migration\109_import_extra_files.cs" />

Loading…
Cancel
Save