diff --git a/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxyFixture.cs b/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxyFixture.cs index b8b2128ff..3a61b9ca8 100644 --- a/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxyFixture.cs +++ b/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxyFixture.cs @@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.MetadataSource.SkyHook { artist.Should().NotBeNull(); artist.Name.Should().NotBeNullOrWhiteSpace(); - artist.CleanName.Should().Be(Parser.Parser.CleanSeriesTitle(artist.Name)); + artist.CleanName.Should().Be(Parser.Parser.CleanArtistName(artist.Name)); artist.SortName.Should().Be(Parser.Parser.NormalizeTitle(artist.Name)); artist.Overview.Should().NotBeNullOrWhiteSpace(); artist.Images.Should().NotBeEmpty(); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleAlbumSearchMatchSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleAlbumSearchMatchSpecification.cs index 09ba2c376..c2ea90be6 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleAlbumSearchMatchSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleAlbumSearchMatchSpecification.cs @@ -31,7 +31,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search return Decision.Accept(); } - if (Parser.Parser.CleanArtistTitle(singleAlbumSpec.AlbumTitle) != Parser.Parser.CleanArtistTitle(remoteAlbum.ParsedAlbumInfo.AlbumTitle)) + if (Parser.Parser.CleanArtistName(singleAlbumSpec.AlbumTitle) != Parser.Parser.CleanArtistName(remoteAlbum.ParsedAlbumInfo.AlbumTitle)) { _logger.Debug("Album does not match searched album title, skipping."); return Decision.Reject("Wrong album"); diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupUnusedTags.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupUnusedTags.cs index 63debb4b7..1eb50ba2b 100644 --- a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupUnusedTags.cs +++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupUnusedTags.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using Marr.Data; using NzbDrone.Common.Serializer; @@ -19,7 +19,7 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers { var mapper = _database.GetDataMapper(); - var usedTags = new[] { "Series", "Notifications", "DelayProfiles", "Restrictions" } + var usedTags = new[] { "Artists", "Notifications", "DelayProfiles", "Restrictions" } .SelectMany(v => GetUsedTags(v, mapper)) .Distinct() .ToArray(); diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/DeleteBadMediaCovers.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/DeleteBadMediaCovers.cs index 0bd74614b..3ae639b48 100644 --- a/src/NzbDrone.Core/Housekeeping/Housekeepers/DeleteBadMediaCovers.cs +++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/DeleteBadMediaCovers.cs @@ -1,30 +1,30 @@ -using System; +using System; using System.IO; using System.Linq; using NLog; using NzbDrone.Common.Disk; using NzbDrone.Core.Configuration; using NzbDrone.Core.Extras.Metadata.Files; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Housekeeping.Housekeepers { public class DeleteBadMediaCovers : IHousekeepingTask { private readonly IMetadataFileService _metaFileService; - private readonly ISeriesService _seriesService; + private readonly IArtistService _artistService; private readonly IDiskProvider _diskProvider; private readonly IConfigService _configService; private readonly Logger _logger; public DeleteBadMediaCovers(IMetadataFileService metaFileService, - ISeriesService seriesService, + IArtistService artistService, IDiskProvider diskProvider, IConfigService configService, Logger logger) { _metaFileService = metaFileService; - _seriesService = seriesService; + _artistService = artistService; _diskProvider = diskProvider; _configService = configService; _logger = logger; @@ -34,18 +34,18 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers { if (!_configService.CleanupMetadataImages) return; - var series = _seriesService.GetAllSeries(); + var artists = _artistService.GetAllArtists(); - foreach (var show in series) + foreach (var artist in artists) { - var images = _metaFileService.GetFilesBySeries(show.Id) + var images = _metaFileService.GetFilesBySeries(artist.Id) .Where(c => c.LastUpdated > new DateTime(2014, 12, 27) && c.RelativePath.EndsWith(".jpg", StringComparison.InvariantCultureIgnoreCase)); foreach (var image in images) { try { - var path = Path.Combine(show.Path, image.RelativePath); + var path = Path.Combine(artist.Path, image.RelativePath); if (!IsValid(path)) { _logger.Debug("Deleting invalid image file " + path); @@ -84,4 +84,4 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers return !text.ToLowerInvariant().Contains("html"); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForArtist.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForArtist.cs new file mode 100644 index 000000000..04dce6e36 --- /dev/null +++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForArtist.cs @@ -0,0 +1,27 @@ +using System.Linq; +using NzbDrone.Core.Parser; +using NzbDrone.Core.Music; + +namespace NzbDrone.Core.Housekeeping.Housekeepers +{ + public class UpdateCleanTitleForArtist : IHousekeepingTask + { + private readonly IArtistRepository _artistRepository; + + public UpdateCleanTitleForArtist(IArtistRepository artistRepository) + { + _artistRepository = artistRepository; + } + + public void Clean() + { + var artists = _artistRepository.All().ToList(); + + artists.ForEach(s => + { + s.CleanName = s.CleanName.CleanArtistName(); + _artistRepository.Update(s); + }); + } + } +} diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForSeries.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForSeries.cs deleted file mode 100644 index 16b19c505..000000000 --- a/src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForSeries.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Linq; -using NzbDrone.Core.Parser; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Housekeeping.Housekeepers -{ - public class UpdateCleanTitleForSeries : IHousekeepingTask - { - private readonly ISeriesRepository _seriesRepository; - - public UpdateCleanTitleForSeries(ISeriesRepository seriesRepository) - { - _seriesRepository = seriesRepository; - } - - public void Clean() - { - var series = _seriesRepository.All().ToList(); - - series.ForEach(s => - { - s.CleanTitle = s.CleanTitle.CleanSeriesTitle(); - _seriesRepository.Update(s); - }); - } - } -} diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index 924d92dc5..6bd2f7db2 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -43,7 +43,17 @@ namespace NzbDrone.Core.MetadataSource.SkyHook _logger.Debug("Getting Artist with LidarrAPI.MetadataID of {0}", foreignArtistId); SetCustomProvider(); - + + if (primaryAlbumTypes == null) + { + primaryAlbumTypes = new List(); + } + + if (secondaryAlbumTypes == null) + { + secondaryAlbumTypes = new List(); + } + var httpRequest = customerRequestBuilder.Create() .SetSegment("route", "artists/" + foreignArtistId) .AddQueryParam("primTypes", string.Join("|",primaryAlbumTypes)) @@ -143,7 +153,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook album.Title = resource.Title; album.ForeignAlbumId = resource.Id; album.ReleaseDate = resource.ReleaseDate; - album.CleanTitle = Parser.Parser.CleanArtistTitle(album.Title); + album.CleanTitle = Parser.Parser.CleanArtistName(album.Title); album.AlbumType = resource.Type; album.Images = resource.Images.Select(MapImage).ToList(); album.Label = resource.Label; @@ -174,8 +184,8 @@ namespace NzbDrone.Core.MetadataSource.SkyHook artist.ForeignArtistId = resource.Id; artist.Genres = resource.Genres; artist.Overview = resource.Overview; - artist.NameSlug = Parser.Parser.CleanArtistTitle(artist.Name); - artist.CleanName = Parser.Parser.CleanArtistTitle(artist.Name); + artist.NameSlug = Parser.Parser.CleanArtistName(artist.Name); + artist.CleanName = Parser.Parser.CleanArtistName(artist.Name); artist.SortName = Parser.Parser.NormalizeTitle(artist.Name); artist.Disambiguation = resource.Disambiguation; artist.ArtistType = resource.Type; diff --git a/src/NzbDrone.Core/Music/AddArtistService.cs b/src/NzbDrone.Core/Music/AddArtistService.cs index a6450411a..5c0eaf04e 100644 --- a/src/NzbDrone.Core/Music/AddArtistService.cs +++ b/src/NzbDrone.Core/Music/AddArtistService.cs @@ -53,7 +53,7 @@ namespace NzbDrone.Core.Music newArtist.Path = Path.Combine(newArtist.RootFolderPath, folderName); } - newArtist.CleanName = newArtist.Name.CleanArtistTitle(); + newArtist.CleanName = newArtist.Name.CleanArtistName(); newArtist.SortName = ArtistNameNormalizer.Normalize(newArtist.Name, newArtist.ForeignArtistId); // There is no Sort Title newArtist.Added = DateTime.UtcNow; diff --git a/src/NzbDrone.Core/Music/AlbumRepository.cs b/src/NzbDrone.Core/Music/AlbumRepository.cs index 6c8fc60f1..83e6d9296 100644 --- a/src/NzbDrone.Core/Music/AlbumRepository.cs +++ b/src/NzbDrone.Core/Music/AlbumRepository.cs @@ -177,7 +177,7 @@ namespace NzbDrone.Core.Music public Album FindByTitle(int artistId, string title) { - title = Parser.Parser.CleanArtistTitle(title); + title = Parser.Parser.CleanArtistName(title); return Query.Where(s => s.CleanTitle == title) .AndWhere(s => s.ArtistId == artistId) @@ -186,7 +186,7 @@ namespace NzbDrone.Core.Music public Album FindByArtistAndName(string artistName, string cleanTitle) { - var cleanArtistName = Parser.Parser.CleanArtistTitle(artistName); + var cleanArtistName = Parser.Parser.CleanArtistName(artistName); cleanTitle = cleanTitle.ToLowerInvariant(); var query = Query.Join(JoinType.Inner, album => album.Artist, (album, artist) => album.ArtistId == artist.Id) .Where(artist => artist.CleanName == cleanArtistName) diff --git a/src/NzbDrone.Core/Music/ArtistService.cs b/src/NzbDrone.Core/Music/ArtistService.cs index c44f73a5b..9bd021192 100644 --- a/src/NzbDrone.Core/Music/ArtistService.cs +++ b/src/NzbDrone.Core/Music/ArtistService.cs @@ -77,7 +77,7 @@ namespace NzbDrone.Core.Music public Artist FindByName(string title) { - return _artistRepository.FindByName(title.CleanArtistTitle()); + return _artistRepository.FindByName(title.CleanArtistName()); } public Artist FindByTitleInexact(string title) diff --git a/src/NzbDrone.Core/Music/RefreshAlbumService.cs b/src/NzbDrone.Core/Music/RefreshAlbumService.cs index 67925f04e..d9c6a349e 100644 --- a/src/NzbDrone.Core/Music/RefreshAlbumService.cs +++ b/src/NzbDrone.Core/Music/RefreshAlbumService.cs @@ -76,7 +76,7 @@ namespace NzbDrone.Core.Music albumToUpdate.LastInfoSync = DateTime.UtcNow; albumToUpdate.CleanTitle = album.CleanTitle; albumToUpdate.Title = album.Title ?? "Unknown"; - albumToUpdate.CleanTitle = Parser.Parser.CleanArtistTitle(albumToUpdate.Title); + albumToUpdate.CleanTitle = Parser.Parser.CleanArtistName(albumToUpdate.Title); albumToUpdate.ArtistId = artist.Id; albumToUpdate.AlbumType = album.AlbumType; albumToUpdate.Genres = album.Genres; diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 529481c81..4529ba57f 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -608,7 +608,7 @@ - + diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index c2b8a28a6..ca7247acd 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -789,15 +789,15 @@ namespace NzbDrone.Core.Parser return NormalizeRegex.Replace(title, string.Empty).ToLower().RemoveAccent(); } - public static string CleanArtistTitle(this string title) + public static string CleanArtistName(this string name) { long number = 0; //If Title only contains numbers return it as is. - if (long.TryParse(title, out number)) - return title; + if (long.TryParse(name, out number)) + return name; - return NormalizeRegex.Replace(title, string.Empty).ToLower().RemoveAccent(); + return NormalizeRegex.Replace(name, string.Empty).ToLower().RemoveAccent(); } public static string NormalizeEpisodeTitle(string title)