diff --git a/src/NzbDrone.Api/Albums/AlbumResource.cs b/src/NzbDrone.Api/Albums/AlbumResource.cs index 26f883be0..9c6f5487e 100644 --- a/src/NzbDrone.Api/Albums/AlbumResource.cs +++ b/src/NzbDrone.Api/Albums/AlbumResource.cs @@ -18,6 +18,7 @@ namespace NzbDrone.Api.Albums public bool Monitored { get; set; } public string Path { get; set; } public int ProfileId { get; set; } + public int Duration { get; set; } public Ratings Ratings { get; set; } public DateTime? ReleaseDate { get; set; } public List Genres { get; set; } @@ -46,8 +47,7 @@ namespace NzbDrone.Api.Albums Title = model.Title, Images = model.Images, Ratings = model.Ratings, - //Genres = model.Genres, - //ArtworkUrl = model.ArtworkUrl + Duration = model.Duration, }; } @@ -68,8 +68,6 @@ namespace NzbDrone.Api.Albums Title = resource.Title, Images = resource.Images, Ratings = resource.Ratings, - //Genres = resource.Genres, - //ArtworkUrl = resource.ArtworkUrl }; } diff --git a/src/NzbDrone.Api/History/HistoryModule.cs b/src/NzbDrone.Api/History/HistoryModule.cs index d85cf74d8..8d2c8bb21 100644 --- a/src/NzbDrone.Api/History/HistoryModule.cs +++ b/src/NzbDrone.Api/History/HistoryModule.cs @@ -1,8 +1,10 @@ using System; using Nancy; using NzbDrone.Api.Episodes; +using NzbDrone.Api.Albums; using NzbDrone.Api.Extensions; using NzbDrone.Api.Series; +using NzbDrone.Api.Music; using NzbDrone.Core.Datastore; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; @@ -32,12 +34,12 @@ namespace NzbDrone.Api.History { var resource = model.ToResource(); - resource.Series = model.Series.ToResource(); - resource.Episode = model.Episode.ToResource(); + resource.Artist = model.Artist.ToResource(); + resource.Album = model.Album.ToResource(); - if (model.Series != null) + if (model.Artist != null) { - resource.QualityCutoffNotMet = _qualityUpgradableSpecification.CutoffNotMet(model.Series.Profile.Value, model.Quality); + resource.QualityCutoffNotMet = _qualityUpgradableSpecification.CutoffNotMet(model.Artist.Profile.Value, model.Quality); } return resource; @@ -45,7 +47,7 @@ namespace NzbDrone.Api.History private PagingResource GetHistory(PagingResource pagingResource) { - var episodeId = Request.Query.EpisodeId; + var albumId = Request.Query.AlbumId; var pagingSpec = pagingResource.MapToPagingSpec("date", SortDirection.Descending); @@ -55,10 +57,10 @@ namespace NzbDrone.Api.History pagingSpec.FilterExpression = v => v.EventType == filterValue; } - if (episodeId.HasValue) + if (albumId.HasValue) { - int i = (int)episodeId; - pagingSpec.FilterExpression = h => h.EpisodeId == i; + int i = (int)albumId; + pagingSpec.FilterExpression = h => h.AlbumId == i; } return ApplyToPage(_historyService.Paged, pagingSpec, MapToResource); diff --git a/src/NzbDrone.Api/History/HistoryResource.cs b/src/NzbDrone.Api/History/HistoryResource.cs index dba4149dd..1279641be 100644 --- a/src/NzbDrone.Api/History/HistoryResource.cs +++ b/src/NzbDrone.Api/History/HistoryResource.cs @@ -1,8 +1,10 @@ using System; using System.Collections.Generic; using NzbDrone.Api.Episodes; +using NzbDrone.Api.Albums; using NzbDrone.Api.REST; using NzbDrone.Api.Series; +using NzbDrone.Api.Music; using NzbDrone.Core.History; using NzbDrone.Core.Qualities; @@ -11,8 +13,8 @@ namespace NzbDrone.Api.History { public class HistoryResource : RestResource { - public int EpisodeId { get; set; } - public int SeriesId { get; set; } + public int ArtistId { get; set; } + public int AlbumId { get; set; } public string SourceTitle { get; set; } public QualityModel Quality { get; set; } public bool QualityCutoffNotMet { get; set; } @@ -23,8 +25,8 @@ namespace NzbDrone.Api.History public Dictionary Data { get; set; } - public EpisodeResource Episode { get; set; } - public SeriesResource Series { get; set; } + public AlbumResource Album { get; set; } + public ArtistResource Artist { get; set; } } public static class HistoryResourceMapper @@ -37,8 +39,8 @@ namespace NzbDrone.Api.History { Id = model.Id, - EpisodeId = model.EpisodeId, - SeriesId = model.SeriesId, + AlbumId = model.AlbumId, + ArtistId = model.ArtistId, SourceTitle = model.SourceTitle, Quality = model.Quality, //QualityCutoffNotMet diff --git a/src/NzbDrone.Api/Indexers/ReleaseModule.cs b/src/NzbDrone.Api/Indexers/ReleaseModule.cs index 9ad8eb964..858263b4e 100644 --- a/src/NzbDrone.Api/Indexers/ReleaseModule.cs +++ b/src/NzbDrone.Api/Indexers/ReleaseModule.cs @@ -25,7 +25,7 @@ namespace NzbDrone.Api.Indexers private readonly IDownloadService _downloadService; private readonly Logger _logger; - private readonly ICached _remoteEpisodeCache; + private readonly ICached _remoteAlbumCache; public ReleaseModule(IFetchAndParseRss rssFetcherAndParser, ISearchForNzb nzbSearchService, @@ -48,14 +48,14 @@ namespace NzbDrone.Api.Indexers PostValidator.RuleFor(s => s.DownloadAllowed).Equal(true); PostValidator.RuleFor(s => s.Guid).NotEmpty(); - _remoteEpisodeCache = cacheManager.GetCache(GetType(), "remoteEpisodes"); + _remoteAlbumCache = cacheManager.GetCache(GetType(), "remoteAlbums"); } private Response DownloadRelease(ReleaseResource release) { - var remoteEpisode = _remoteEpisodeCache.Find(release.Guid); + var remoteAlbum = _remoteAlbumCache.Find(release.Guid); - if (remoteEpisode == null) + if (remoteAlbum == null) { _logger.Debug("Couldn't find requested release in cache, cache timeout probably expired."); @@ -64,7 +64,7 @@ namespace NzbDrone.Api.Indexers try { - _downloadService.DownloadReport(remoteEpisode); + _downloadService.DownloadReport(remoteAlbum); } catch (ReleaseDownloadException ex) { @@ -113,7 +113,7 @@ namespace NzbDrone.Api.Indexers protected override ReleaseResource MapDecision(DownloadDecision decision, int initialWeight) { - _remoteEpisodeCache.Set(decision.RemoteEpisode.Release.Guid, decision.RemoteEpisode, TimeSpan.FromMinutes(30)); + _remoteAlbumCache.Set(decision.RemoteAlbum.Release.Guid, decision.RemoteAlbum, TimeSpan.FromMinutes(30)); return base.MapDecision(decision, initialWeight); } } diff --git a/src/NzbDrone.Api/Indexers/ReleaseModuleBase.cs b/src/NzbDrone.Api/Indexers/ReleaseModuleBase.cs index f6a223475..32344ef34 100644 --- a/src/NzbDrone.Api/Indexers/ReleaseModuleBase.cs +++ b/src/NzbDrone.Api/Indexers/ReleaseModuleBase.cs @@ -25,9 +25,9 @@ namespace NzbDrone.Api.Indexers release.ReleaseWeight = initialWeight; - if (decision.RemoteEpisode.Series != null) + if (decision.RemoteAlbum.Artist != null) { - release.QualityWeight = decision.RemoteEpisode.Series + release.QualityWeight = decision.RemoteAlbum.Artist .Profile.Value .Items.FindIndex(v => v.Quality == release.Quality.Quality) * 100; } diff --git a/src/NzbDrone.Api/Indexers/ReleaseResource.cs b/src/NzbDrone.Api/Indexers/ReleaseResource.cs index b951b0fe0..a8f8cdfab 100644 --- a/src/NzbDrone.Api/Indexers/ReleaseResource.cs +++ b/src/NzbDrone.Api/Indexers/ReleaseResource.cs @@ -25,18 +25,13 @@ namespace NzbDrone.Api.Indexers public string ReleaseGroup { get; set; } public string ReleaseHash { get; set; } public string Title { get; set; } - public bool FullSeason { get; set; } - public int SeasonNumber { get; set; } public Language Language { get; set; } - public string AirDate { get; set; } - public string SeriesTitle { get; set; } - public int[] EpisodeNumbers { get; set; } - public int[] AbsoluteEpisodeNumbers { get; set; } + public string ReleaseDate { get; set; } + public string ArtistName { get; set; } + public string AlbumTitle { get; set; } public bool Approved { get; set; } public bool TemporarilyRejected { get; set; } public bool Rejected { get; set; } - public int TvdbId { get; set; } - public int TvRageId { get; set; } public IEnumerable Rejections { get; set; } public DateTime PublishDate { get; set; } public string CommentUrl { get; set; } @@ -82,16 +77,16 @@ namespace NzbDrone.Api.Indexers { public static ReleaseResource ToResource(this DownloadDecision model) { - var releaseInfo = model.RemoteEpisode.Release; - var parsedEpisodeInfo = model.RemoteEpisode.ParsedEpisodeInfo; - var remoteEpisode = model.RemoteEpisode; - var torrentInfo = (model.RemoteEpisode.Release as TorrentInfo) ?? new TorrentInfo(); + var releaseInfo = model.RemoteAlbum.Release; + var parsedAlbumInfo = model.RemoteAlbum.ParsedAlbumInfo; + var remoteAlbum = model.RemoteAlbum; + var torrentInfo = (model.RemoteAlbum.Release as TorrentInfo) ?? new TorrentInfo(); // TODO: Clean this mess up. don't mix data from multiple classes, use sub-resources instead? (Got a huge Deja Vu, didn't we talk about this already once?) return new ReleaseResource { Guid = releaseInfo.Guid, - Quality = parsedEpisodeInfo.Quality, + Quality = parsedAlbumInfo.Quality, //QualityWeight Age = releaseInfo.Age, AgeHours = releaseInfo.AgeHours, @@ -99,27 +94,22 @@ namespace NzbDrone.Api.Indexers Size = releaseInfo.Size, IndexerId = releaseInfo.IndexerId, Indexer = releaseInfo.Indexer, - ReleaseGroup = parsedEpisodeInfo.ReleaseGroup, - ReleaseHash = parsedEpisodeInfo.ReleaseHash, + ReleaseGroup = parsedAlbumInfo.ReleaseGroup, + ReleaseHash = parsedAlbumInfo.ReleaseHash, Title = releaseInfo.Title, - FullSeason = parsedEpisodeInfo.FullSeason, - SeasonNumber = parsedEpisodeInfo.SeasonNumber, - Language = parsedEpisodeInfo.Language, - AirDate = parsedEpisodeInfo.AirDate, - SeriesTitle = parsedEpisodeInfo.SeriesTitle, - EpisodeNumbers = parsedEpisodeInfo.EpisodeNumbers, - AbsoluteEpisodeNumbers = parsedEpisodeInfo.AbsoluteEpisodeNumbers, + Language = parsedAlbumInfo.Language, + ReleaseDate = parsedAlbumInfo.ReleaseDate, + ArtistName = parsedAlbumInfo.ArtistName, + AlbumTitle = parsedAlbumInfo.AlbumTitle, Approved = model.Approved, TemporarilyRejected = model.TemporarilyRejected, Rejected = model.Rejected, - TvdbId = releaseInfo.TvdbId, - TvRageId = releaseInfo.TvRageId, Rejections = model.Rejections.Select(r => r.Reason).ToList(), PublishDate = releaseInfo.PublishDate, CommentUrl = releaseInfo.CommentUrl, DownloadUrl = releaseInfo.DownloadUrl, InfoUrl = releaseInfo.InfoUrl, - DownloadAllowed = remoteEpisode.DownloadAllowed, + DownloadAllowed = remoteAlbum.DownloadAllowed, //ReleaseWeight MagnetUrl = torrentInfo.MagnetUrl, @@ -127,11 +117,6 @@ namespace NzbDrone.Api.Indexers Seeders = torrentInfo.Seeders, Leechers = (torrentInfo.Peers.HasValue && torrentInfo.Seeders.HasValue) ? (torrentInfo.Peers.Value - torrentInfo.Seeders.Value) : (int?)null, Protocol = releaseInfo.DownloadProtocol, - - IsDaily = parsedEpisodeInfo.IsDaily, - IsAbsoluteNumbering = parsedEpisodeInfo.IsAbsoluteNumbering, - IsPossibleSpecialEpisode = parsedEpisodeInfo.IsPossibleSpecialEpisode, - Special = parsedEpisodeInfo.Special, }; } @@ -164,8 +149,6 @@ namespace NzbDrone.Api.Indexers model.IndexerId = resource.IndexerId; model.Indexer = resource.Indexer; model.DownloadProtocol = resource.DownloadProtocol; - model.TvdbId = resource.TvdbId; - model.TvRageId = resource.TvRageId; model.PublishDate = resource.PublishDate; return model; diff --git a/src/NzbDrone.Api/Music/ArtistResource.cs b/src/NzbDrone.Api/Music/ArtistResource.cs index e242e6601..6d9c447f5 100644 --- a/src/NzbDrone.Api/Music/ArtistResource.cs +++ b/src/NzbDrone.Api/Music/ArtistResource.cs @@ -53,6 +53,7 @@ namespace NzbDrone.Api.Music //public string Certification { get; set; } public List Genres { get; set; } public string CleanName { get; set; } + public string SortName { get; set; } public HashSet Tags { get; set; } public DateTime Added { get; set; } public AddArtistOptions AddOptions { get; set; } @@ -75,8 +76,9 @@ namespace NzbDrone.Api.Music AllMusicId = model.AMId, Name = model.Name, CleanName = model.CleanName, + //AlternateTitles - //SortTitle = resource.SortTitle, + SortName = model.SortName, //TotalTrackCount //TrackCount @@ -130,7 +132,7 @@ namespace NzbDrone.Api.Music Name = resource.Name, CleanName = resource.CleanName, //AlternateTitles - //SortTitle = resource.SortTitle, + SortName = resource.SortName, MBId = resource.MBId, TADBId = resource.TADBId, DiscogsId = resource.DiscogsId, diff --git a/src/NzbDrone.Api/Parse/ParseModule.cs b/src/NzbDrone.Api/Parse/ParseModule.cs index df36307ff..486ed8ace 100644 --- a/src/NzbDrone.Api/Parse/ParseModule.cs +++ b/src/NzbDrone.Api/Parse/ParseModule.cs @@ -1,5 +1,5 @@ -using NzbDrone.Api.Episodes; -using NzbDrone.Api.Series; +using NzbDrone.Api.Albums; +using NzbDrone.Api.Music; using NzbDrone.Core.Parser; namespace NzbDrone.Api.Parse @@ -18,23 +18,23 @@ namespace NzbDrone.Api.Parse private ParseResource Parse() { var title = Request.Query.Title.Value as string; - var parsedEpisodeInfo = Parser.ParseTitle(title); + var parsedAlbumInfo = Parser.ParseAlbumTitle(title); - if (parsedEpisodeInfo == null) + if (parsedAlbumInfo == null) { return null; } - var remoteEpisode = _parsingService.Map(parsedEpisodeInfo, 0, 0); + var remoteAlbum = _parsingService.Map(parsedAlbumInfo); - if (remoteEpisode != null) + if (remoteAlbum != null) { return new ParseResource { Title = title, - ParsedEpisodeInfo = remoteEpisode.ParsedEpisodeInfo, - Series = remoteEpisode.Series.ToResource(), - Episodes = remoteEpisode.Episodes.ToResource() + ParsedAlbumInfo = remoteAlbum.ParsedAlbumInfo, + Artist = remoteAlbum.Artist.ToResource(), + Albums = remoteAlbum.Albums.ToResource() }; } else @@ -42,7 +42,7 @@ namespace NzbDrone.Api.Parse return new ParseResource { Title = title, - ParsedEpisodeInfo = parsedEpisodeInfo + ParsedAlbumInfo = parsedAlbumInfo }; } } diff --git a/src/NzbDrone.Api/Parse/ParseResource.cs b/src/NzbDrone.Api/Parse/ParseResource.cs index c795f09c3..df19e42de 100644 --- a/src/NzbDrone.Api/Parse/ParseResource.cs +++ b/src/NzbDrone.Api/Parse/ParseResource.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; -using NzbDrone.Api.Episodes; using NzbDrone.Api.REST; -using NzbDrone.Api.Series; +using NzbDrone.Api.Music; +using NzbDrone.Api.Albums; using NzbDrone.Core.Parser.Model; namespace NzbDrone.Api.Parse @@ -9,8 +9,8 @@ namespace NzbDrone.Api.Parse public class ParseResource : RestResource { public string Title { get; set; } - public ParsedEpisodeInfo ParsedEpisodeInfo { get; set; } - public SeriesResource Series { get; set; } - public List Episodes { get; set; } + public ParsedAlbumInfo ParsedAlbumInfo { get; set; } + public ArtistResource Artist { get; set; } + public List Albums { get; set; } } } \ No newline at end of file diff --git a/src/NzbDrone.Api/Queue/QueueActionModule.cs b/src/NzbDrone.Api/Queue/QueueActionModule.cs index 9882e60e6..89ca897b7 100644 --- a/src/NzbDrone.Api/Queue/QueueActionModule.cs +++ b/src/NzbDrone.Api/Queue/QueueActionModule.cs @@ -105,7 +105,7 @@ namespace NzbDrone.Api.Queue throw new NotFoundException(); } - _downloadService.DownloadReport(pendingRelease.RemoteEpisode); + _downloadService.DownloadReport(pendingRelease.RemoteAlbum); return resource.AsResponse(); } diff --git a/src/NzbDrone.Api/Queue/QueueResource.cs b/src/NzbDrone.Api/Queue/QueueResource.cs index cf1356c49..858c10dcf 100644 --- a/src/NzbDrone.Api/Queue/QueueResource.cs +++ b/src/NzbDrone.Api/Queue/QueueResource.cs @@ -4,6 +4,8 @@ using NzbDrone.Api.REST; using NzbDrone.Core.Qualities; using NzbDrone.Api.Series; using NzbDrone.Api.Episodes; +using NzbDrone.Api.Music; +using NzbDrone.Api.Albums; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.Indexers; using System.Linq; @@ -12,8 +14,8 @@ namespace NzbDrone.Api.Queue { public class QueueResource : RestResource { - public SeriesResource Series { get; set; } - public EpisodeResource Episode { get; set; } + public ArtistResource Artist { get; set; } + public AlbumResource Album { get; set; } public QualityModel Quality { get; set; } public decimal Size { get; set; } public string Title { get; set; } @@ -37,8 +39,8 @@ namespace NzbDrone.Api.Queue { Id = model.Id, - Series = model.Series.ToResource(), - Episode = model.Episode.ToResource(), + Artist = model.Artist.ToResource(), + Album = model.Album.ToResource(), Quality = model.Quality, Size = model.Size, Title = model.Title, diff --git a/src/NzbDrone.Api/Tracks/TrackResource.cs b/src/NzbDrone.Api/Tracks/TrackResource.cs index 34915d2d7..b8a007671 100644 --- a/src/NzbDrone.Api/Tracks/TrackResource.cs +++ b/src/NzbDrone.Api/Tracks/TrackResource.cs @@ -17,18 +17,11 @@ namespace NzbDrone.Api.Tracks public bool Explicit { get; set; } public int TrackNumber { get; set; } public string Title { get; set; } - //public string AirDate { get; set; } - //public DateTime? AirDateUtc { get; set; } - //public string Overview { get; set; } + public int Duration { get; set; } public TrackFileResource TrackFile { get; set; } public bool HasFile { get; set; } public bool Monitored { get; set; } - //public int? AbsoluteEpisodeNumber { get; set; } - //public int? SceneAbsoluteEpisodeNumber { get; set; } - //public int? SceneEpisodeNumber { get; set; } - //public int? SceneSeasonNumber { get; set; } - //public bool UnverifiedSceneNumbering { get; set; } //public string SeriesTitle { get; set; } public ArtistResource Artist { get; set; } public Ratings Ratings { get; set; } @@ -54,19 +47,12 @@ namespace NzbDrone.Api.Tracks Explicit = model.Explicit, TrackNumber = model.TrackNumber, Title = model.Title, - //AirDate = model.AirDate, - //AirDateUtc = model.AirDateUtc, - //Overview = model.Overview, + Duration = model.Duration, //EpisodeFile HasFile = model.HasFile, Monitored = model.Monitored, Ratings = model.Ratings, - //AbsoluteEpisodeNumber = model.AbsoluteEpisodeNumber, - //SceneAbsoluteEpisodeNumber = model.SceneAbsoluteEpisodeNumber, - //SceneEpisodeNumber = model.SceneEpisodeNumber, - //SceneSeasonNumber = model.SceneSeasonNumber, - //UnverifiedSceneNumbering = model.UnverifiedSceneNumbering, //SeriesTitle = model.SeriesTitle, //Series = model.Series.MapToResource(), }; diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/AcceptableSizeSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/AcceptableSizeSpecificationFixture.cs index fa2ad0608..9a87c710f 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/AcceptableSizeSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/AcceptableSizeSpecificationFixture.cs @@ -8,7 +8,7 @@ using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Test.DecisionEngineTests { @@ -16,40 +16,40 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class AcceptableSizeSpecificationFixture : CoreTest { - private RemoteEpisode parseResultMultiSet; - private RemoteEpisode parseResultMulti; - private RemoteEpisode parseResultSingle; - private Series series; + private RemoteAlbum parseResultMultiSet; + private RemoteAlbum parseResultMulti; + private RemoteAlbum parseResultSingle; + private Artist artist; private QualityDefinition qualityType; [SetUp] public void Setup() { - series = Builder.CreateNew() + artist = Builder.CreateNew() .Build(); - parseResultMultiSet = new RemoteEpisode - { - Series = series, + parseResultMultiSet = new RemoteAlbum + { + Artist = artist, Release = new ReleaseInfo(), - ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) }, - Episodes = new List { new Episode(), new Episode(), new Episode(), new Episode(), new Episode(), new Episode() } + ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) }, + Albums = new List { new Album(), new Album(), new Album(), new Album(), new Album(), new Album() } }; - parseResultMulti = new RemoteEpisode - { - Series = series, + parseResultMulti = new RemoteAlbum + { + Artist = artist, Release = new ReleaseInfo(), - ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) }, - Episodes = new List { new Episode(), new Episode() } + ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) }, + Albums = new List { new Album(), new Album() } }; - parseResultSingle = new RemoteEpisode - { - Series = series, + parseResultSingle = new RemoteAlbum + { + Artist = artist, Release = new ReleaseInfo(), - ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) }, - Episodes = new List { new Episode() { Id = 2 } } + ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) }, + Albums = new List { new Album { Id = 2 } } }; @@ -59,83 +59,68 @@ namespace NzbDrone.Core.Test.DecisionEngineTests qualityType = Builder.CreateNew() .With(q => q.MinSize = 2) - .With(q => q.MaxSize = 10) + .With(q => q.MaxSize = 6) .With(q => q.Quality = Quality.MP3_192) .Build(); Mocker.GetMock().Setup(s => s.Get(Quality.MP3_192)).Returns(qualityType); - Mocker.GetMock().Setup( - s => s.GetEpisodesBySeason(It.IsAny(), It.IsAny())) - .Returns(new List() { - new Episode(), new Episode(), new Episode(), new Episode(), new Episode(), - new Episode(), new Episode(), new Episode(), new Episode() { Id = 2 }, new Episode() }); + Mocker.GetMock().Setup( + s => s.GetAlbumsByArtist(It.IsAny())) + .Returns(new List() { + new Album(), new Album(), new Album(), new Album(), new Album(), + new Album(), new Album(), new Album(), new Album { Id = 2 }, new Album() }); } - private void GivenLastEpisode() + private void GivenLastAlbum() { - Mocker.GetMock().Setup( - s => s.GetEpisodesBySeason(It.IsAny(), It.IsAny())) - .Returns(new List() { - new Episode(), new Episode(), new Episode(), new Episode(), new Episode(), - new Episode(), new Episode(), new Episode(), new Episode(), new Episode() { Id = 2 } }); + Mocker.GetMock().Setup( + s => s.GetAlbumsByArtist(It.IsAny())) + .Returns(new List { + new Album(), new Album(), new Album(), new Album(), new Album(), + new Album(), new Album(), new Album(), new Album(), new Album { Id = 2 } }); } - [TestCase(30, 50, false)] - [TestCase(30, 250, true)] - [TestCase(30, 500, false)] - [TestCase(60, 100, false)] - [TestCase(60, 500, true)] - [TestCase(60, 1000, false)] - public void single_episode(int runtime, int sizeInMegaBytes, bool expectedResult) - { - series.Runtime = runtime; - parseResultSingle.Series = series; - parseResultSingle.Release.Size = sizeInMegaBytes.Megabytes(); - - Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().Be(expectedResult); - } - - [TestCase(30, 500, true)] - [TestCase(30, 1000, false)] - [TestCase(60, 1000, true)] - [TestCase(60, 2000, false)] - public void single_episode_first_or_last(int runtime, int sizeInMegaBytes, bool expectedResult) + [TestCase(1800000, 50, false)] + [TestCase(1800000, 150, true)] + [TestCase(1800000, 300, false)] + [TestCase(3600000, 100, false)] + [TestCase(3600000, 300, true)] + [TestCase(3600000, 600, false)] + public void single_album(int runtime, int sizeInMegaBytes, bool expectedResult) { - GivenLastEpisode(); - - series.Runtime = runtime; - parseResultSingle.Series = series; + parseResultSingle.Albums.Select(c => { c.Duration = runtime; return c; }).ToList(); + parseResultSingle.Artist = artist; parseResultSingle.Release.Size = sizeInMegaBytes.Megabytes(); Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().Be(expectedResult); } - [TestCase(30, 50 * 2, false)] - [TestCase(30, 250 * 2, true)] - [TestCase(30, 500 * 2, false)] - [TestCase(60, 100 * 2, false)] - [TestCase(60, 500 * 2, true)] - [TestCase(60, 1000 * 2, false)] - public void multi_episode(int runtime, int sizeInMegaBytes, bool expectedResult) + [TestCase(1800000, 50 * 2, false)] + [TestCase(1800000, 150 * 2, true)] + [TestCase(1800000, 300 * 2, false)] + [TestCase(3600000, 100 * 2, false)] + [TestCase(3600000, 300 * 2, true)] + [TestCase(3600000, 600 * 2, false)] + public void multi_album(int runtime, int sizeInMegaBytes, bool expectedResult) { - series.Runtime = runtime; - parseResultMulti.Series = series; + parseResultMulti.Albums.Select(c => { c.Duration = runtime; return c; }).ToList(); + parseResultMulti.Artist = artist; parseResultMulti.Release.Size = sizeInMegaBytes.Megabytes(); Subject.IsSatisfiedBy(parseResultMulti, null).Accepted.Should().Be(expectedResult); } - [TestCase(30, 50 * 6, false)] - [TestCase(30, 250 * 6, true)] - [TestCase(30, 500 * 6, false)] - [TestCase(60, 100 * 6, false)] - [TestCase(60, 500 * 6, true)] - [TestCase(60, 1000 * 6, false)] - public void multiset_episode(int runtime, int sizeInMegaBytes, bool expectedResult) + [TestCase(1800000, 50 * 6, false)] + [TestCase(1800000, 150 * 6, true)] + [TestCase(1800000, 300 * 6, false)] + [TestCase(3600000, 100 * 6, false)] + [TestCase(3600000, 300 * 6, true)] + [TestCase(3600000, 600 * 6, false)] + public void multiset_album(int runtime, int sizeInMegaBytes, bool expectedResult) { - series.Runtime = runtime; - parseResultMultiSet.Series = series; + parseResultMultiSet.Albums.Select(c => { c.Duration = runtime; return c; }).ToList(); + parseResultMultiSet.Artist = artist; parseResultMultiSet.Release.Size = sizeInMegaBytes.Megabytes(); Subject.IsSatisfiedBy(parseResultMultiSet, null).Accepted.Should().Be(expectedResult); @@ -144,10 +129,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [Test] public void should_return_true_if_size_is_zero() { - GivenLastEpisode(); - - series.Runtime = 30; - parseResultSingle.Series = series; + GivenLastAlbum(); + parseResultSingle.Albums.Select(c => { c.Duration = 1800000; return c; }).ToList(); + parseResultSingle.Artist = artist; parseResultSingle.Release.Size = 0; qualityType.MinSize = 10; qualityType.MaxSize = 20; @@ -158,10 +142,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [Test] public void should_return_true_if_unlimited_30_minute() { - GivenLastEpisode(); - - series.Runtime = 30; - parseResultSingle.Series = series; + GivenLastAlbum(); + parseResultSingle.Albums.Select(c => { c.Duration = 1800000; return c; }).ToList(); + parseResultSingle.Artist = artist; parseResultSingle.Release.Size = 18457280000; qualityType.MaxSize = null; @@ -171,50 +154,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [Test] public void should_return_true_if_unlimited_60_minute() { - GivenLastEpisode(); - - series.Runtime = 60; - parseResultSingle.Series = series; + GivenLastAlbum(); + parseResultSingle.Albums.Select(c => { c.Duration = 3600000; return c; }).ToList(); + parseResultSingle.Artist = artist; parseResultSingle.Release.Size = 36857280000; qualityType.MaxSize = null; Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue(); } - [Test] - public void should_treat_daily_series_as_single_episode() - { - GivenLastEpisode(); - - series.Runtime = 60; - parseResultSingle.Series = series; - parseResultSingle.Series.SeriesType = SeriesTypes.Daily; - parseResultSingle.Release.Size = 300.Megabytes(); - - qualityType.MaxSize = 10; - - Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue(); - } - - [Test] - public void should_return_true_if_RAWHD() - { - parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.FLAC); - - series.Runtime = 45; - parseResultSingle.Series = series; - parseResultSingle.Series.SeriesType = SeriesTypes.Daily; - parseResultSingle.Release.Size = 8000.Megabytes(); - - Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue(); - } - - [Test] - public void should_return_true_for_special() - { - parseResultSingle.ParsedEpisodeInfo.Special = true; - - Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue(); - } } } diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/AnimeVersionUpgradeSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/AnimeVersionUpgradeSpecificationFixture.cs deleted file mode 100644 index 5ac6df03c..000000000 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/AnimeVersionUpgradeSpecificationFixture.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using Marr.Data; -using NUnit.Framework; -using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.DecisionEngine.Specifications; -using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.DecisionEngineTests -{ - [TestFixture] - public class AnimeVersionUpgradeSpecificationFixture : CoreTest - { - private AnimeVersionUpgradeSpecification _subject; - private RemoteEpisode _remoteEpisode; - private EpisodeFile _episodeFile; - - [SetUp] - public void Setup() - { - Mocker.Resolve(); - _subject = Mocker.Resolve(); - - _episodeFile = new EpisodeFile - { - Quality = new QualityModel(Quality.MP3_256, new Revision()), - ReleaseGroup = "DRONE2" - }; - - _remoteEpisode = new RemoteEpisode(); - _remoteEpisode.Series = new Series { SeriesType = SeriesTypes.Anime }; - _remoteEpisode.ParsedEpisodeInfo = new ParsedEpisodeInfo - { - Quality = new QualityModel(Quality.MP3_256, new Revision(2)), - ReleaseGroup = "DRONE" - }; - - _remoteEpisode.Episodes = Builder.CreateListOfSize(1) - .All() - .With(e => e.EpisodeFile = new LazyLoaded(_episodeFile)) - .Build() - .ToList(); - } - - private void GivenStandardSeries() - { - _remoteEpisode.Series.SeriesType = SeriesTypes.Standard; - } - - private void GivenNoVersionUpgrade() - { - _remoteEpisode.ParsedEpisodeInfo.Quality.Revision = new Revision(); - } - - [Test] - public void should_be_true_when_no_existing_file() - { - _remoteEpisode.Episodes.First().EpisodeFileId = 0; - - _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); - } - - [Test] - public void should_be_true_if_series_is_not_anime() - { - GivenStandardSeries(); - _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); - } - - [Test] - public void should_be_true_if_is_not_a_version_upgrade_for_existing_file() - { - GivenNoVersionUpgrade(); - _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); - } - - [Test] - public void should_be_true_when_release_group_matches() - { - _episodeFile.ReleaseGroup = _remoteEpisode.ParsedEpisodeInfo.ReleaseGroup; - - _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); - } - - [Test] - public void should_be_false_when_existing_file_doesnt_have_a_release_group() - { - _episodeFile.ReleaseGroup = string.Empty; - _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); - } - - [Test] - public void should_should_be_false_when_release_doesnt_have_a_release_group() - { - _remoteEpisode.ParsedEpisodeInfo.ReleaseGroup = string.Empty; - _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); - } - - [Test] - public void should_be_false_when_release_group_does_not_match() - { - _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/CutoffSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/CutoffSpecificationFixture.cs index ae4a884c3..ab91dba4a 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/CutoffSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/CutoffSpecificationFixture.cs @@ -11,28 +11,28 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class CutoffSpecificationFixture : CoreTest { [Test] - public void should_return_true_if_current_episode_is_less_than_cutoff() + public void should_return_true_if_current_album_is_less_than_cutoff() { Subject.CutoffNotMet(new Profile { Cutoff = Quality.MP3_512, Items = Qualities.QualityFixture.GetDefaultQualities() }, new QualityModel(Quality.MP3_192, new Revision(version: 2))).Should().BeTrue(); } [Test] - public void should_return_false_if_current_episode_is_equal_to_cutoff() + public void should_return_false_if_current_album_is_equal_to_cutoff() { Subject.CutoffNotMet(new Profile { Cutoff = Quality.MP3_256, Items = Qualities.QualityFixture.GetDefaultQualities() }, new QualityModel(Quality.MP3_256, new Revision(version: 2))).Should().BeFalse(); } [Test] - public void should_return_false_if_current_episode_is_greater_than_cutoff() + public void should_return_false_if_current_album_is_greater_than_cutoff() { Subject.CutoffNotMet(new Profile { Cutoff = Quality.MP3_256, Items = Qualities.QualityFixture.GetDefaultQualities() }, new QualityModel(Quality.MP3_512, new Revision(version: 2))).Should().BeFalse(); } [Test] - public void should_return_true_when_new_episode_is_proper_but_existing_is_not() + public void should_return_true_when_new_album_is_proper_but_existing_is_not() { Subject.CutoffNotMet(new Profile { Cutoff = Quality.MP3_256, Items = Qualities.QualityFixture.GetDefaultQualities() }, new QualityModel(Quality.MP3_256, new Revision(version: 1)), diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/DownloadDecisionMakerFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/DownloadDecisionMakerFixture.cs index 0206abbd2..b99d13b26 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/DownloadDecisionMakerFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/DownloadDecisionMakerFixture.cs @@ -8,7 +8,7 @@ using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; using NzbDrone.Test.Common; using FizzWare.NBuilder; @@ -18,7 +18,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class DownloadDecisionMakerFixture : CoreTest { private List _reports; - private RemoteEpisode _remoteEpisode; + private RemoteAlbum _remoteAlbum; private Mock _pass1; private Mock _pass2; @@ -39,23 +39,23 @@ namespace NzbDrone.Core.Test.DecisionEngineTests _fail2 = new Mock(); _fail3 = new Mock(); - _pass1.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Accept); - _pass2.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Accept); - _pass3.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Accept); + _pass1.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Accept); + _pass2.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Accept); + _pass3.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Accept); - _fail1.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Reject("fail1")); - _fail2.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Reject("fail2")); - _fail3.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Reject("fail3")); - - _reports = new List { new ReleaseInfo { Title = "The.Office.S03E115.DVDRip.XviD-OSiTV" } }; - _remoteEpisode = new RemoteEpisode { - Series = new Series(), - Episodes = new List { new Episode() } + _fail1.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Reject("fail1")); + _fail2.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Reject("fail2")); + _fail3.Setup(c => c.IsSatisfiedBy(It.IsAny(), null)).Returns(Decision.Reject("fail3")); + + _reports = new List { new ReleaseInfo { Title = "Coldplay-A Head Full Of Dreams-CD-FLAC-2015-PERFECT" } }; + _remoteAlbum = new RemoteAlbum { + Artist = new Artist(), + Albums = new List { new Album() } }; Mocker.GetMock() - .Setup(c => c.Map(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(_remoteEpisode); + .Setup(c => c.Map(It.IsAny(), It.IsAny())) + .Returns(_remoteAlbum); } private void GivenSpecifications(params Mock[] mocks) @@ -70,12 +70,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests Subject.GetRssDecision(_reports).ToList(); - _fail1.Verify(c => c.IsSatisfiedBy(_remoteEpisode, null), Times.Once()); - _fail2.Verify(c => c.IsSatisfiedBy(_remoteEpisode, null), Times.Once()); - _fail3.Verify(c => c.IsSatisfiedBy(_remoteEpisode, null), Times.Once()); - _pass1.Verify(c => c.IsSatisfiedBy(_remoteEpisode, null), Times.Once()); - _pass2.Verify(c => c.IsSatisfiedBy(_remoteEpisode, null), Times.Once()); - _pass3.Verify(c => c.IsSatisfiedBy(_remoteEpisode, null), Times.Once()); + _fail1.Verify(c => c.IsSatisfiedBy(_remoteAlbum, null), Times.Once()); + _fail2.Verify(c => c.IsSatisfiedBy(_remoteAlbum, null), Times.Once()); + _fail3.Verify(c => c.IsSatisfiedBy(_remoteAlbum, null), Times.Once()); + _pass1.Verify(c => c.IsSatisfiedBy(_remoteAlbum, null), Times.Once()); + _pass2.Verify(c => c.IsSatisfiedBy(_remoteAlbum, null), Times.Once()); + _pass3.Verify(c => c.IsSatisfiedBy(_remoteAlbum, null), Times.Once()); } [Test] @@ -118,51 +118,51 @@ namespace NzbDrone.Core.Test.DecisionEngineTests } [Test] - public void should_not_attempt_to_map_episode_if_not_parsable() + public void should_not_attempt_to_map_album_if_not_parsable() { GivenSpecifications(_pass1, _pass2, _pass3); _reports[0].Title = "Not parsable"; var results = Subject.GetRssDecision(_reports).ToList(); - Mocker.GetMock().Verify(c => c.Map(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); + Mocker.GetMock().Verify(c => c.Map(It.IsAny(), It.IsAny()), Times.Never()); - _pass1.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); - _pass2.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); - _pass3.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); + _pass1.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); + _pass2.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); + _pass3.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); results.Should().BeEmpty(); } [Test] - public void should_not_attempt_to_map_episode_series_title_is_blank() + public void should_not_attempt_to_map_album_artist_title_is_blank() { GivenSpecifications(_pass1, _pass2, _pass3); - _reports[0].Title = "1937 - Snow White and the Seven Dwarves"; + _reports[0].Title = "2013 - Night Visions"; var results = Subject.GetRssDecision(_reports).ToList(); - Mocker.GetMock().Verify(c => c.Map(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); + Mocker.GetMock().Verify(c => c.Map(It.IsAny(), It.IsAny()), Times.Never()); - _pass1.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); - _pass2.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); - _pass3.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); + _pass1.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); + _pass2.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); + _pass3.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); results.Should().BeEmpty(); } [Test] - public void should_not_attempt_to_make_decision_if_series_is_unknown() + public void should_not_attempt_to_make_decision_if_artist_is_unknown() { GivenSpecifications(_pass1, _pass2, _pass3); - _remoteEpisode.Series = null; + _remoteAlbum.Artist = null; Subject.GetRssDecision(_reports); - _pass1.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); - _pass2.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); - _pass3.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); + _pass1.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); + _pass2.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); + _pass3.Verify(c => c.IsSatisfiedBy(It.IsAny(), null), Times.Never()); } [Test] @@ -170,29 +170,29 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenSpecifications(_pass1); - Mocker.GetMock().Setup(c => c.Map(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) + Mocker.GetMock().Setup(c => c.Map(It.IsAny(), It.IsAny())) .Throws(); _reports = new List { - new ReleaseInfo{Title = "The.Office.S03E115.DVDRip.XviD-OSiTV"}, - new ReleaseInfo{Title = "The.Office.S03E115.DVDRip.XviD-OSiTV"}, - new ReleaseInfo{Title = "The.Office.S03E115.DVDRip.XviD-OSiTV"} + new ReleaseInfo{Title = "Coldplay-A Head Full Of Dreams-CD-FLAC-2015-PERFECT"}, + new ReleaseInfo{Title = "Coldplay-A Head Full Of Dreams-CD-FLAC-2015-PERFECT"}, + new ReleaseInfo{Title = "Coldplay-A Head Full Of Dreams-CD-FLAC-2015-PERFECT"} }; Subject.GetRssDecision(_reports); - Mocker.GetMock().Verify(c => c.Map(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Exactly(_reports.Count)); + Mocker.GetMock().Verify(c => c.Map(It.IsAny(), It.IsAny()), Times.Exactly(_reports.Count)); ExceptionVerification.ExpectedErrors(3); } [Test] - public void should_return_unknown_series_rejection_if_series_is_unknown() + public void should_return_unknown_artist_rejection_if_artist_is_unknown() { GivenSpecifications(_pass1, _pass2, _pass3); - _remoteEpisode.Series = null; + _remoteAlbum.Artist = null; var result = Subject.GetRssDecision(_reports); @@ -200,40 +200,38 @@ namespace NzbDrone.Core.Test.DecisionEngineTests } [Test] - public void should_only_include_reports_for_requested_episodes() + public void should_only_include_reports_for_requested_albums() { - var series = Builder.CreateNew().Build(); + var artist = Builder.CreateNew().Build(); - var episodes = Builder.CreateListOfSize(2) + var albums = Builder.CreateListOfSize(2) .All() - .With(v => v.SeriesId, series.Id) - .With(v => v.Series, series) - .With(v => v.SeasonNumber, 1) - .With(v => v.SceneSeasonNumber, 2) + .With(v => v.ArtistId, artist.Id) + .With(v => v.Artist, artist) .BuildList(); - var criteria = new SeasonSearchCriteria { Episodes = episodes.Take(1).ToList(), SeasonNumber = 1 }; + var criteria = new ArtistSearchCriteria { Albums = albums.Take(1).ToList()}; - var reports = episodes.Select(v => + var reports = albums.Select(v => new ReleaseInfo() { - Title = string.Format("{0}.S{1:00}E{2:00}.720p.WEB-DL-DRONE", series.Title, v.SceneSeasonNumber, v.SceneEpisodeNumber) + Title = string.Format("{0}-{1}[FLAC][2017][DRONE]", artist.Name, v.Title) }).ToList(); Mocker.GetMock() - .Setup(v => v.Map(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) - .Returns((p,tvdbid,tvrageid,c) => - new RemoteEpisode + .Setup(v => v.Map(It.IsAny(), It.IsAny())) + .Returns((p,c) => + new RemoteAlbum { DownloadAllowed = true, - ParsedEpisodeInfo = p, - Series = series, - Episodes = episodes.Where(v => v.SceneEpisodeNumber == p.EpisodeNumbers.First()).ToList() + ParsedAlbumInfo = p, + Artist = artist, + Albums = albums.Where(v => v.Title == p.AlbumTitle).ToList() }); Mocker.SetConstant>(new List { - Mocker.Resolve() + Mocker.Resolve() }); var decisions = Subject.GetSearchDecision(reports, criteria); @@ -244,31 +242,31 @@ namespace NzbDrone.Core.Test.DecisionEngineTests } [Test] - public void should_not_allow_download_if_series_is_unknown() + public void should_not_allow_download_if_artist_is_unknown() { GivenSpecifications(_pass1, _pass2, _pass3); - _remoteEpisode.Series = null; + _remoteAlbum.Artist = null; var result = Subject.GetRssDecision(_reports); result.Should().HaveCount(1); - result.First().RemoteEpisode.DownloadAllowed.Should().BeFalse(); + result.First().RemoteAlbum.DownloadAllowed.Should().BeFalse(); } [Test] - public void should_not_allow_download_if_no_episodes_found() + public void should_not_allow_download_if_no_albums_found() { GivenSpecifications(_pass1, _pass2, _pass3); - _remoteEpisode.Episodes = new List(); + _remoteAlbum.Albums = new List(); var result = Subject.GetRssDecision(_reports); result.Should().HaveCount(1); - result.First().RemoteEpisode.DownloadAllowed.Should().BeFalse(); + result.First().RemoteAlbum.DownloadAllowed.Should().BeFalse(); } [Test] @@ -276,7 +274,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenSpecifications(_pass1); - Mocker.GetMock().Setup(c => c.Map(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) + Mocker.GetMock().Setup(c => c.Map(It.IsAny(), It.IsAny())) .Throws(); _reports = new List diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/HistorySpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/HistorySpecificationFixture.cs index ae228c447..4f8aa3891 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/HistorySpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/HistorySpecificationFixture.cs @@ -11,9 +11,8 @@ using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; using NzbDrone.Core.DecisionEngine; - using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.DecisionEngineTests @@ -23,13 +22,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { private HistorySpecification _upgradeHistory; - private RemoteEpisode _parseResultMulti; - private RemoteEpisode _parseResultSingle; + private RemoteAlbum _parseResultMulti; + private RemoteAlbum _parseResultSingle; private QualityModel _upgradableQuality; private QualityModel _notupgradableQuality; - private Series _fakeSeries; - private const int FIRST_EPISODE_ID = 1; - private const int SECOND_EPISODE_ID = 2; + private Artist _fakeArtist; + private const int FIRST_ALBUM_ID = 1; + private const int SECOND_ALBUM_ID = 2; [SetUp] public void Setup() @@ -37,29 +36,29 @@ namespace NzbDrone.Core.Test.DecisionEngineTests Mocker.Resolve(); _upgradeHistory = Mocker.Resolve(); - var singleEpisodeList = new List { new Episode { Id = FIRST_EPISODE_ID, SeasonNumber = 12, EpisodeNumber = 3 } }; - var doubleEpisodeList = new List { - new Episode {Id = FIRST_EPISODE_ID, SeasonNumber = 12, EpisodeNumber = 3 }, - new Episode {Id = SECOND_EPISODE_ID, SeasonNumber = 12, EpisodeNumber = 4 }, - new Episode {Id = 3, SeasonNumber = 12, EpisodeNumber = 5 } + var singleAlbumList = new List { new Album { Id = FIRST_ALBUM_ID} }; + var doubleAlbumList = new List { + new Album {Id = FIRST_ALBUM_ID }, + new Album {Id = SECOND_ALBUM_ID }, + new Album {Id = 3 } }; - _fakeSeries = Builder.CreateNew() + _fakeArtist = Builder.CreateNew() .With(c => c.Profile = new Profile { Cutoff = Quality.MP3_512, Items = Qualities.QualityFixture.GetDefaultQualities() }) .Build(); - _parseResultMulti = new RemoteEpisode + _parseResultMulti = new RemoteAlbum { - Series = _fakeSeries, - ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) }, - Episodes = doubleEpisodeList + Artist = _fakeArtist, + ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) }, + Albums = doubleAlbumList }; - _parseResultSingle = new RemoteEpisode + _parseResultSingle = new RemoteAlbum { - Series = _fakeSeries, - ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) }, - Episodes = singleEpisodeList + Artist = _fakeArtist, + ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) }, + Albums = singleAlbumList }; _upgradableQuality = new QualityModel(Quality.MP3_192, new Revision(version: 1)); @@ -70,9 +69,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests .Returns(true); } - private void GivenMostRecentForEpisode(int episodeId, string downloadId, QualityModel quality, DateTime date, HistoryEventType eventType) + private void GivenMostRecentForAlbum(int albumId, string downloadId, QualityModel quality, DateTime date, HistoryEventType eventType) { - Mocker.GetMock().Setup(s => s.MostRecentForEpisode(episodeId)) + Mocker.GetMock().Setup(s => s.MostRecentForAlbum(albumId)) .Returns(new History.History { DownloadId = downloadId, Quality = quality, Date = date, EventType = eventType }); } @@ -92,14 +91,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [Test] public void should_return_true_if_latest_history_item_is_null() { - Mocker.GetMock().Setup(s => s.MostRecentForEpisode(It.IsAny())).Returns((History.History)null); + Mocker.GetMock().Setup(s => s.MostRecentForAlbum(It.IsAny())).Returns((History.History)null); _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue(); } [Test] public void should_return_true_if_latest_history_item_is_not_grabbed() { - GivenMostRecentForEpisode(FIRST_EPISODE_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow, HistoryEventType.DownloadFailed); + GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow, HistoryEventType.DownloadFailed); _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue(); } @@ -113,57 +112,57 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [Test] public void should_return_true_if_latest_history_item_is_older_than_twelve_hours() { - GivenMostRecentForEpisode(FIRST_EPISODE_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow.AddHours(-13), HistoryEventType.Grabbed); + GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow.AddHours(-12).AddMilliseconds(-1), HistoryEventType.Grabbed); _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue(); } [Test] - public void should_be_upgradable_if_only_episode_is_upgradable() + public void should_be_upgradable_if_only_album_is_upgradable() { - GivenMostRecentForEpisode(FIRST_EPISODE_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); + GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); _upgradeHistory.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue(); } [Test] - public void should_be_upgradable_if_both_episodes_are_upgradable() + public void should_be_upgradable_if_both_albums_are_upgradable() { - GivenMostRecentForEpisode(FIRST_EPISODE_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); - GivenMostRecentForEpisode(SECOND_EPISODE_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); + GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); + GivenMostRecentForAlbum(SECOND_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue(); } [Test] - public void should_not_be_upgradable_if_both_episodes_are_not_upgradable() + public void should_not_be_upgradable_if_both_albums_are_not_upgradable() { - GivenMostRecentForEpisode(FIRST_EPISODE_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); - GivenMostRecentForEpisode(SECOND_EPISODE_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); + GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); + GivenMostRecentForAlbum(SECOND_ALBUM_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); } [Test] - public void should_be_not_upgradable_if_only_first_episodes_is_upgradable() + public void should_be_not_upgradable_if_only_first_albums_is_upgradable() { - GivenMostRecentForEpisode(FIRST_EPISODE_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); - GivenMostRecentForEpisode(FIRST_EPISODE_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); + GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); + GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); } [Test] - public void should_be_not_upgradable_if_only_second_episodes_is_upgradable() + public void should_be_not_upgradable_if_only_second_albums_is_upgradable() { - GivenMostRecentForEpisode(FIRST_EPISODE_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); - GivenMostRecentForEpisode(SECOND_EPISODE_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); + GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); + GivenMostRecentForAlbum(SECOND_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); } [Test] - public void should_not_be_upgradable_if_episode_is_of_same_quality_as_existing() + public void should_not_be_upgradable_if_album_is_of_same_quality_as_existing() { - _fakeSeries.Profile = new Profile { Cutoff = Quality.MP3_512, Items = Qualities.QualityFixture.GetDefaultQualities() }; - _parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.MP3_512, new Revision(version: 1)); + _fakeArtist.Profile = new Profile { Cutoff = Quality.MP3_512, Items = Qualities.QualityFixture.GetDefaultQualities() }; + _parseResultSingle.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_512, new Revision(version: 1)); _upgradableQuality = new QualityModel(Quality.MP3_512, new Revision(version: 1)); - GivenMostRecentForEpisode(FIRST_EPISODE_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); + GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); _upgradeHistory.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse(); } @@ -171,11 +170,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [Test] public void should_not_be_upgradable_if_cutoff_already_met() { - _fakeSeries.Profile = new Profile { Cutoff = Quality.MP3_512, Items = Qualities.QualityFixture.GetDefaultQualities() }; - _parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.MP3_512, new Revision(version: 1)); + _fakeArtist.Profile = new Profile { Cutoff = Quality.MP3_512, Items = Qualities.QualityFixture.GetDefaultQualities() }; + _parseResultSingle.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_512, new Revision(version: 1)); _upgradableQuality = new QualityModel(Quality.MP3_512, new Revision(version: 1)); - GivenMostRecentForEpisode(FIRST_EPISODE_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); + GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _upgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed); _upgradeHistory.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse(); } @@ -183,7 +182,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [Test] public void should_return_false_if_latest_history_item_is_only_one_hour_old() { - GivenMostRecentForEpisode(FIRST_EPISODE_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow.AddHours(-1), HistoryEventType.Grabbed); + GivenMostRecentForAlbum(FIRST_ALBUM_ID, string.Empty, _notupgradableQuality, DateTime.UtcNow.AddHours(-1), HistoryEventType.Grabbed); _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); } @@ -191,7 +190,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void should_return_false_if_latest_history_has_a_download_id_and_cdh_is_disabled() { GivenCdhDisabled(); - GivenMostRecentForEpisode(FIRST_EPISODE_ID, "test", _upgradableQuality, DateTime.UtcNow.AddDays(-100), HistoryEventType.Grabbed); + GivenMostRecentForAlbum(FIRST_ALBUM_ID, "test", _upgradableQuality, DateTime.UtcNow.AddDays(-100), HistoryEventType.Grabbed); _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue(); } @@ -199,20 +198,20 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void should_return_false_if_cutoff_already_met_and_cdh_is_disabled() { GivenCdhDisabled(); - _fakeSeries.Profile = new Profile { Cutoff = Quality.MP3_512, Items = Qualities.QualityFixture.GetDefaultQualities() }; - _parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.MP3_512, new Revision(version: 1)); + _fakeArtist.Profile = new Profile { Cutoff = Quality.MP3_512, Items = Qualities.QualityFixture.GetDefaultQualities() }; + _parseResultSingle.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_512, new Revision(version: 1)); _upgradableQuality = new QualityModel(Quality.MP3_512, new Revision(version: 1)); - GivenMostRecentForEpisode(FIRST_EPISODE_ID, "test", _upgradableQuality, DateTime.UtcNow.AddDays(-100), HistoryEventType.Grabbed); + GivenMostRecentForAlbum(FIRST_ALBUM_ID, "test", _upgradableQuality, DateTime.UtcNow.AddDays(-100), HistoryEventType.Grabbed); _upgradeHistory.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse(); } [Test] - public void should_return_false_if_only_episode_is_not_upgradable_and_cdh_is_disabled() + public void should_return_false_if_only_album_is_not_upgradable_and_cdh_is_disabled() { GivenCdhDisabled(); - GivenMostRecentForEpisode(FIRST_EPISODE_ID, "test", _notupgradableQuality, DateTime.UtcNow.AddDays(-100), HistoryEventType.Grabbed); + GivenMostRecentForAlbum(FIRST_ALBUM_ID, "test", _notupgradableQuality, DateTime.UtcNow.AddDays(-100), HistoryEventType.Grabbed); _upgradeHistory.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse(); } } diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/LanguageSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/LanguageSpecificationFixture.cs index f190677c3..5bb65c62e 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/LanguageSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/LanguageSpecificationFixture.cs @@ -6,7 +6,7 @@ using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Test.DecisionEngineTests { @@ -14,18 +14,18 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class LanguageSpecificationFixture : CoreTest { - private RemoteEpisode _remoteEpisode; + private RemoteAlbum _remoteAlbum; [SetUp] public void Setup() { - _remoteEpisode = new RemoteEpisode + _remoteAlbum = new RemoteAlbum { - ParsedEpisodeInfo = new ParsedEpisodeInfo + ParsedAlbumInfo = new ParsedAlbumInfo { Language = Language.English }, - Series = new Series + Artist = new Artist { Profile = new LazyLoaded(new Profile { @@ -37,12 +37,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests private void WithEnglishRelease() { - _remoteEpisode.ParsedEpisodeInfo.Language = Language.English; + _remoteAlbum.ParsedAlbumInfo.Language = Language.English; } private void WithGermanRelease() { - _remoteEpisode.ParsedEpisodeInfo.Language = Language.German; + _remoteAlbum.ParsedAlbumInfo.Language = Language.German; } [Test] @@ -50,7 +50,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { WithEnglishRelease(); - Mocker.Resolve().IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Mocker.Resolve().IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] @@ -58,7 +58,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { WithGermanRelease(); - Mocker.Resolve().IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Mocker.Resolve().IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } } } \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/MinimumAgeSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/MinimumAgeSpecificationFixture.cs index 745eb68d5..40cc8c941 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/MinimumAgeSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/MinimumAgeSpecificationFixture.cs @@ -13,12 +13,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class MinimumAgeSpecificationFixture : CoreTest { - private RemoteEpisode _remoteEpisode; + private RemoteAlbum _remoteAlbum; [SetUp] public void Setup() { - _remoteEpisode = new RemoteEpisode + _remoteAlbum = new RemoteAlbum { Release = new ReleaseInfo() { DownloadProtocol = DownloadProtocol.Usenet } }; @@ -31,7 +31,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests private void WithAge(int minutes) { - _remoteEpisode.Release.PublishDate = DateTime.UtcNow.AddMinutes(-minutes); + _remoteAlbum.Release.PublishDate = DateTime.UtcNow.AddMinutes(-minutes); } [Test] @@ -40,7 +40,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests WithMinimumAge(0); WithAge(100); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] @@ -49,7 +49,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests WithMinimumAge(30); WithAge(100); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] @@ -58,7 +58,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests WithMinimumAge(30); WithAge(10); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } } } \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/MonitoredAlbumSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/MonitoredAlbumSpecificationFixture.cs new file mode 100644 index 000000000..44494fa1b --- /dev/null +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/MonitoredAlbumSpecificationFixture.cs @@ -0,0 +1,141 @@ +using System.Collections.Generic; +using FizzWare.NBuilder; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.DecisionEngine.Specifications.RssSync; +using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Music; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.DecisionEngineTests +{ + [TestFixture] + + public class MonitoredAlbumSpecificationFixture : CoreTest + { + private MonitoredAlbumSpecification _monitoredAlbumSpecification; + + private RemoteAlbum _parseResultMulti; + private RemoteAlbum _parseResultSingle; + private Artist _fakeArtist; + private Album _firstAlbum; + private Album _secondAlbum; + + [SetUp] + public void Setup() + { + _monitoredAlbumSpecification = Mocker.Resolve(); + + _fakeArtist = Builder.CreateNew() + .With(c => c.Monitored = true) + .Build(); + + _firstAlbum = new Album { Monitored = true }; + _secondAlbum = new Album { Monitored = true }; + + + var singleAlbumList = new List { _firstAlbum }; + var doubleAlbumList = new List { _firstAlbum, _secondAlbum }; + + _parseResultMulti = new RemoteAlbum + { + Artist = _fakeArtist, + Albums = doubleAlbumList + }; + + _parseResultSingle = new RemoteAlbum + { + Artist = _fakeArtist, + Albums = singleAlbumList + }; + } + + private void WithFirstAlbumUnmonitored() + { + _firstAlbum.Monitored = false; + } + + private void WithSecondAlbumUnmonitored() + { + _secondAlbum.Monitored = false; + } + + [Test] + public void setup_should_return_monitored_album_should_return_true() + { + _monitoredAlbumSpecification.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue(); + _monitoredAlbumSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue(); + } + + [Test] + public void not_monitored_series_should_be_skipped() + { + _fakeArtist.Monitored = false; + _monitoredAlbumSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); + } + + [Test] + public void only_album_not_monitored_should_return_false() + { + WithFirstAlbumUnmonitored(); + _monitoredAlbumSpecification.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse(); + } + + [Test] + public void both_albums_not_monitored_should_return_false() + { + WithFirstAlbumUnmonitored(); + WithSecondAlbumUnmonitored(); + _monitoredAlbumSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); + } + + [Test] + public void only_first_album_not_monitored_should_return_false() + { + WithFirstAlbumUnmonitored(); + _monitoredAlbumSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); + } + + [Test] + public void only_second_album_not_monitored_should_return_false() + { + WithSecondAlbumUnmonitored(); + _monitoredAlbumSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); + } + + [Test] + public void should_return_true_for_single_album_search() + { + _fakeArtist.Monitored = false; + _monitoredAlbumSpecification.IsSatisfiedBy(_parseResultSingle, new SingleEpisodeSearchCriteria()).Accepted.Should().BeTrue(); + } + + [Test] + public void should_return_true_if_album_is_monitored_for_season_search() + { + _monitoredAlbumSpecification.IsSatisfiedBy(_parseResultSingle, new SeasonSearchCriteria()).Accepted.Should().BeTrue(); + } + + [Test] + public void should_return_false_if_album_is_not_monitored_for_season_search() + { + WithFirstAlbumUnmonitored(); + _monitoredAlbumSpecification.IsSatisfiedBy(_parseResultSingle, new SeasonSearchCriteria()).Accepted.Should().BeFalse(); + } + + [Test] + public void should_return_true_if_album_is_not_monitored_and_monitoredEpisodesOnly_flag_is_false() + { + WithFirstAlbumUnmonitored(); + _monitoredAlbumSpecification.IsSatisfiedBy(_parseResultSingle, new SingleEpisodeSearchCriteria { MonitoredEpisodesOnly = false }).Accepted.Should().BeTrue(); + } + + [Test] + public void should_return_false_if_album_is_not_monitored_and_monitoredEpisodesOnly_flag_is_true() + { + WithFirstAlbumUnmonitored(); + _monitoredAlbumSpecification.IsSatisfiedBy(_parseResultSingle, new SingleEpisodeSearchCriteria{ MonitoredEpisodesOnly = true}).Accepted.Should().BeFalse(); + } + } +} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs deleted file mode 100644 index 36a46337d..000000000 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs +++ /dev/null @@ -1,141 +0,0 @@ -using System.Collections.Generic; -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.DecisionEngine.Specifications.RssSync; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.DecisionEngineTests -{ - [TestFixture] - - public class MonitoredEpisodeSpecificationFixture : CoreTest - { - private MonitoredEpisodeSpecification _monitoredEpisodeSpecification; - - private RemoteEpisode _parseResultMulti; - private RemoteEpisode _parseResultSingle; - private Series _fakeSeries; - private Episode _firstEpisode; - private Episode _secondEpisode; - - [SetUp] - public void Setup() - { - _monitoredEpisodeSpecification = Mocker.Resolve(); - - _fakeSeries = Builder.CreateNew() - .With(c => c.Monitored = true) - .Build(); - - _firstEpisode = new Episode { Monitored = true }; - _secondEpisode = new Episode { Monitored = true }; - - - var singleEpisodeList = new List { _firstEpisode }; - var doubleEpisodeList = new List { _firstEpisode, _secondEpisode }; - - _parseResultMulti = new RemoteEpisode - { - Series = _fakeSeries, - Episodes = doubleEpisodeList - }; - - _parseResultSingle = new RemoteEpisode - { - Series = _fakeSeries, - Episodes = singleEpisodeList - }; - } - - private void WithFirstEpisodeUnmonitored() - { - _firstEpisode.Monitored = false; - } - - private void WithSecondEpisodeUnmonitored() - { - _secondEpisode.Monitored = false; - } - - [Test] - public void setup_should_return_monitored_episode_should_return_true() - { - _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue(); - _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue(); - } - - [Test] - public void not_monitored_series_should_be_skipped() - { - _fakeSeries.Monitored = false; - _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); - } - - [Test] - public void only_episode_not_monitored_should_return_false() - { - WithFirstEpisodeUnmonitored(); - _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse(); - } - - [Test] - public void both_episodes_not_monitored_should_return_false() - { - WithFirstEpisodeUnmonitored(); - WithSecondEpisodeUnmonitored(); - _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); - } - - [Test] - public void only_first_episode_not_monitored_should_return_false() - { - WithFirstEpisodeUnmonitored(); - _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); - } - - [Test] - public void only_second_episode_not_monitored_should_return_false() - { - WithSecondEpisodeUnmonitored(); - _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); - } - - [Test] - public void should_return_true_for_single_episode_search() - { - _fakeSeries.Monitored = false; - _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SingleEpisodeSearchCriteria()).Accepted.Should().BeTrue(); - } - - [Test] - public void should_return_true_if_episode_is_monitored_for_season_search() - { - _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SeasonSearchCriteria()).Accepted.Should().BeTrue(); - } - - [Test] - public void should_return_false_if_episode_is_not_monitored_for_season_search() - { - WithFirstEpisodeUnmonitored(); - _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SeasonSearchCriteria()).Accepted.Should().BeFalse(); - } - - [Test] - public void should_return_true_if_episode_is_not_monitored_and_monitoredEpisodesOnly_flag_is_false() - { - WithFirstEpisodeUnmonitored(); - _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SingleEpisodeSearchCriteria { MonitoredEpisodesOnly = false }).Accepted.Should().BeTrue(); - } - - [Test] - public void should_return_false_if_episode_is_not_monitored_and_monitoredEpisodesOnly_flag_is_true() - { - WithFirstEpisodeUnmonitored(); - _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new SingleEpisodeSearchCriteria{ MonitoredEpisodesOnly = true}).Accepted.Should().BeFalse(); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/PrioritizeDownloadDecisionFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/PrioritizeDownloadDecisionFixture.cs index 3f519cb3b..1f3d4d03d 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/PrioritizeDownloadDecisionFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/PrioritizeDownloadDecisionFixture.cs @@ -4,7 +4,7 @@ using System.Linq; using Moq; using NzbDrone.Core.Indexers; using NzbDrone.Core.Profiles.Delay; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; using NzbDrone.Core.Parser.Model; @@ -26,33 +26,32 @@ namespace NzbDrone.Core.Test.DecisionEngineTests GivenPreferredDownloadProtocol(DownloadProtocol.Usenet); } - private Episode GivenEpisode(int id) + private Album GivenAlbum(int id) { - return Builder.CreateNew() + return Builder.CreateNew() .With(e => e.Id = id) - .With(e => e.EpisodeNumber = id) .Build(); } - private RemoteEpisode GivenRemoteEpisode(List episodes, QualityModel quality, int age = 0, long size = 0, DownloadProtocol downloadProtocol = DownloadProtocol.Usenet) + private RemoteAlbum GivenRemoteAlbum(List albums, QualityModel quality, int age = 0, long size = 0, DownloadProtocol downloadProtocol = DownloadProtocol.Usenet) { - var remoteEpisode = new RemoteEpisode(); - remoteEpisode.ParsedEpisodeInfo = new ParsedEpisodeInfo(); - remoteEpisode.ParsedEpisodeInfo.Quality = quality; + var remoteAlbum = new RemoteAlbum(); + remoteAlbum.ParsedAlbumInfo = new ParsedAlbumInfo(); + remoteAlbum.ParsedAlbumInfo.Quality = quality; - remoteEpisode.Episodes = new List(); - remoteEpisode.Episodes.AddRange(episodes); + remoteAlbum.Albums = new List(); + remoteAlbum.Albums.AddRange(albums); - remoteEpisode.Release = new ReleaseInfo(); - remoteEpisode.Release.PublishDate = DateTime.Now.AddDays(-age); - remoteEpisode.Release.Size = size; - remoteEpisode.Release.DownloadProtocol = downloadProtocol; + remoteAlbum.Release = new ReleaseInfo(); + remoteAlbum.Release.PublishDate = DateTime.Now.AddDays(-age); + remoteAlbum.Release.Size = size; + remoteAlbum.Release.DownloadProtocol = downloadProtocol; - remoteEpisode.Series = Builder.CreateNew() + remoteAlbum.Artist = Builder.CreateNew() .With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() }) .Build(); - return remoteEpisode; + return remoteAlbum; } private void GivenPreferredDownloadProtocol(DownloadProtocol downloadProtocol) @@ -68,103 +67,75 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [Test] public void should_put_propers_before_non_propers() { - var remoteEpisode1 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256, new Revision(version: 1))); - var remoteEpisode2 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256, new Revision(version: 2))); + var remoteAlbum1 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256, new Revision(version: 1))); + var remoteAlbum2 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256, new Revision(version: 2))); var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode1)); - decisions.Add(new DownloadDecision(remoteEpisode2)); + decisions.Add(new DownloadDecision(remoteAlbum1)); + decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteEpisode.ParsedEpisodeInfo.Quality.Revision.Version.Should().Be(2); + qualifiedReports.First().RemoteAlbum.ParsedAlbumInfo.Quality.Revision.Version.Should().Be(2); } [Test] public void should_put_higher_quality_before_lower() { - var remoteEpisode1 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_192)); - var remoteEpisode2 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256)); + var remoteAlbum1 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_192)); + var remoteAlbum2 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256)); var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode1)); - decisions.Add(new DownloadDecision(remoteEpisode2)); + decisions.Add(new DownloadDecision(remoteAlbum1)); + decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteEpisode.ParsedEpisodeInfo.Quality.Quality.Should().Be(Quality.MP3_256); - } - - [Test] - public void should_order_by_lowest_number_of_episodes() - { - var remoteEpisode1 = GivenRemoteEpisode(new List { GivenEpisode(2) }, new QualityModel(Quality.MP3_256)); - var remoteEpisode2 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256)); - - var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode1)); - decisions.Add(new DownloadDecision(remoteEpisode2)); - - var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteEpisode.Episodes.First().EpisodeNumber.Should().Be(1); - } - - [Test] - public void should_order_by_lowest_number_of_episodes_with_multiple_episodes() - { - var remoteEpisode1 = GivenRemoteEpisode(new List { GivenEpisode(2), GivenEpisode(3) }, new QualityModel(Quality.MP3_256)); - var remoteEpisode2 = GivenRemoteEpisode(new List { GivenEpisode(1), GivenEpisode(2) }, new QualityModel(Quality.MP3_256)); - - var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode1)); - decisions.Add(new DownloadDecision(remoteEpisode2)); - - var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteEpisode.Episodes.First().EpisodeNumber.Should().Be(1); + qualifiedReports.First().RemoteAlbum.ParsedAlbumInfo.Quality.Quality.Should().Be(Quality.MP3_256); } [Test] public void should_order_by_age_then_largest_rounded_to_200mb() { - var remoteEpisodeSd = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_192), size: 100.Megabytes(), age: 1); - var remoteEpisodeHdSmallOld = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256), size: 1200.Megabytes(), age: 1000); - var remoteEpisodeSmallYoung = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256), size: 1250.Megabytes(), age: 10); - var remoteEpisodeHdLargeYoung = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256), size: 3000.Megabytes(), age: 1); + var remoteAlbumSd = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_192), size: 100.Megabytes(), age: 1); + var remoteAlbumHdSmallOld = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256), size: 1200.Megabytes(), age: 1000); + var remoteAlbumSmallYoung = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256), size: 1250.Megabytes(), age: 10); + var remoteAlbumHdLargeYoung = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256), size: 3000.Megabytes(), age: 1); var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisodeSd)); - decisions.Add(new DownloadDecision(remoteEpisodeHdSmallOld)); - decisions.Add(new DownloadDecision(remoteEpisodeSmallYoung)); - decisions.Add(new DownloadDecision(remoteEpisodeHdLargeYoung)); + decisions.Add(new DownloadDecision(remoteAlbumSd)); + decisions.Add(new DownloadDecision(remoteAlbumHdSmallOld)); + decisions.Add(new DownloadDecision(remoteAlbumSmallYoung)); + decisions.Add(new DownloadDecision(remoteAlbumHdLargeYoung)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteEpisode.Should().Be(remoteEpisodeHdLargeYoung); + qualifiedReports.First().RemoteAlbum.Should().Be(remoteAlbumHdLargeYoung); } [Test] public void should_order_by_youngest() { - var remoteEpisode1 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256), age: 10); - var remoteEpisode2 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256), age: 5); + var remoteAlbum1 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256), age: 10); + var remoteAlbum2 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256), age: 5); var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode1)); - decisions.Add(new DownloadDecision(remoteEpisode2)); + decisions.Add(new DownloadDecision(remoteAlbum1)); + decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteEpisode.Should().Be(remoteEpisode2); + qualifiedReports.First().RemoteAlbum.Should().Be(remoteAlbum2); } [Test] public void should_not_throw_if_no_episodes_are_found() { - var remoteEpisode1 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256), size: 500.Megabytes()); - var remoteEpisode2 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256), size: 500.Megabytes()); + var remoteAlbum1 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256), size: 500.Megabytes()); + var remoteAlbum2 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256), size: 500.Megabytes()); - remoteEpisode1.Episodes = new List(); + remoteAlbum1.Albums = new List(); var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode1)); - decisions.Add(new DownloadDecision(remoteEpisode2)); + decisions.Add(new DownloadDecision(remoteAlbum1)); + decisions.Add(new DownloadDecision(remoteAlbum2)); Subject.PrioritizeDecisions(decisions); } @@ -174,15 +145,15 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenPreferredDownloadProtocol(DownloadProtocol.Usenet); - var remoteEpisode1 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256), downloadProtocol: DownloadProtocol.Torrent); - var remoteEpisode2 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256), downloadProtocol: DownloadProtocol.Usenet); + var remoteAlbum1 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256), downloadProtocol: DownloadProtocol.Torrent); + var remoteAlbum2 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256), downloadProtocol: DownloadProtocol.Usenet); var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode1)); - decisions.Add(new DownloadDecision(remoteEpisode2)); + decisions.Add(new DownloadDecision(remoteAlbum1)); + decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteEpisode.Release.DownloadProtocol.Should().Be(DownloadProtocol.Usenet); + qualifiedReports.First().RemoteAlbum.Release.DownloadProtocol.Should().Be(DownloadProtocol.Usenet); } [Test] @@ -190,69 +161,36 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenPreferredDownloadProtocol(DownloadProtocol.Torrent); - var remoteEpisode1 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256), downloadProtocol: DownloadProtocol.Torrent); - var remoteEpisode2 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256), downloadProtocol: DownloadProtocol.Usenet); - - var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode1)); - decisions.Add(new DownloadDecision(remoteEpisode2)); - - var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteEpisode.Release.DownloadProtocol.Should().Be(DownloadProtocol.Torrent); - } - - [Test] - public void should_prefer_season_pack_above_single_episode() - { - var remoteEpisode1 = GivenRemoteEpisode(new List { GivenEpisode(1), GivenEpisode(2) }, new QualityModel(Quality.MP3_256)); - var remoteEpisode2 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256)); - - remoteEpisode1.ParsedEpisodeInfo.FullSeason = true; - - var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode1)); - decisions.Add(new DownloadDecision(remoteEpisode2)); - - var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteEpisode.ParsedEpisodeInfo.FullSeason.Should().BeTrue(); - } - - [Test] - public void should_prefer_multiepisode_over_single_episode_for_anime() - { - var remoteEpisode1 = GivenRemoteEpisode(new List { GivenEpisode(1), GivenEpisode(2) }, new QualityModel(Quality.MP3_256)); - var remoteEpisode2 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256)); - - remoteEpisode1.Series.SeriesType = SeriesTypes.Anime; - remoteEpisode2.Series.SeriesType = SeriesTypes.Anime; + var remoteAlbum1 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256), downloadProtocol: DownloadProtocol.Torrent); + var remoteAlbum2 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256), downloadProtocol: DownloadProtocol.Usenet); var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode1)); - decisions.Add(new DownloadDecision(remoteEpisode2)); + decisions.Add(new DownloadDecision(remoteAlbum1)); + decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteEpisode.Episodes.Count.Should().Be(remoteEpisode1.Episodes.Count); + qualifiedReports.First().RemoteAlbum.Release.DownloadProtocol.Should().Be(DownloadProtocol.Torrent); } [Test] - public void should_prefer_single_episode_over_multi_episode_for_non_anime() + public void should_prefer_single_album_over_multi_album() { - var remoteEpisode1 = GivenRemoteEpisode(new List { GivenEpisode(1), GivenEpisode(2) }, new QualityModel(Quality.MP3_256)); - var remoteEpisode2 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256)); + var remoteAlbum1 = GivenRemoteAlbum(new List { GivenAlbum(1), GivenAlbum(2) }, new QualityModel(Quality.MP3_256)); + var remoteAlbum2 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256)); var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode1)); - decisions.Add(new DownloadDecision(remoteEpisode2)); + decisions.Add(new DownloadDecision(remoteAlbum1)); + decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteEpisode.Episodes.Count.Should().Be(remoteEpisode2.Episodes.Count); + qualifiedReports.First().RemoteAlbum.Albums.Count.Should().Be(remoteAlbum2.Albums.Count); } [Test] public void should_prefer_releases_with_more_seeders() { - var remoteEpisode1 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256)); - var remoteEpisode2 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256)); + var remoteAlbum1 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256)); + var remoteAlbum2 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256)); var torrentInfo1 = new TorrentInfo(); torrentInfo1.PublishDate = DateTime.Now; @@ -263,22 +201,22 @@ namespace NzbDrone.Core.Test.DecisionEngineTests var torrentInfo2 = torrentInfo1.JsonClone(); torrentInfo2.Seeders = 100; - remoteEpisode1.Release = torrentInfo1; - remoteEpisode2.Release = torrentInfo2; + remoteAlbum1.Release = torrentInfo1; + remoteAlbum2.Release = torrentInfo2; var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode1)); - decisions.Add(new DownloadDecision(remoteEpisode2)); + decisions.Add(new DownloadDecision(remoteAlbum1)); + decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - ((TorrentInfo) qualifiedReports.First().RemoteEpisode.Release).Seeders.Should().Be(torrentInfo2.Seeders); + ((TorrentInfo) qualifiedReports.First().RemoteAlbum.Release).Seeders.Should().Be(torrentInfo2.Seeders); } [Test] public void should_prefer_releases_with_more_peers_given_equal_number_of_seeds() { - var remoteEpisode1 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256)); - var remoteEpisode2 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256)); + var remoteAlbum1 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256)); + var remoteAlbum2 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256)); var torrentInfo1 = new TorrentInfo(); torrentInfo1.PublishDate = DateTime.Now; @@ -291,22 +229,22 @@ namespace NzbDrone.Core.Test.DecisionEngineTests var torrentInfo2 = torrentInfo1.JsonClone(); torrentInfo2.Peers = 100; - remoteEpisode1.Release = torrentInfo1; - remoteEpisode2.Release = torrentInfo2; + remoteAlbum1.Release = torrentInfo1; + remoteAlbum2.Release = torrentInfo2; var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode1)); - decisions.Add(new DownloadDecision(remoteEpisode2)); + decisions.Add(new DownloadDecision(remoteAlbum1)); + decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - ((TorrentInfo)qualifiedReports.First().RemoteEpisode.Release).Peers.Should().Be(torrentInfo2.Peers); + ((TorrentInfo)qualifiedReports.First().RemoteAlbum.Release).Peers.Should().Be(torrentInfo2.Peers); } [Test] public void should_prefer_releases_with_more_peers_no_seeds() { - var remoteEpisode1 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256)); - var remoteEpisode2 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256)); + var remoteAlbum1 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256)); + var remoteAlbum2 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256)); var torrentInfo1 = new TorrentInfo(); torrentInfo1.PublishDate = DateTime.Now; @@ -320,22 +258,22 @@ namespace NzbDrone.Core.Test.DecisionEngineTests torrentInfo2.Seeders = 0; torrentInfo2.Peers = 100; - remoteEpisode1.Release = torrentInfo1; - remoteEpisode2.Release = torrentInfo2; + remoteAlbum1.Release = torrentInfo1; + remoteAlbum2.Release = torrentInfo2; var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode1)); - decisions.Add(new DownloadDecision(remoteEpisode2)); + decisions.Add(new DownloadDecision(remoteAlbum1)); + decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - ((TorrentInfo)qualifiedReports.First().RemoteEpisode.Release).Peers.Should().Be(torrentInfo2.Peers); + ((TorrentInfo)qualifiedReports.First().RemoteAlbum.Release).Peers.Should().Be(torrentInfo2.Peers); } [Test] public void should_prefer_first_release_if_peers_and_size_are_too_similar() { - var remoteEpisode1 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256)); - var remoteEpisode2 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256)); + var remoteAlbum1 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256)); + var remoteAlbum2 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256)); var torrentInfo1 = new TorrentInfo(); torrentInfo1.PublishDate = DateTime.Now; @@ -349,42 +287,42 @@ namespace NzbDrone.Core.Test.DecisionEngineTests torrentInfo2.Peers = 10; torrentInfo1.Size = 250.Megabytes(); - remoteEpisode1.Release = torrentInfo1; - remoteEpisode2.Release = torrentInfo2; + remoteAlbum1.Release = torrentInfo1; + remoteAlbum2.Release = torrentInfo2; var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode1)); - decisions.Add(new DownloadDecision(remoteEpisode2)); + decisions.Add(new DownloadDecision(remoteAlbum1)); + decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - ((TorrentInfo) qualifiedReports.First().RemoteEpisode.Release).Should().Be(torrentInfo1); + ((TorrentInfo) qualifiedReports.First().RemoteAlbum.Release).Should().Be(torrentInfo1); } [Test] public void should_prefer_first_release_if_age_and_size_are_too_similar() { - var remoteEpisode1 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256)); - var remoteEpisode2 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_256)); + var remoteAlbum1 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256)); + var remoteAlbum2 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_256)); - remoteEpisode1.Release.PublishDate = DateTime.UtcNow.AddDays(-100); - remoteEpisode1.Release.Size = 200.Megabytes(); + remoteAlbum1.Release.PublishDate = DateTime.UtcNow.AddDays(-100); + remoteAlbum1.Release.Size = 200.Megabytes(); - remoteEpisode2.Release.PublishDate = DateTime.UtcNow.AddDays(-150); - remoteEpisode2.Release.Size = 250.Megabytes(); + remoteAlbum2.Release.PublishDate = DateTime.UtcNow.AddDays(-150); + remoteAlbum2.Release.Size = 250.Megabytes(); var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode1)); - decisions.Add(new DownloadDecision(remoteEpisode2)); + decisions.Add(new DownloadDecision(remoteAlbum1)); + decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - qualifiedReports.First().RemoteEpisode.Release.Should().Be(remoteEpisode1.Release); + qualifiedReports.First().RemoteAlbum.Release.Should().Be(remoteAlbum1.Release); } [Test] public void should_prefer_quality_over_the_number_of_peers() { - var remoteEpisode1 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_512)); - var remoteEpisode2 = GivenRemoteEpisode(new List { GivenEpisode(1) }, new QualityModel(Quality.MP3_192)); + var remoteAlbum1 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_512)); + var remoteAlbum2 = GivenRemoteAlbum(new List { GivenAlbum(1) }, new QualityModel(Quality.MP3_192)); var torrentInfo1 = new TorrentInfo(); torrentInfo1.PublishDate = DateTime.Now; @@ -398,15 +336,15 @@ namespace NzbDrone.Core.Test.DecisionEngineTests torrentInfo2.Peers = 10; torrentInfo1.Size = 250.Megabytes(); - remoteEpisode1.Release = torrentInfo1; - remoteEpisode2.Release = torrentInfo2; + remoteAlbum1.Release = torrentInfo1; + remoteAlbum2.Release = torrentInfo2; var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode1)); - decisions.Add(new DownloadDecision(remoteEpisode2)); + decisions.Add(new DownloadDecision(remoteAlbum1)); + decisions.Add(new DownloadDecision(remoteAlbum2)); var qualifiedReports = Subject.PrioritizeDecisions(decisions); - ((TorrentInfo)qualifiedReports.First().RemoteEpisode.Release).Should().Be(torrentInfo1); + ((TorrentInfo)qualifiedReports.First().RemoteAlbum.Release).Should().Be(torrentInfo1); } } } diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/ProtocolSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/ProtocolSpecificationFixture.cs index 4bfaf34dc..5b9ce36ef 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/ProtocolSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/ProtocolSpecificationFixture.cs @@ -7,22 +7,22 @@ using NzbDrone.Core.Indexers; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Delay; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Test.DecisionEngineTests { [TestFixture] public class ProtocolSpecificationFixture : CoreTest { - private RemoteEpisode _remoteEpisode; + private RemoteAlbum _remoteAlbum; private DelayProfile _delayProfile; [SetUp] public void Setup() { - _remoteEpisode = new RemoteEpisode(); - _remoteEpisode.Release = new ReleaseInfo(); - _remoteEpisode.Series = new Series(); + _remoteAlbum = new RemoteAlbum(); + _remoteAlbum.Release = new ReleaseInfo(); + _remoteAlbum.Artist = new Artist(); _delayProfile = new DelayProfile(); @@ -33,7 +33,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests private void GivenProtocol(DownloadProtocol downloadProtocol) { - _remoteEpisode.Release.DownloadProtocol = downloadProtocol; + _remoteAlbum.Release.DownloadProtocol = downloadProtocol; } [Test] @@ -42,7 +42,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests GivenProtocol(DownloadProtocol.Usenet); _delayProfile.EnableUsenet = true; - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().Be(true); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().Be(true); } [Test] @@ -51,7 +51,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests GivenProtocol(DownloadProtocol.Torrent); _delayProfile.EnableTorrent = true; - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().Be(true); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().Be(true); } [Test] @@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests GivenProtocol(DownloadProtocol.Usenet); _delayProfile.EnableUsenet = false; - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().Be(false); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().Be(false); } [Test] @@ -69,7 +69,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests GivenProtocol(DownloadProtocol.Torrent); _delayProfile.EnableTorrent = false; - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().Be(false); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().Be(false); } } } \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/QualityAllowedByProfileSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/QualityAllowedByProfileSpecificationFixture.cs index 02d80ff3b..d362c6d0e 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/QualityAllowedByProfileSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/QualityAllowedByProfileSpecificationFixture.cs @@ -6,7 +6,7 @@ using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.DecisionEngineTests @@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class QualityAllowedByProfileSpecificationFixture : CoreTest { - private RemoteEpisode remoteEpisode; + private RemoteAlbum remoteAlbum; public static object[] AllowedTestCases = { @@ -26,41 +26,41 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public static object[] DeniedTestCases = { - new object[] { Quality.MP3_192 }, - new object[] { Quality.MP3_320 }, - new object[] { Quality.MP3_320 } + new object[] { Quality.MP3_VBR }, + new object[] { Quality.FLAC }, + new object[] { Quality.Unknown } }; [SetUp] public void Setup() { - var fakeSeries = Builder.CreateNew() + var fakeArtist = Builder.CreateNew() .With(c => c.Profile = (LazyLoaded)new Profile { Cutoff = Quality.MP3_512 }) .Build(); - remoteEpisode = new RemoteEpisode + remoteAlbum = new RemoteAlbum { - Series = fakeSeries, - ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) }, + Artist = fakeArtist, + ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) }, }; } [Test, TestCaseSource(nameof(AllowedTestCases))] public void should_allow_if_quality_is_defined_in_profile(Quality qualityType) { - remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType; - remoteEpisode.Series.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.MP3_192, Quality.MP3_256, Quality.MP3_512); + remoteAlbum.ParsedAlbumInfo.Quality.Quality = qualityType; + remoteAlbum.Artist.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.MP3_192, Quality.MP3_256, Quality.MP3_512); - Subject.IsSatisfiedBy(remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(remoteAlbum, null).Accepted.Should().BeTrue(); } [Test, TestCaseSource(nameof(DeniedTestCases))] public void should_not_allow_if_quality_is_not_defined_in_profile(Quality qualityType) { - remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType; - remoteEpisode.Series.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.MP3_192, Quality.MP3_256, Quality.MP3_512); + remoteAlbum.ParsedAlbumInfo.Quality.Quality = qualityType; + remoteAlbum.Artist.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.MP3_192, Quality.MP3_256, Quality.MP3_512); - Subject.IsSatisfiedBy(remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(remoteAlbum, null).Accepted.Should().BeFalse(); } } } \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs index ef945b79c..38dc8d420 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs @@ -9,7 +9,7 @@ using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; using NzbDrone.Core.Queue; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.DecisionEngineTests @@ -17,41 +17,39 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [TestFixture] public class QueueSpecificationFixture : CoreTest { - private Series _series; - private Episode _episode; - private RemoteEpisode _remoteEpisode; + private Artist _artist; + private Album _album; + private RemoteAlbum _remoteAlbum; - private Series _otherSeries; - private Episode _otherEpisode; + private Artist _otherArtist; + private Album _otherAlbum; [SetUp] public void Setup() { Mocker.Resolve(); - _series = Builder.CreateNew() + _artist = Builder.CreateNew() .With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() }) .Build(); - _episode = Builder.CreateNew() - .With(e => e.SeriesId = _series.Id) + _album = Builder.CreateNew() + .With(e => e.ArtistId = _artist.Id) .Build(); - _otherSeries = Builder.CreateNew() + _otherArtist = Builder.CreateNew() .With(s => s.Id = 2) .Build(); - _otherEpisode = Builder.CreateNew() - .With(e => e.SeriesId = _otherSeries.Id) + _otherAlbum = Builder.CreateNew() + .With(e => e.ArtistId = _otherArtist.Id) .With(e => e.Id = 2) - .With(e => e.SeasonNumber = 2) - .With(e => e.EpisodeNumber = 2) .Build(); - _remoteEpisode = Builder.CreateNew() - .With(r => r.Series = _series) - .With(r => r.Episodes = new List { _episode }) - .With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.MP3_192) }) + _remoteAlbum = Builder.CreateNew() + .With(r => r.Artist = _artist) + .With(r => r.Albums = new List { _album }) + .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_192) }) .Build(); } @@ -62,11 +60,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests .Returns(new List()); } - private void GivenQueue(IEnumerable remoteEpisodes) + private void GivenQueue(IEnumerable remoteAlbums) { - var queue = remoteEpisodes.Select(remoteEpisode => new Queue.Queue + var queue = remoteAlbums.Select(remoteAlbum => new Queue.Queue { - RemoteEpisode = remoteEpisode + RemoteAlbum = remoteAlbum }); Mocker.GetMock() @@ -78,181 +76,181 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public void should_return_true_when_queue_is_empty() { GivenEmptyQueue(); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] public void should_return_true_when_series_doesnt_match() { - var remoteEpisode = Builder.CreateNew() - .With(r => r.Series = _otherSeries) - .With(r => r.Episodes = new List { _episode }) + var remoteAlbum = Builder.CreateNew() + .With(r => r.Artist = _otherArtist) + .With(r => r.Albums = new List { _album }) .Build(); - GivenQueue(new List { remoteEpisode }); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + GivenQueue(new List { remoteAlbum }); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] public void should_return_true_when_quality_in_queue_is_lower() { - _series.Profile.Value.Cutoff = Quality.MP3_512; + _artist.Profile.Value.Cutoff = Quality.MP3_512; - var remoteEpisode = Builder.CreateNew() - .With(r => r.Series = _series) - .With(r => r.Episodes = new List { _episode }) - .With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo + var remoteAlbum = Builder.CreateNew() + .With(r => r.Artist = _artist) + .With(r => r.Albums = new List { _album }) + .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_192) }) .Build(); - GivenQueue(new List { remoteEpisode }); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + GivenQueue(new List { remoteAlbum }); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] - public void should_return_true_when_episode_doesnt_match() + public void should_return_true_when_album_doesnt_match() { - var remoteEpisode = Builder.CreateNew() - .With(r => r.Series = _series) - .With(r => r.Episodes = new List { _otherEpisode }) - .With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo + var remoteAlbum = Builder.CreateNew() + .With(r => r.Artist = _artist) + .With(r => r.Albums = new List { _otherAlbum }) + .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_192) }) .Build(); - GivenQueue(new List { remoteEpisode }); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + GivenQueue(new List { remoteAlbum }); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] public void should_return_false_when_qualities_are_the_same() { - var remoteEpisode = Builder.CreateNew() - .With(r => r.Series = _series) - .With(r => r.Episodes = new List { _episode }) - .With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo + var remoteAlbum = Builder.CreateNew() + .With(r => r.Artist = _artist) + .With(r => r.Albums = new List { _album }) + .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_192) }) .Build(); - GivenQueue(new List { remoteEpisode }); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + GivenQueue(new List { remoteAlbum }); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } [Test] public void should_return_false_when_quality_in_queue_is_better() { - _series.Profile.Value.Cutoff = Quality.MP3_512; + _artist.Profile.Value.Cutoff = Quality.MP3_512; - var remoteEpisode = Builder.CreateNew() - .With(r => r.Series = _series) - .With(r => r.Episodes = new List { _episode }) - .With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo + var remoteAlbum = Builder.CreateNew() + .With(r => r.Artist = _artist) + .With(r => r.Albums = new List { _album }) + .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_256) }) .Build(); - GivenQueue(new List { remoteEpisode }); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + GivenQueue(new List { remoteAlbum }); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } [Test] - public void should_return_false_if_matching_multi_episode_is_in_queue() + public void should_return_false_if_matching_multi_album_is_in_queue() { - var remoteEpisode = Builder.CreateNew() - .With(r => r.Series = _series) - .With(r => r.Episodes = new List { _episode, _otherEpisode }) - .With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo + var remoteAlbum = Builder.CreateNew() + .With(r => r.Artist = _artist) + .With(r => r.Albums = new List { _album, _otherAlbum }) + .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_256) }) .Build(); - GivenQueue(new List { remoteEpisode }); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + GivenQueue(new List { remoteAlbum }); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } [Test] - public void should_return_false_if_multi_episode_has_one_episode_in_queue() + public void should_return_false_if_multi_album_has_one_album_in_queue() { - var remoteEpisode = Builder.CreateNew() - .With(r => r.Series = _series) - .With(r => r.Episodes = new List { _episode }) - .With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo + var remoteAlbum = Builder.CreateNew() + .With(r => r.Artist = _artist) + .With(r => r.Albums = new List { _album }) + .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_256) }) .Build(); - _remoteEpisode.Episodes.Add(_otherEpisode); + _remoteAlbum.Albums.Add(_otherAlbum); - GivenQueue(new List { remoteEpisode }); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + GivenQueue(new List { remoteAlbum }); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } [Test] - public void should_return_false_if_multi_part_episode_is_already_in_queue() + public void should_return_false_if_multi_part_album_is_already_in_queue() { - var remoteEpisode = Builder.CreateNew() - .With(r => r.Series = _series) - .With(r => r.Episodes = new List { _episode, _otherEpisode }) - .With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo + var remoteAlbum = Builder.CreateNew() + .With(r => r.Artist = _artist) + .With(r => r.Albums = new List { _album, _otherAlbum }) + .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_256) }) .Build(); - _remoteEpisode.Episodes.Add(_otherEpisode); + _remoteAlbum.Albums.Add(_otherAlbum); - GivenQueue(new List { remoteEpisode }); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + GivenQueue(new List { remoteAlbum }); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } [Test] - public void should_return_false_if_multi_part_episode_has_two_episodes_in_queue() + public void should_return_false_if_multi_part_album_has_two_episodes_in_queue() { - var remoteEpisodes = Builder.CreateListOfSize(2) + var remoteAlbums = Builder.CreateListOfSize(2) .All() - .With(r => r.Series = _series) - .With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo + .With(r => r.Artist = _artist) + .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel( Quality.MP3_256) }) .TheFirst(1) - .With(r => r.Episodes = new List { _episode }) + .With(r => r.Albums = new List { _album }) .TheNext(1) - .With(r => r.Episodes = new List { _otherEpisode }) + .With(r => r.Albums = new List { _otherAlbum }) .Build(); - _remoteEpisode.Episodes.Add(_otherEpisode); - GivenQueue(remoteEpisodes); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + _remoteAlbum.Albums.Add(_otherAlbum); + GivenQueue(remoteAlbums); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } [Test] public void should_return_false_if_quality_in_queue_meets_cutoff() { - _series.Profile.Value.Cutoff = _remoteEpisode.ParsedEpisodeInfo.Quality.Quality; + _artist.Profile.Value.Cutoff = _remoteAlbum.ParsedAlbumInfo.Quality.Quality; - var remoteEpisode = Builder.CreateNew() - .With(r => r.Series = _series) - .With(r => r.Episodes = new List { _episode }) - .With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo + var remoteAlbum = Builder.CreateNew() + .With(r => r.Artist = _artist) + .With(r => r.Albums = new List { _album }) + .With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_256) }) .Build(); - GivenQueue(new List { remoteEpisode }); + GivenQueue(new List { remoteAlbum }); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } } } \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/RawDiskSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/RawDiskSpecificationFixture.cs index 024c3763b..301566f25 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/RawDiskSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/RawDiskSpecificationFixture.cs @@ -2,7 +2,6 @@ using NUnit.Framework; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Parser.Model; - using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Indexers; @@ -12,12 +11,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class RawDiskSpecificationFixture : CoreTest { - private RemoteEpisode _remoteEpisode; + private RemoteAlbum _remoteAlbum; [SetUp] public void Setup() { - _remoteEpisode = new RemoteEpisode + _remoteAlbum = new RemoteAlbum { Release = new ReleaseInfo() { DownloadProtocol = DownloadProtocol.Torrent } }; @@ -25,48 +24,41 @@ namespace NzbDrone.Core.Test.DecisionEngineTests private void WithContainer(string container) { - _remoteEpisode.Release.Container = container; + _remoteAlbum.Release.Container = container; } [Test] public void should_return_true_if_no_container_specified() { - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] - public void should_return_true_if_mkv() + public void should_return_true_if_flac() { - WithContainer("MKV"); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + WithContainer("FLAC"); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] public void should_return_false_if_vob() { WithContainer("VOB"); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } [Test] public void should_return_false_if_iso() { WithContainer("ISO"); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); - } - - [Test] - public void should_return_false_if_m2ts() - { - WithContainer("M2TS"); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } [Test] public void should_compare_case_insensitive() { WithContainer("vob"); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } } diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/ReleaseRestrictionsSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/ReleaseRestrictionsSpecificationFixture.cs index 5ccaaaedb..721c4ec37 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/ReleaseRestrictionsSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/ReleaseRestrictionsSpecificationFixture.cs @@ -6,21 +6,21 @@ using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Restrictions; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Test.DecisionEngineTests { [TestFixture] public class ReleaseRestrictionsSpecificationFixture : CoreTest { - private RemoteEpisode _remoteEpisode; + private RemoteAlbum _remoteAlbum; [SetUp] public void Setup() { - _remoteEpisode = new RemoteEpisode - { - Series = new Series + _remoteAlbum = new RemoteAlbum + { + Artist = new Artist { Tags = new HashSet() }, @@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests .Setup(s => s.AllForTags(It.IsAny>())) .Returns(new List()); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] @@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenRestictions("WEBRip", null); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] @@ -68,7 +68,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenRestictions("doesnt,exist", null); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } [Test] @@ -76,7 +76,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenRestictions(null, "ignored"); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] @@ -84,7 +84,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenRestictions(null, "edited"); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } [TestCase("EdiTED")] @@ -95,7 +95,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenRestictions(required, null); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [TestCase("EdiTED")] @@ -106,22 +106,22 @@ namespace NzbDrone.Core.Test.DecisionEngineTests { GivenRestictions(null, ignored); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } [Test] public void should_be_false_when_release_contains_one_restricted_word_and_one_required_word() { - _remoteEpisode.Release.Title = "[ www.Speed.cd ] -Whose.Line.is.it.Anyway.US.S10E24.720p.HDTV.x264-BAJSKORV"; + _remoteAlbum.Release.Title = "[ www.Speed.cd ] - Katy Perry - Witness (2017) MP3 [320 kbps] "; Mocker.GetMock() .Setup(s => s.AllForTags(It.IsAny>())) .Returns(new List { - new Restriction { Required = "x264", Ignored = "www.Speed.cd" } + new Restriction { Required = "320", Ignored = "www.Speed.cd" } }); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } } } diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs index a9c8ace61..243f7c740 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs @@ -13,12 +13,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class RetentionSpecificationFixture : CoreTest { - private RemoteEpisode _remoteEpisode; + private RemoteAlbum _remoteAlbum; [SetUp] public void Setup() { - _remoteEpisode = new RemoteEpisode + _remoteAlbum = new RemoteAlbum { Release = new ReleaseInfo() { DownloadProtocol = DownloadProtocol.Usenet } }; @@ -31,7 +31,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests private void WithAge(int days) { - _remoteEpisode.Release.PublishDate = DateTime.UtcNow.AddDays(-days); + _remoteAlbum.Release.PublishDate = DateTime.UtcNow.AddDays(-days); } [Test] @@ -40,7 +40,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests WithRetention(0); WithAge(100); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] @@ -49,7 +49,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests WithRetention(1000); WithAge(100); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] @@ -58,7 +58,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests WithRetention(100); WithAge(100); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] @@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests WithRetention(10); WithAge(100); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } [Test] @@ -76,18 +76,18 @@ namespace NzbDrone.Core.Test.DecisionEngineTests WithRetention(0); WithAge(100); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] public void should_return_true_when_release_is_not_usenet() { - _remoteEpisode.Release.DownloadProtocol = DownloadProtocol.Torrent; + _remoteAlbum.Release.DownloadProtocol = DownloadProtocol.Torrent; WithRetention(10); WithAge(100); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } } } \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DelaySpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DelaySpecificationFixture.cs index a04477fe8..9416dc0c7 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DelaySpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DelaySpecificationFixture.cs @@ -17,7 +17,7 @@ using NzbDrone.Core.Profiles; using NzbDrone.Core.Profiles.Delay; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync { @@ -26,7 +26,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync { private Profile _profile; private DelayProfile _delayProfile; - private RemoteEpisode _remoteEpisode; + private RemoteAlbum _remoteAlbum; [SetUp] public void Setup() @@ -38,12 +38,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync .With(d => d.PreferredProtocol = DownloadProtocol.Usenet) .Build(); - var series = Builder.CreateNew() + var artist = Builder.CreateNew() .With(s => s.Profile = _profile) .Build(); - _remoteEpisode = Builder.CreateNew() - .With(r => r.Series = series) + _remoteAlbum = Builder.CreateNew() + .With(r => r.Artist = artist) .Build(); _profile.Items = new List(); @@ -53,30 +53,30 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync _profile.Cutoff = Quality.MP3_320; - _remoteEpisode.ParsedEpisodeInfo = new ParsedEpisodeInfo(); - _remoteEpisode.Release = new ReleaseInfo(); - _remoteEpisode.Release.DownloadProtocol = DownloadProtocol.Usenet; + _remoteAlbum.ParsedAlbumInfo = new ParsedAlbumInfo(); + _remoteAlbum.Release = new ReleaseInfo(); + _remoteAlbum.Release.DownloadProtocol = DownloadProtocol.Usenet; - _remoteEpisode.Episodes = Builder.CreateListOfSize(1).Build().ToList(); - _remoteEpisode.Episodes.First().EpisodeFileId = 0; + _remoteAlbum.Albums = Builder.CreateListOfSize(1).Build().ToList(); + + Mocker.GetMock() + .Setup(s => s.GetFilesByAlbum(It.IsAny(), It.IsAny())) + .Returns(new List {}); Mocker.GetMock() .Setup(s => s.BestForTags(It.IsAny>())) .Returns(_delayProfile); Mocker.GetMock() - .Setup(s => s.GetPendingRemoteEpisodes(It.IsAny())) - .Returns(new List()); + .Setup(s => s.GetPendingRemoteAlbums(It.IsAny())) + .Returns(new List()); } private void GivenExistingFile(QualityModel quality) { - _remoteEpisode.Episodes.First().EpisodeFileId = 1; - - _remoteEpisode.Episodes.First().EpisodeFile = new LazyLoaded(new EpisodeFile - { - Quality = quality - }); + Mocker.GetMock() + .Setup(s => s.GetFilesByAlbum(It.IsAny(), It.IsAny())) + .Returns(new List { new TrackFile { Quality = quality } }); } private void GivenUpgradeForExistingFile() @@ -89,18 +89,18 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync [Test] public void should_be_true_when_user_invoked_search() { - Subject.IsSatisfiedBy(new RemoteEpisode(), new SingleEpisodeSearchCriteria { UserInvokedSearch = true }).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(new RemoteAlbum(), new AlbumSearchCriteria { UserInvokedSearch = true }).Accepted.Should().BeTrue(); } [Test] public void should_be_false_when_system_invoked_search_and_release_is_younger_than_delay() { - _remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.MP3_192); - _remoteEpisode.Release.PublishDate = DateTime.UtcNow; + _remoteAlbum.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_192); + _remoteAlbum.Release.PublishDate = DateTime.UtcNow; _delayProfile.UsenetDelay = 720; - Subject.IsSatisfiedBy(_remoteEpisode, new SingleEpisodeSearchCriteria()).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteAlbum, new AlbumSearchCriteria()).Accepted.Should().BeFalse(); } [Test] @@ -108,44 +108,44 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync { _delayProfile.UsenetDelay = 0; - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] public void should_be_true_when_quality_is_last_allowed_in_profile() { - _remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.MP3_320); + _remoteAlbum.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_320); - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] public void should_be_true_when_release_is_older_than_delay() { - _remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.MP3_256); - _remoteEpisode.Release.PublishDate = DateTime.UtcNow.AddHours(-10); + _remoteAlbum.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_256); + _remoteAlbum.Release.PublishDate = DateTime.UtcNow.AddHours(-10); _delayProfile.UsenetDelay = 60; - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] public void should_be_false_when_release_is_younger_than_delay() { - _remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.MP3_192); - _remoteEpisode.Release.PublishDate = DateTime.UtcNow; + _remoteAlbum.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_192); + _remoteAlbum.Release.PublishDate = DateTime.UtcNow; _delayProfile.UsenetDelay = 720; - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } [Test] - public void should_be_true_when_release_is_a_proper_for_existing_episode() + public void should_be_true_when_release_is_a_proper_for_existing_album() { - _remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.MP3_256, new Revision(version: 2)); - _remoteEpisode.Release.PublishDate = DateTime.UtcNow; + _remoteAlbum.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_256, new Revision(version: 2)); + _remoteAlbum.Release.PublishDate = DateTime.UtcNow; GivenExistingFile(new QualityModel(Quality.MP3_256)); GivenUpgradeForExistingFile(); @@ -156,14 +156,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync _delayProfile.UsenetDelay = 720; - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] - public void should_be_true_when_release_is_a_real_for_existing_episode() + public void should_be_true_when_release_is_a_real_for_existing_album() { - _remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.MP3_256, new Revision(real: 1)); - _remoteEpisode.Release.PublishDate = DateTime.UtcNow; + _remoteAlbum.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_256, new Revision(real: 1)); + _remoteAlbum.Release.PublishDate = DateTime.UtcNow; GivenExistingFile(new QualityModel(Quality.MP3_256)); GivenUpgradeForExistingFile(); @@ -174,20 +174,20 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync _delayProfile.UsenetDelay = 720; - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] - public void should_be_false_when_release_is_proper_for_existing_episode_of_different_quality() + public void should_be_false_when_release_is_proper_for_existing_album_of_different_quality() { - _remoteEpisode.ParsedEpisodeInfo.Quality = new QualityModel(Quality.MP3_256, new Revision(version: 2)); - _remoteEpisode.Release.PublishDate = DateTime.UtcNow; + _remoteAlbum.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_256, new Revision(version: 2)); + _remoteAlbum.Release.PublishDate = DateTime.UtcNow; GivenExistingFile(new QualityModel(Quality.MP3_192)); _delayProfile.UsenetDelay = 720; - Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); } } } diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/ProperSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/ProperSpecificationFixture.cs index 7fe60be78..4eb2968d2 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/ProperSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/ProperSpecificationFixture.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; +using Moq; using NzbDrone.Core.Configuration; using NzbDrone.Core.DecisionEngine.Specifications.RssSync; using NzbDrone.Core.IndexerSearch.Definitions; @@ -10,7 +11,7 @@ using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Test.Framework; @@ -21,38 +22,43 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync public class ProperSpecificationFixture : CoreTest { - private RemoteEpisode _parseResultMulti; - private RemoteEpisode _parseResultSingle; - private EpisodeFile _firstFile; - private EpisodeFile _secondFile; + private RemoteAlbum _parseResultMulti; + private RemoteAlbum _parseResultSingle; + private TrackFile _firstFile; + private TrackFile _secondFile; [SetUp] public void Setup() { Mocker.Resolve(); - _firstFile = new EpisodeFile { Quality = new QualityModel(Quality.MP3_512, new Revision(version: 1)), DateAdded = DateTime.Now }; - _secondFile = new EpisodeFile { Quality = new QualityModel(Quality.MP3_512, new Revision(version: 1)), DateAdded = DateTime.Now }; + _firstFile = new TrackFile { Quality = new QualityModel(Quality.FLAC, new Revision(version: 1)), DateAdded = DateTime.Now }; + _secondFile = new TrackFile { Quality = new QualityModel(Quality.FLAC, new Revision(version: 1)), DateAdded = DateTime.Now }; - var singleEpisodeList = new List { new Episode { EpisodeFile = _firstFile, EpisodeFileId = 1 }, new Episode { EpisodeFile = null } }; - var doubleEpisodeList = new List { new Episode { EpisodeFile = _firstFile, EpisodeFileId = 1 }, new Episode { EpisodeFile = _secondFile, EpisodeFileId = 1 }, new Episode { EpisodeFile = null } }; + var singleEpisodeList = new List { new Album {}, new Album {} }; + var doubleEpisodeList = new List { new Album {}, new Album {}, new Album {} }; - var fakeSeries = Builder.CreateNew() - .With(c => c.Profile = new Profile { Cutoff = Quality.MP3_512 }) + + var fakeArtist = Builder.CreateNew() + .With(c => c.Profile = new Profile { Cutoff = Quality.FLAC }) .Build(); - _parseResultMulti = new RemoteEpisode + Mocker.GetMock() + .Setup(c => c.GetFilesByAlbum(It.IsAny(), It.IsAny())) + .Returns(new List { _firstFile, _secondFile }); + + _parseResultMulti = new RemoteAlbum { - Series = fakeSeries, - ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) }, - Episodes = doubleEpisodeList + Artist = fakeArtist, + ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_256, new Revision(version: 2)) }, + Albums = doubleEpisodeList }; - _parseResultSingle = new RemoteEpisode + _parseResultSingle = new RemoteAlbum { - Series = fakeSeries, - ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) }, - Episodes = singleEpisodeList + Artist = fakeArtist, + ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_256, new Revision(version: 2)) }, + Albums = singleEpisodeList }; } @@ -69,36 +75,36 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync } [Test] - public void should_return_false_when_episodeFile_was_added_more_than_7_days_ago() + public void should_return_false_when_trackFile_was_added_more_than_7_days_ago() { - _firstFile.Quality.Quality = Quality.MP3_192; + _firstFile.Quality.Quality = Quality.MP3_256; _firstFile.DateAdded = DateTime.Today.AddDays(-30); Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse(); } [Test] - public void should_return_false_when_first_episodeFile_was_added_more_than_7_days_ago() + public void should_return_false_when_first_trackFile_was_added_more_than_7_days_ago() { - _firstFile.Quality.Quality = Quality.MP3_192; - _secondFile.Quality.Quality = Quality.MP3_192; + _firstFile.Quality.Quality = Quality.MP3_256; + _secondFile.Quality.Quality = Quality.MP3_256; _firstFile.DateAdded = DateTime.Today.AddDays(-30); Subject.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); } [Test] - public void should_return_false_when_second_episodeFile_was_added_more_than_7_days_ago() + public void should_return_false_when_second_trackFile_was_added_more_than_7_days_ago() { - _firstFile.Quality.Quality = Quality.MP3_192; - _secondFile.Quality.Quality = Quality.MP3_192; + _firstFile.Quality.Quality = Quality.MP3_256; + _secondFile.Quality.Quality = Quality.MP3_256; _secondFile.DateAdded = DateTime.Today.AddDays(-30); Subject.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); } [Test] - public void should_return_true_when_episodeFile_was_added_more_than_7_days_ago_but_proper_is_for_better_quality() + public void should_return_true_when_trackFile_was_added_more_than_7_days_ago_but_proper_is_for_better_quality() { WithFirstFileUpgradable(); @@ -107,7 +113,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync } [Test] - public void should_return_true_when_episodeFile_was_added_more_than_7_days_ago_but_is_for_search() + public void should_return_true_when_trackFile_was_added_more_than_7_days_ago_but_is_for_search() { WithFirstFileUpgradable(); @@ -118,18 +124,18 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync [Test] public void should_return_false_when_proper_but_auto_download_propers_is_false() { - _firstFile.Quality.Quality = Quality.MP3_192; + _firstFile.Quality.Quality = Quality.MP3_256; _firstFile.DateAdded = DateTime.Today; Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse(); } [Test] - public void should_return_true_when_episodeFile_was_added_today() + public void should_return_true_when_trackFile_was_added_today() { GivenAutoDownloadPropers(); - _firstFile.Quality.Quality = Quality.MP3_192; + _firstFile.Quality.Quality = Quality.MP3_256; _firstFile.DateAdded = DateTime.Today; Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue(); diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/Search/ArtistSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/Search/ArtistSpecificationFixture.cs new file mode 100644 index 000000000..443bb0c75 --- /dev/null +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/Search/ArtistSpecificationFixture.cs @@ -0,0 +1,46 @@ +using FizzWare.NBuilder; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.DecisionEngine.Specifications.Search; +using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; +using NzbDrone.Test.Common; + +namespace NzbDrone.Core.Test.DecisionEngineTests.Search +{ + [TestFixture] + public class ArtistSpecificationFixture : TestBase + { + private Artist _artist1; + private Artist _artist2; + private RemoteAlbum _remoteAlbum = new RemoteAlbum(); + private SearchCriteriaBase _searchCriteria = new AlbumSearchCriteria(); + + [SetUp] + public void Setup() + { + _artist1 = Builder.CreateNew().With(s => s.Id = 1).Build(); + _artist2 = Builder.CreateNew().With(s => s.Id = 2).Build(); + + _remoteAlbum.Artist = _artist1; + } + + [Test] + public void should_return_false_if_artist_doesnt_match() + { + _searchCriteria.Artist = _artist2; + + Subject.IsSatisfiedBy(_remoteAlbum, _searchCriteria).Accepted.Should().BeFalse(); + } + + [Test] + public void should_return_true_when_artist_ids_match() + { + _searchCriteria.Artist = _artist1; + + Subject.IsSatisfiedBy(_remoteAlbum, _searchCriteria).Accepted.Should().BeTrue(); + } + } +} diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/Search/SeriesSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/Search/SeriesSpecificationFixture.cs deleted file mode 100644 index 279890763..000000000 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/Search/SeriesSpecificationFixture.cs +++ /dev/null @@ -1,45 +0,0 @@ -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.DecisionEngine.Specifications.Search; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv; -using NzbDrone.Test.Common; - -namespace NzbDrone.Core.Test.DecisionEngineTests.Search -{ - [TestFixture] - public class SeriesSpecificationFixture : TestBase - { - private Series _series1; - private Series _series2; - private RemoteEpisode _remoteEpisode = new RemoteEpisode(); - private SearchCriteriaBase _searchCriteria = new SingleEpisodeSearchCriteria(); - - [SetUp] - public void Setup() - { - _series1 = Builder.CreateNew().With(s => s.Id = 1).Build(); - _series2 = Builder.CreateNew().With(s => s.Id = 2).Build(); - - _remoteEpisode.Series = _series1; - } - - [Test] - public void should_return_false_if_series_doesnt_match() - { - _searchCriteria.Series = _series2; - - Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Accepted.Should().BeFalse(); - } - - [Test] - public void should_return_true_when_series_ids_match() - { - _searchCriteria.Series = _series1; - - Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Accepted.Should().BeTrue(); - } - } -} diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/UpgradeDiskSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/UpgradeDiskSpecificationFixture.cs index b96334abb..214cb2196 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/UpgradeDiskSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/UpgradeDiskSpecificationFixture.cs @@ -3,14 +3,14 @@ using System.Collections.Generic; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; +using Moq; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; using NzbDrone.Core.DecisionEngine; - using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.DecisionEngineTests @@ -19,42 +19,44 @@ namespace NzbDrone.Core.Test.DecisionEngineTests public class UpgradeDiskSpecificationFixture : CoreTest { - private UpgradeDiskSpecification _upgradeDisk; - - private RemoteEpisode _parseResultMulti; - private RemoteEpisode _parseResultSingle; - private EpisodeFile _firstFile; - private EpisodeFile _secondFile; + private RemoteAlbum _parseResultMulti; + private RemoteAlbum _parseResultSingle; + private TrackFile _firstFile; + private TrackFile _secondFile; [SetUp] public void Setup() { Mocker.Resolve(); - _upgradeDisk = Mocker.Resolve(); - _firstFile = new EpisodeFile { Quality = new QualityModel(Quality.MP3_512, new Revision(version: 2)), DateAdded = DateTime.Now }; - _secondFile = new EpisodeFile { Quality = new QualityModel(Quality.MP3_512, new Revision(version: 2)), DateAdded = DateTime.Now }; + _firstFile = new TrackFile { Quality = new QualityModel(Quality.FLAC, new Revision(version: 2)), DateAdded = DateTime.Now }; + _secondFile = new TrackFile { Quality = new QualityModel(Quality.FLAC, new Revision(version: 2)), DateAdded = DateTime.Now }; - var singleEpisodeList = new List { new Episode { EpisodeFile = _firstFile, EpisodeFileId = 1 }, new Episode { EpisodeFile = null } }; - var doubleEpisodeList = new List { new Episode { EpisodeFile = _firstFile, EpisodeFileId = 1 }, new Episode { EpisodeFile = _secondFile, EpisodeFileId = 1 }, new Episode { EpisodeFile = null } }; + var singleEpisodeList = new List { new Album {}}; + var doubleEpisodeList = new List { new Album {}, new Album {}, new Album {} }; - var fakeSeries = Builder.CreateNew() + var fakeArtist = Builder.CreateNew() .With(c => c.Profile = new Profile { Cutoff = Quality.MP3_512, Items = Qualities.QualityFixture.GetDefaultQualities() }) .Build(); - _parseResultMulti = new RemoteEpisode + Mocker.GetMock() + .Setup(c => c.GetFilesByAlbum(It.IsAny(), It.IsAny())) + .Returns(new List { _firstFile, _secondFile }); + + _parseResultMulti = new RemoteAlbum { - Series = fakeSeries, - ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) }, - Episodes = doubleEpisodeList + Artist = fakeArtist, + ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_256, new Revision(version: 2)) }, + Albums = doubleEpisodeList }; - _parseResultSingle = new RemoteEpisode + _parseResultSingle = new RemoteAlbum { - Series = fakeSeries, - ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) }, - Episodes = singleEpisodeList + Artist = fakeArtist, + ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_256, new Revision(version: 2)) }, + Albums = singleEpisodeList }; + } private void WithFirstFileUpgradable() @@ -68,61 +70,42 @@ namespace NzbDrone.Core.Test.DecisionEngineTests } [Test] - public void should_return_true_if_episode_has_no_existing_file() + public void should_return_true_if_album_has_no_existing_file() { - _parseResultSingle.Episodes.ForEach(c => c.EpisodeFileId = 0); - _upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue(); - } + Mocker.GetMock() + .Setup(c => c.GetFilesByAlbum(It.IsAny(), It.IsAny())) + .Returns(new List { }); - [Test] - public void should_return_true_if_single_episode_doesnt_exist_on_disk() - { - _parseResultSingle.Episodes = new List(); - - _upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue(); + Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue(); } [Test] - public void should_be_upgradable_if_only_episode_is_upgradable() + public void should_return_true_if_single_album_doesnt_exist_on_disk() { - WithFirstFileUpgradable(); - _upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue(); - } + _parseResultSingle.Albums = new List(); - [Test] - public void should_be_upgradable_if_both_episodes_are_upgradable() - { - WithFirstFileUpgradable(); - WithSecondFileUpgradable(); - _upgradeDisk.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue(); - } - - [Test] - public void should_be_not_upgradable_if_both_episodes_are_not_upgradable() - { - _upgradeDisk.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue(); } [Test] - public void should_be_not_upgradable_if_only_first_episodes_is_upgradable() + public void should_be_upgradable_if_album_is_upgradable() { WithFirstFileUpgradable(); - _upgradeDisk.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue(); } [Test] - public void should_be_not_upgradable_if_only_second_episodes_is_upgradable() + public void should_not_be_upgradable_if_qualities_are_the_same() { - WithSecondFileUpgradable(); - _upgradeDisk.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeFalse(); + _firstFile.Quality = new QualityModel(Quality.MP3_512); + _parseResultSingle.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_512); + Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse(); } [Test] - public void should_not_be_upgradable_if_qualities_are_the_same() + public void should_not_be_upgradable_if_all_tracks_are_not_upgradable() { - _firstFile.Quality = new QualityModel(Quality.MP3_512); - _parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.MP3_512); - _upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse(); + Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse(); } } } \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/Download/DownloadApprovedReportsTests/DownloadApprovedFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadApprovedReportsTests/DownloadApprovedFixture.cs index 785a2d009..07ffe6f95 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadApprovedReportsTests/DownloadApprovedFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadApprovedReportsTests/DownloadApprovedFixture.cs @@ -11,7 +11,7 @@ using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests @@ -27,89 +27,88 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests .Returns>(v => v); } - private Episode GetEpisode(int id) + private Album GetAlbum(int id) { - return Builder.CreateNew() + return Builder.CreateNew() .With(e => e.Id = id) - .With(e => e.EpisodeNumber = id) .Build(); } - private RemoteEpisode GetRemoteEpisode(List episodes, QualityModel quality) + private RemoteAlbum GetRemoteAlbum(List albums, QualityModel quality) { - var remoteEpisode = new RemoteEpisode(); - remoteEpisode.ParsedEpisodeInfo = new ParsedEpisodeInfo(); - remoteEpisode.ParsedEpisodeInfo.Quality = quality; + var remoteAlbum = new RemoteAlbum(); + remoteAlbum.ParsedAlbumInfo = new ParsedAlbumInfo(); + remoteAlbum.ParsedAlbumInfo.Quality = quality; - remoteEpisode.Episodes = new List(); - remoteEpisode.Episodes.AddRange(episodes); + remoteAlbum.Albums = new List(); + remoteAlbum.Albums.AddRange(albums); - remoteEpisode.Release = new ReleaseInfo(); - remoteEpisode.Release.PublishDate = DateTime.UtcNow; + remoteAlbum.Release = new ReleaseInfo(); + remoteAlbum.Release.PublishDate = DateTime.UtcNow; - remoteEpisode.Series = Builder.CreateNew() + remoteAlbum.Artist = Builder.CreateNew() .With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() }) .Build(); - return remoteEpisode; + return remoteAlbum; } [Test] - public void should_download_report_if_epsiode_was_not_already_downloaded() + public void should_download_report_if_album_was_not_already_downloaded() { - var episodes = new List { GetEpisode(1) }; - var remoteEpisode = GetRemoteEpisode(episodes, new QualityModel(Quality.MP3_192)); + var albums = new List { GetAlbum(1) }; + var remoteEpisode = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_192)); var decisions = new List(); decisions.Add(new DownloadDecision(remoteEpisode)); Subject.ProcessDecisions(decisions); - Mocker.GetMock().Verify(v => v.DownloadReport(It.IsAny()), Times.Once()); + Mocker.GetMock().Verify(v => v.DownloadReport(It.IsAny()), Times.Once()); } [Test] - public void should_only_download_episode_once() + public void should_only_download_album_once() { - var episodes = new List { GetEpisode(1) }; - var remoteEpisode = GetRemoteEpisode(episodes, new QualityModel(Quality.MP3_192)); + var albums = new List { GetAlbum(1) }; + var remoteAlbum = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_192)); var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode)); - decisions.Add(new DownloadDecision(remoteEpisode)); + decisions.Add(new DownloadDecision(remoteAlbum)); + decisions.Add(new DownloadDecision(remoteAlbum)); Subject.ProcessDecisions(decisions); - Mocker.GetMock().Verify(v => v.DownloadReport(It.IsAny()), Times.Once()); + Mocker.GetMock().Verify(v => v.DownloadReport(It.IsAny()), Times.Once()); } [Test] - public void should_not_download_if_any_episode_was_already_downloaded() + public void should_not_download_if_any_album_was_already_downloaded() { - var remoteEpisode1 = GetRemoteEpisode( - new List { GetEpisode(1) }, + var remoteAlbum1 = GetRemoteAlbum( + new List { GetAlbum(1) }, new QualityModel(Quality.MP3_192) ); - var remoteEpisode2 = GetRemoteEpisode( - new List { GetEpisode(1), GetEpisode(2) }, + var remoteAlbum2 = GetRemoteAlbum( + new List { GetAlbum(1), GetAlbum(2) }, new QualityModel(Quality.MP3_192) ); var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode1)); - decisions.Add(new DownloadDecision(remoteEpisode2)); + decisions.Add(new DownloadDecision(remoteAlbum1)); + decisions.Add(new DownloadDecision(remoteAlbum2)); Subject.ProcessDecisions(decisions); - Mocker.GetMock().Verify(v => v.DownloadReport(It.IsAny()), Times.Once()); + Mocker.GetMock().Verify(v => v.DownloadReport(It.IsAny()), Times.Once()); } [Test] public void should_return_downloaded_reports() { - var episodes = new List { GetEpisode(1) }; - var remoteEpisode = GetRemoteEpisode(episodes, new QualityModel(Quality.MP3_192)); + var albums = new List { GetAlbum(1) }; + var remoteAlbum = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_192)); var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode)); + decisions.Add(new DownloadDecision(remoteAlbum)); Subject.ProcessDecisions(decisions).Grabbed.Should().HaveCount(1); } @@ -117,19 +116,19 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests [Test] public void should_return_all_downloaded_reports() { - var remoteEpisode1 = GetRemoteEpisode( - new List { GetEpisode(1) }, + var remoteAlbum1 = GetRemoteAlbum( + new List { GetAlbum(1) }, new QualityModel(Quality.MP3_192) ); - var remoteEpisode2 = GetRemoteEpisode( - new List { GetEpisode(2) }, + var remoteAlbum2 = GetRemoteAlbum( + new List { GetAlbum(2) }, new QualityModel(Quality.MP3_192) ); var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode1)); - decisions.Add(new DownloadDecision(remoteEpisode2)); + decisions.Add(new DownloadDecision(remoteAlbum1)); + decisions.Add(new DownloadDecision(remoteAlbum2)); Subject.ProcessDecisions(decisions).Grabbed.Should().HaveCount(2); } @@ -137,25 +136,25 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests [Test] public void should_only_return_downloaded_reports() { - var remoteEpisode1 = GetRemoteEpisode( - new List { GetEpisode(1) }, + var remoteAlbum1 = GetRemoteAlbum( + new List { GetAlbum(1) }, new QualityModel(Quality.MP3_192) ); - var remoteEpisode2 = GetRemoteEpisode( - new List { GetEpisode(2) }, + var remoteAlbum2 = GetRemoteAlbum( + new List { GetAlbum(2) }, new QualityModel(Quality.MP3_192) ); - var remoteEpisode3 = GetRemoteEpisode( - new List { GetEpisode(2) }, + var remoteAlbum3 = GetRemoteAlbum( + new List { GetAlbum(2) }, new QualityModel(Quality.MP3_192) ); var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode1)); - decisions.Add(new DownloadDecision(remoteEpisode2)); - decisions.Add(new DownloadDecision(remoteEpisode3)); + decisions.Add(new DownloadDecision(remoteAlbum1)); + decisions.Add(new DownloadDecision(remoteAlbum2)); + decisions.Add(new DownloadDecision(remoteAlbum3)); Subject.ProcessDecisions(decisions).Grabbed.Should().HaveCount(2); } @@ -163,13 +162,13 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests [Test] public void should_not_add_to_downloaded_list_when_download_fails() { - var episodes = new List { GetEpisode(1) }; - var remoteEpisode = GetRemoteEpisode(episodes, new QualityModel(Quality.MP3_192)); + var albums = new List { GetAlbum(1) }; + var remoteAlbum = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_192)); var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode)); + decisions.Add(new DownloadDecision(remoteAlbum)); - Mocker.GetMock().Setup(s => s.DownloadReport(It.IsAny())).Throws(new Exception()); + Mocker.GetMock().Setup(s => s.DownloadReport(It.IsAny())).Throws(new Exception()); Subject.ProcessDecisions(decisions).Grabbed.Should().BeEmpty(); ExceptionVerification.ExpectedWarns(1); } @@ -178,8 +177,8 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests public void should_return_an_empty_list_when_none_are_appproved() { var decisions = new List(); - decisions.Add(new DownloadDecision(null, new Rejection("Failure!"))); - decisions.Add(new DownloadDecision(null, new Rejection("Failure!"))); + decisions.Add(new DownloadDecision(new RemoteAlbum(), new Rejection("Failure!"))); + decisions.Add(new DownloadDecision(new RemoteAlbum(), new Rejection("Failure!"))); Subject.GetQualifiedReports(decisions).Should().BeEmpty(); } @@ -187,26 +186,26 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests [Test] public void should_not_grab_if_pending() { - var episodes = new List { GetEpisode(1) }; - var remoteEpisode = GetRemoteEpisode(episodes, new QualityModel(Quality.MP3_192)); + var albums = new List { GetAlbum(1) }; + var remoteAlbum = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_192)); var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode, new Rejection("Failure!", RejectionType.Temporary))); - decisions.Add(new DownloadDecision(remoteEpisode)); + decisions.Add(new DownloadDecision(remoteAlbum, new Rejection("Failure!", RejectionType.Temporary))); + decisions.Add(new DownloadDecision(remoteAlbum)); Subject.ProcessDecisions(decisions); - Mocker.GetMock().Verify(v => v.DownloadReport(It.IsAny()), Times.Never()); + Mocker.GetMock().Verify(v => v.DownloadReport(It.IsAny()), Times.Never()); } [Test] - public void should_not_add_to_pending_if_episode_was_grabbed() + public void should_not_add_to_pending_if_album_was_grabbed() { - var episodes = new List { GetEpisode(1) }; - var remoteEpisode = GetRemoteEpisode(episodes, new QualityModel(Quality.MP3_192)); + var albums = new List { GetAlbum(1) }; + var remoteAlbum = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_192)); var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode)); - decisions.Add(new DownloadDecision(remoteEpisode, new Rejection("Failure!", RejectionType.Temporary))); + decisions.Add(new DownloadDecision(remoteAlbum)); + decisions.Add(new DownloadDecision(remoteAlbum, new Rejection("Failure!", RejectionType.Temporary))); Subject.ProcessDecisions(decisions); Mocker.GetMock().Verify(v => v.Add(It.IsAny()), Times.Never()); @@ -215,12 +214,12 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests [Test] public void should_add_to_pending_even_if_already_added_to_pending() { - var episodes = new List { GetEpisode(1) }; - var remoteEpisode = GetRemoteEpisode(episodes, new QualityModel(Quality.MP3_192)); + var albums = new List { GetAlbum(1) }; + var remoteAlbum = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_192)); var decisions = new List(); - decisions.Add(new DownloadDecision(remoteEpisode, new Rejection("Failure!", RejectionType.Temporary))); - decisions.Add(new DownloadDecision(remoteEpisode, new Rejection("Failure!", RejectionType.Temporary))); + decisions.Add(new DownloadDecision(remoteAlbum, new Rejection("Failure!", RejectionType.Temporary))); + decisions.Add(new DownloadDecision(remoteAlbum, new Rejection("Failure!", RejectionType.Temporary))); Subject.ProcessDecisions(decisions); Mocker.GetMock().Verify(v => v.Add(It.IsAny()), Times.Exactly(2)); diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/ScanWatchFolderFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/ScanWatchFolderFixture.cs index 199b206e2..40aada01a 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/ScanWatchFolderFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/ScanWatchFolderFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Linq; using FluentAssertions; @@ -16,7 +16,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole [TestFixture] public class ScanWatchFolderFixture : CoreTest { - protected readonly string _title = "Droned.S01E01.Pilot.1080p.WEB-DL-DRONE"; + protected readonly string _title = "Radiohead - Scotch Mist [2008-FLAC-Lossless]"; protected string _completedDownloadFolder = @"c:\blackhole\completed".AsOsAgnostic(); protected void GivenCompletedItem() @@ -28,7 +28,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole Mocker.GetMock() .Setup(c => c.GetFiles(targetDir, SearchOption.AllDirectories)) - .Returns(new[] { Path.Combine(targetDir, "somefile.mkv") }); + .Returns(new[] { Path.Combine(targetDir, "somefile.flac") }); Mocker.GetMock() .Setup(c => c.GetFileSize(It.IsAny())) diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/TorrentBlackholeFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/TorrentBlackholeFixture.cs index 5a61271cf..fafb5f30d 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/TorrentBlackholeFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/TorrentBlackholeFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Linq; using System.Net; @@ -67,26 +67,26 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole Mocker.GetMock() .Setup(c => c.GetFiles(targetDir, SearchOption.AllDirectories)) - .Returns(new[] { Path.Combine(targetDir, "somefile.mkv") }); + .Returns(new[] { Path.Combine(targetDir, "somefile.flac") }); Mocker.GetMock() .Setup(c => c.GetFileSize(It.IsAny())) .Returns(1000000); } - protected override RemoteEpisode CreateRemoteEpisode() + protected override RemoteAlbum CreateRemoteAlbum() { - var remoteEpisode = base.CreateRemoteEpisode(); + var remoteAlbum = base.CreateRemoteAlbum(); var torrentInfo = new TorrentInfo(); - torrentInfo.Title = remoteEpisode.Release.Title; - torrentInfo.DownloadUrl = remoteEpisode.Release.DownloadUrl; - torrentInfo.DownloadProtocol = remoteEpisode.Release.DownloadProtocol; - torrentInfo.MagnetUrl = "magnet:?xt=urn:btih:755248817d32b00cc853e633ecdc48e4c21bff15&dn=Series.S05E10.PROPER.HDTV.x264-DEFiNE%5Brartv%5D&tr=http%3A%2F%2Ftracker.trackerfix.com%3A80%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2710&tr=udp%3A%2F%2F9.rarbg.to%3A2710"; + torrentInfo.Title = remoteAlbum.Release.Title; + torrentInfo.DownloadUrl = remoteAlbum.Release.DownloadUrl; + torrentInfo.DownloadProtocol = remoteAlbum.Release.DownloadProtocol; + torrentInfo.MagnetUrl = "magnet:?xt=urn:btih:755248817d32b00cc853e633ecdc48e4c21bff15&dn=Artist.Album.FLAC.loseless-DEFiNE%5Brartv%5D&tr=http%3A%2F%2Ftracker.trackerfix.com%3A80%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2710&tr=udp%3A%2F%2F9.rarbg.to%3A2710"; - remoteEpisode.Release = torrentInfo; + remoteAlbum.Release = torrentInfo; - return remoteEpisode; + return remoteAlbum; } [Test] @@ -125,9 +125,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole [Test] public void Download_should_download_file_if_it_doesnt_exist() { - var remoteEpisode = CreateRemoteEpisode(); + var remoteAlbum = CreateRemoteAlbum(); - Subject.Download(remoteEpisode); + Subject.Download(remoteAlbum); Mocker.GetMock().Verify(c => c.Get(It.Is(v => v.Url.FullUri == _downloadUrl)), Times.Once()); Mocker.GetMock().Verify(c => c.OpenWriteStream(_filePath), Times.Once()); @@ -139,10 +139,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole { Subject.Definition.Settings.As().SaveMagnetFiles = true; - var remoteEpisode = CreateRemoteEpisode(); - remoteEpisode.Release.DownloadUrl = null; + var remoteAlbum = CreateRemoteAlbum(); + remoteAlbum.Release.DownloadUrl = null; - Subject.Download(remoteEpisode); + Subject.Download(remoteAlbum); Mocker.GetMock().Verify(c => c.Get(It.Is(v => v.Url.FullUri == _downloadUrl)), Times.Never()); Mocker.GetMock().Verify(c => c.OpenWriteStream(_filePath), Times.Never()); @@ -153,10 +153,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole [Test] public void Download_should_not_save_magnet_if_disabled() { - var remoteEpisode = CreateRemoteEpisode(); - remoteEpisode.Release.DownloadUrl = null; + var remoteAlbum = CreateRemoteAlbum(); + remoteAlbum.Release.DownloadUrl = null; - Assert.Throws(() => Subject.Download(remoteEpisode)); + Assert.Throws(() => Subject.Download(remoteAlbum)); Mocker.GetMock().Verify(c => c.Get(It.Is(v => v.Url.FullUri == _downloadUrl)), Times.Never()); Mocker.GetMock().Verify(c => c.OpenWriteStream(_filePath), Times.Never()); @@ -169,9 +169,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole { Subject.Definition.Settings.As().SaveMagnetFiles = true; - var remoteEpisode = CreateRemoteEpisode(); + var remoteAlbum = CreateRemoteAlbum(); - Subject.Download(remoteEpisode); + Subject.Download(remoteAlbum); Mocker.GetMock().Verify(c => c.Get(It.Is(v => v.Url.FullUri == _downloadUrl)), Times.Once()); Mocker.GetMock().Verify(c => c.OpenWriteStream(_filePath), Times.Once()); @@ -182,13 +182,13 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole [Test] public void Download_should_replace_illegal_characters_in_title() { - var illegalTitle = "Saturday Night Live - S38E08 - Jeremy Renner/Maroon 5 [SDTV]"; - var expectedFilename = Path.Combine(_blackholeFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV]" + Path.GetExtension(_filePath)); + var illegalTitle = "Radiohead - Scotch Mist [2008/FLAC/Lossless]"; + var expectedFilename = Path.Combine(_blackholeFolder, "Radiohead - Scotch Mist [2008+FLAC+Lossless]" + Path.GetExtension(_filePath)); - var remoteEpisode = CreateRemoteEpisode(); - remoteEpisode.Release.Title = illegalTitle; + var remoteAlbum = CreateRemoteAlbum(); + remoteAlbum.Release.Title = illegalTitle; - Subject.Download(remoteEpisode); + Subject.Download(remoteAlbum); Mocker.GetMock().Verify(c => c.Get(It.Is(v => v.Url.FullUri == _downloadUrl)), Times.Once()); Mocker.GetMock().Verify(c => c.OpenWriteStream(expectedFilename), Times.Once()); @@ -198,10 +198,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole [Test] public void Download_should_throw_if_magnet_and_torrent_url_does_not_exist() { - var remoteEpisode = CreateRemoteEpisode(); - remoteEpisode.Release.DownloadUrl = null; + var remoteAlbum = CreateRemoteAlbum(); + remoteAlbum.Release.DownloadUrl = null; - Assert.Throws(() => Subject.Download(remoteEpisode)); + Assert.Throws(() => Subject.Download(remoteAlbum)); } [Test] @@ -273,9 +273,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole [Test] public void should_return_null_hash() { - var remoteEpisode = CreateRemoteEpisode(); + var remoteAlbum = CreateRemoteAlbum(); - Subject.Download(remoteEpisode).Should().BeNull(); + Subject.Download(remoteAlbum).Should().BeNull(); } } } diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/UsenetBlackholeFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/UsenetBlackholeFixture.cs index d48d9e0b8..3927a60a1 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/UsenetBlackholeFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/UsenetBlackholeFixture.cs @@ -1,4 +1,4 @@ - + using System; using System.IO; using System.Linq; @@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole Mocker.GetMock() .Setup(c => c.GetFiles(targetDir, SearchOption.AllDirectories)) - .Returns(new[] { Path.Combine(targetDir, "somefile.mkv") }); + .Returns(new[] { Path.Combine(targetDir, "somefile.flac") }); Mocker.GetMock() .Setup(c => c.GetFileSize(It.IsAny())) @@ -104,7 +104,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole [Test] public void Download_should_download_file_if_it_doesnt_exist() { - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); Subject.Download(remoteEpisode); @@ -116,10 +116,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole [Test] public void Download_should_replace_illegal_characters_in_title() { - var illegalTitle = "Saturday Night Live - S38E08 - Jeremy Renner/Maroon 5 [SDTV]"; - var expectedFilename = Path.Combine(_blackholeFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV]" + Path.GetExtension(_filePath)); + var illegalTitle = "Radiohead - Scotch Mist [2008/FLAC/Lossless]"; + var expectedFilename = Path.Combine(_blackholeFolder, "Radiohead - Scotch Mist [2008+FLAC+Lossless]" + Path.GetExtension(_filePath)); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); remoteEpisode.Release.Title = illegalTitle; Subject.Download(remoteEpisode); diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DelugeTests/DelugeFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DelugeTests/DelugeFixture.cs index af24f2797..6d7cfb0c0 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DelugeTests/DelugeFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DelugeTests/DelugeFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Collections.Generic; using FluentAssertions; @@ -196,7 +196,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests { GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -208,7 +208,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests { GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); remoteEpisode.Release.DownloadUrl = magnetUrl; var id = Subject.Download(remoteEpisode); diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs index 762137861..f22b7f77e 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs @@ -9,6 +9,7 @@ using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser; using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; using NzbDrone.Core.Download; using NzbDrone.Core.Configuration; using NzbDrone.Core.RemotePathMappings; @@ -30,8 +31,8 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests .Returns(30); Mocker.GetMock() - .Setup(s => s.Map(It.IsAny(), It.IsAny(), It.IsAny(), (SearchCriteriaBase)null)) - .Returns(() => CreateRemoteEpisode()); + .Setup(s => s.Map(It.IsAny(), (SearchCriteriaBase)null)) + .Returns(() => CreateRemoteAlbum()); Mocker.GetMock() .Setup(s => s.Get(It.IsAny())) @@ -42,22 +43,21 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests .Returns((h, r) => r); } - protected virtual RemoteEpisode CreateRemoteEpisode() + protected virtual RemoteAlbum CreateRemoteAlbum() { - var remoteEpisode = new RemoteEpisode(); - remoteEpisode.Release = new ReleaseInfo(); - remoteEpisode.Release.Title = _title; - remoteEpisode.Release.DownloadUrl = _downloadUrl; - remoteEpisode.Release.DownloadProtocol = Subject.Protocol; + var remoteAlbum = new RemoteAlbum(); + remoteAlbum.Release = new ReleaseInfo(); + remoteAlbum.Release.Title = _title; + remoteAlbum.Release.DownloadUrl = _downloadUrl; + remoteAlbum.Release.DownloadProtocol = Subject.Protocol; - remoteEpisode.ParsedEpisodeInfo = new ParsedEpisodeInfo(); - remoteEpisode.ParsedEpisodeInfo.FullSeason = false; + remoteAlbum.ParsedAlbumInfo = new ParsedAlbumInfo(); - remoteEpisode.Episodes = new List(); + remoteAlbum.Albums = new List(); - remoteEpisode.Series = new Series(); + remoteAlbum.Artist = new Artist(); - return remoteEpisode; + return remoteAlbum; } protected void VerifyIdentifiable(DownloadClientItem downloadClientItem) diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/TorrentDownloadStationFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/TorrentDownloadStationFixture.cs index b5690bd78..b3a6f121b 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/TorrentDownloadStationFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/TorrentDownloadStationFixture.cs @@ -33,7 +33,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests protected string _serialNumber = "SERIALNUMBER"; protected string _category ="lidarr"; - protected string _tvDirectory = @"video/Series"; + protected string _musicDirectory = @"music/Artist"; protected string _defaultDestination = "somepath"; protected OsPath _physicalPath = new OsPath("/mnt/sdb1/mydata"); @@ -301,7 +301,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests protected void GivenTvDirectory() { - _settings.TvDirectory = _tvDirectory; + _settings.TvDirectory = _musicDirectory; } protected virtual void GivenTasks(List torrents) @@ -339,13 +339,13 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests .Callback(PrepareClientToReturnQueuedItem); } - protected override RemoteEpisode CreateRemoteEpisode() + protected override RemoteAlbum CreateRemoteAlbum() { - var episode = base.CreateRemoteEpisode(); + var album = base.CreateRemoteAlbum(); - episode.Release.DownloadUrl = DownloadURL; + album.Release.DownloadUrl = DownloadURL; - return episode; + return album; } protected int GivenAllKindOfTasks() @@ -366,14 +366,14 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests GivenTvDirectory(); GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); id.Should().NotBeNullOrEmpty(); Mocker.GetMock() - .Verify(v => v.AddTaskFromUrl(It.IsAny(), _tvDirectory, It.IsAny()), Times.Once()); + .Verify(v => v.AddTaskFromUrl(It.IsAny(), _musicDirectory, It.IsAny()), Times.Once()); } [Test] @@ -383,7 +383,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests GivenTvCategory(); GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -399,7 +399,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests GivenSerialNumber(); GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -474,7 +474,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests [Test] public void Download_should_throw_and_not_add_task_if_cannot_get_serial_number() { - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); Mocker.GetMock() .Setup(s => s.GetSerialNumber(_settings)) diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/UsenetDownloadStationFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/UsenetDownloadStationFixture.cs index b3a621b8c..d0f73378e 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/UsenetDownloadStationFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/UsenetDownloadStationFixture.cs @@ -29,18 +29,18 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests protected string _serialNumber = "SERIALNUMBER"; protected string _category = "lidarr"; - protected string _tvDirectory = @"video/Series"; + protected string _musicDirectory = @"music/Artist"; protected string _defaultDestination = "somepath"; protected OsPath _physicalPath = new OsPath("/mnt/sdb1/mydata"); - protected RemoteEpisode _remoteEpisode; + protected RemoteAlbum _remoteAlbum; protected Dictionary _downloadStationConfigItems; [SetUp] public void Setup() { - _remoteEpisode = CreateRemoteEpisode(); + _remoteAlbum = CreateRemoteAlbum(); _settings = new DownloadStationSettings() { @@ -66,7 +66,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests Detail = new Dictionary { { "destination","shared/folder" }, - { "uri", FileNameBuilder.CleanFileName(_remoteEpisode.Release.Title) + ".nzb" } + { "uri", FileNameBuilder.CleanFileName(_remoteAlbum.Release.Title) + ".nzb" } }, Transfer = new Dictionary { @@ -89,7 +89,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests Detail = new Dictionary { { "destination","shared/folder" }, - { "uri", FileNameBuilder.CleanFileName(_remoteEpisode.Release.Title) + ".nzb" } + { "uri", FileNameBuilder.CleanFileName(_remoteAlbum.Release.Title) + ".nzb" } }, Transfer = new Dictionary { @@ -112,7 +112,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests Detail = new Dictionary { { "destination","shared/folder" }, - { "uri", FileNameBuilder.CleanFileName(_remoteEpisode.Release.Title) + ".nzb" } + { "uri", FileNameBuilder.CleanFileName(_remoteAlbum.Release.Title) + ".nzb" } }, Transfer = new Dictionary { @@ -135,7 +135,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests Detail = new Dictionary { { "destination","shared/folder" }, - { "uri", FileNameBuilder.CleanFileName(_remoteEpisode.Release.Title) + ".nzb" } + { "uri", FileNameBuilder.CleanFileName(_remoteAlbum.Release.Title) + ".nzb" } }, Transfer = new Dictionary { @@ -158,7 +158,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests Detail = new Dictionary { { "destination","shared/folder" }, - { "uri", FileNameBuilder.CleanFileName(_remoteEpisode.Release.Title) + ".nzb" } + { "uri", FileNameBuilder.CleanFileName(_remoteAlbum.Release.Title) + ".nzb" } }, Transfer = new Dictionary { @@ -203,7 +203,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests protected void GivenTvDirectory() { - _settings.TvDirectory = _tvDirectory; + _settings.TvDirectory = _musicDirectory; } protected virtual void GivenTasks(List nzbs) @@ -254,14 +254,14 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests GivenTvDirectory(); GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); id.Should().NotBeNullOrEmpty(); Mocker.GetMock() - .Verify(v => v.AddTaskFromData(It.IsAny(), It.IsAny(), _tvDirectory, It.IsAny()), Times.Once()); + .Verify(v => v.AddTaskFromData(It.IsAny(), It.IsAny(), _musicDirectory, It.IsAny()), Times.Once()); } [Test] @@ -271,7 +271,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests GivenTvCategory(); GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -287,7 +287,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests GivenSerialNumber(); GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -362,7 +362,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests [Test] public void Download_should_throw_and_not_add_task_if_cannot_get_serial_number() { - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); Mocker.GetMock() .Setup(s => s.GetSerialNumber(_settings)) diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/HadoukenTests/HadoukenFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/HadoukenTests/HadoukenFixture.cs index 871567355..42a6e25fd 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/HadoukenTests/HadoukenFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/HadoukenTests/HadoukenFixture.cs @@ -197,7 +197,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.HadoukenTests { GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -276,7 +276,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.HadoukenTests [Test] public void Download_from_magnet_link_should_return_hash_uppercase() { - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); remoteEpisode.Release.DownloadUrl = "magnet:?xt=urn:btih:a45129e59d8750f9da982f53552b1e4f0457ee9f"; @@ -291,7 +291,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.HadoukenTests [Test] public void Download_from_torrent_file_should_return_hash_uppercase() { - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); Mocker.GetMock() .Setup(v => v.AddTorrentFile(It.IsAny(), It.IsAny())) diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbVortexTests/NzbVortexFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbVortexTests/NzbVortexFixture.cs index ccdaba3f1..501dfb2e6 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbVortexTests/NzbVortexFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbVortexTests/NzbVortexFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Collections.Generic; using FluentAssertions; @@ -32,7 +32,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbVortexTests Host = "127.0.0.1", Port = 2222, ApiKey = "1234-ABCD", - TvCategory = "tv", + TvCategory = "Music", RecentTvPriority = (int)NzbgetPriority.High }; @@ -41,16 +41,16 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbVortexTests Id = RandomNumber, DownloadedSize = 1000, TotalDownloadSize = 10, - GroupName = "tv", - UiTitle = "Droned.S01E01.Pilot.1080p.WEB-DL-DRONE" - }; + GroupName = "Music", + UiTitle = "Fall Out Boy-Make America Psycho Again-CD-FLAC-2015-FORSAKEN" + }; _failed = new NzbVortexQueueItem { DownloadedSize = 1000, TotalDownloadSize = 1000, - GroupName = "tv", - UiTitle = "Droned.S01E01.Pilot.1080p.WEB-DL-DRONE", + GroupName = "Music", + UiTitle = "Fall Out Boy-Make America Psycho Again-CD-FLAC-2015-FORSAKEN", DestinationPath = "somedirectory", State = NzbVortexStateType.UncompressFailed, }; @@ -59,9 +59,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbVortexTests { DownloadedSize = 1000, TotalDownloadSize = 1000, - GroupName = "tv", - UiTitle = "Droned.S01E01.Pilot.1080p.WEB-DL-DRONE", - DestinationPath = "/remote/mount/tv/Droned.S01E01.Pilot.1080p.WEB-DL-DRONE", + GroupName = "Music", + UiTitle = "Fall Out Boy-Make America Psycho Again-CD-FLAC-2015-FORSAKEN", + DestinationPath = "/remote/mount/music/Fall Out Boy-Make America Psycho Again-CD-FLAC-2015-FORSAKEN", State = NzbVortexStateType.Done }; } @@ -189,7 +189,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbVortexTests { GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -201,7 +201,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbVortexTests { GivenFailedDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); Assert.Throws(() => Subject.Download(remoteEpisode)); } @@ -223,13 +223,13 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbVortexTests { Mocker.GetMock() .Setup(v => v.RemapRemoteToLocal("127.0.0.1", It.IsAny())) - .Returns(new OsPath(@"O:\mymount\Droned.S01E01.Pilot.1080p.WEB-DL-DRONE".AsOsAgnostic())); + .Returns(new OsPath(@"O:\mymount\Fall Out Boy-Make America Psycho Again-CD-FLAC-2015-FORSAKEN".AsOsAgnostic())); GivenQueue(_completed); var result = Subject.GetItems().Single(); - result.OutputPath.Should().Be(@"O:\mymount\Droned.S01E01.Pilot.1080p.WEB-DL-DRONE".AsOsAgnostic()); + result.OutputPath.Should().Be(@"O:\mymount\Fall Out Boy-Make America Psycho Again-CD-FLAC-2015-FORSAKEN".AsOsAgnostic()); } [Test] @@ -241,14 +241,14 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbVortexTests Mocker.GetMock() .Setup(s => s.GetFiles(It.IsAny(), It.IsAny())) - .Returns(new List { new NzbVortexFile { FileName = "Droned.S01E01.Pilot.1080p.WEB-DL-DRONE.mkv" } }); + .Returns(new List { new NzbVortexFile { FileName = "Fall Out Boy - Make America Psyco Again - Track 1.flac" } }); _completed.State = NzbVortexStateType.Done; GivenQueue(_completed); var result = Subject.GetItems().Single(); - result.OutputPath.Should().Be(@"O:\mymount\Droned.S01E01.Pilot.1080p.WEB-DL-DRONE.mkv".AsOsAgnostic()); + result.OutputPath.Should().Be(@"O:\mymount\Fall Out Boy - Make America Psyco Again - Track 1.flac".AsOsAgnostic()); } [Test] @@ -262,8 +262,8 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbVortexTests .Setup(s => s.GetFiles(It.IsAny(), It.IsAny())) .Returns(new List { - new NzbVortexFile { FileName = "Droned.S01E01.Pilot.1080p.WEB-DL-DRONE.mkv" }, - new NzbVortexFile { FileName = "Droned.S01E01.Pilot.1080p.WEB-DL-DRONE.nfo" } + new NzbVortexFile { FileName = "Fall Out Boy - Make America Psyco Again - Track 1.flac" }, + new NzbVortexFile { FileName = "Fall Out Boy-Make America Psycho Again-CD-FLAC-2015-FORSAKEN.nfo" } }); _completed.State = NzbVortexStateType.Done; diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetTests/NzbgetFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetTests/NzbgetFixture.cs index 226288464..5ad07cc34 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetTests/NzbgetFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetTests/NzbgetFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Collections.Generic; using FluentAssertions; @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests Port = 2222, Username = "admin", Password = "pass", - TvCategory = "tv", + TvCategory = "music", RecentTvPriority = (int)NzbgetPriority.High }; @@ -38,16 +38,16 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests { FileSizeLo = 1000, RemainingSizeLo = 10, - Category = "tv", - NzbName = "Droned.S01E01.Pilot.1080p.WEB-DL-DRONE", + Category = "music", + NzbName = "Fall Out Boy-Make America Psycho Again-CD-FLAC-2015-FORSAKEN", Parameters = new List { new NzbgetParameter { Name = "drone", Value = "id" } } }; _failed = new NzbgetHistoryItem { FileSizeLo = 1000, - Category = "tv", - Name = "Droned.S01E01.Pilot.1080p.WEB-DL-DRONE", + Category = "music", + Name = "Fall Out Boy-Make America Psycho Again-CD-FLAC-2015-FORSAKEN", DestDir = "somedirectory", Parameters = new List { new NzbgetParameter { Name = "drone", Value = "id" } }, ParStatus = "Some Error", @@ -61,9 +61,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests _completed = new NzbgetHistoryItem { FileSizeLo = 1000, - Category = "tv", - Name = "Droned.S01E01.Pilot.1080p.WEB-DL-DRONE", - DestDir = "/remote/mount/tv/Droned.S01E01.Pilot.1080p.WEB-DL-DRONE", + Category = "music", + Name = "Fall Out Boy-Make America Psycho Again-CD-FLAC-2015-FORSAKEN", + DestDir = "/remote/mount/music/Fall Out Boy-Make America Psycho Again-CD-FLAC-2015-FORSAKEN", Parameters = new List { new NzbgetParameter { Name = "drone", Value = "id" } }, ParStatus = "SUCCESS", UnpackStatus = "NONE", @@ -81,8 +81,8 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests }); var configItems = new Dictionary(); - configItems.Add("Category1.Name", "tv"); - configItems.Add("Category1.DestDir", @"/remote/mount/tv"); + configItems.Add("Category1.Name", "music"); + configItems.Add("Category1.DestDir", @"/remote/mount/music"); Mocker.GetMock() .Setup(v => v.GetConfig(It.IsAny())) @@ -303,7 +303,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests { GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -315,7 +315,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests { GivenFailedDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); Assert.Throws(() => Subject.Download(remoteEpisode)); } @@ -340,7 +340,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests result.IsLocalhost.Should().BeTrue(); result.OutputRootFolders.Should().NotBeNull(); - result.OutputRootFolders.First().Should().Be(@"/remote/mount/tv"); + result.OutputRootFolders.First().Should().Be(@"/remote/mount/music"); } [Test] @@ -362,14 +362,14 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests { Mocker.GetMock() .Setup(v => v.RemapRemoteToLocal("127.0.0.1", It.IsAny())) - .Returns(new OsPath(@"O:\mymount\Droned.S01E01.Pilot.1080p.WEB-DL-DRONE".AsOsAgnostic())); + .Returns(new OsPath(@"O:\mymount\Fall Out Boy-Make America Psycho Again-CD-FLAC-2015-FORSAKEN".AsOsAgnostic())); GivenQueue(null); GivenHistory(_completed); var result = Subject.GetItems().Single(); - result.OutputPath.Should().Be(@"O:\mymount\Droned.S01E01.Pilot.1080p.WEB-DL-DRONE".AsOsAgnostic()); + result.OutputPath.Should().Be(@"O:\mymount\Fall Out Boy-Make America Psycho Again-CD-FLAC-2015-FORSAKEN".AsOsAgnostic()); } [TestCase("11.0", false)] diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs index d3de3c1d9..d9b9c2b52 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Net; using Moq; @@ -21,7 +21,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests private string _pneumaticFolder; private string _sabDrop; private string _nzbPath; - private RemoteEpisode _remoteEpisode; + private RemoteAlbum _remoteEpisode; [SetUp] public void Setup() @@ -33,13 +33,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests Mocker.GetMock().SetupGet(c => c.DownloadedEpisodesFolder).Returns(_sabDrop); - _remoteEpisode = new RemoteEpisode(); + _remoteEpisode = new RemoteAlbum(); _remoteEpisode.Release = new ReleaseInfo(); _remoteEpisode.Release.Title = _title; _remoteEpisode.Release.DownloadUrl = _nzbUrl; - _remoteEpisode.ParsedEpisodeInfo = new ParsedEpisodeInfo(); - _remoteEpisode.ParsedEpisodeInfo.FullSeason = false; + _remoteEpisode.ParsedAlbumInfo = new ParsedAlbumInfo(); Subject.Definition = new DownloadClientDefinition(); Subject.Definition.Settings = new PneumaticSettings @@ -74,7 +73,6 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests public void should_throw_if_full_season_download() { _remoteEpisode.Release.Title = "30 Rock - Season 1"; - _remoteEpisode.ParsedEpisodeInfo.FullSeason = true; Assert.Throws(() => Subject.Download(_remoteEpisode)); } diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs index bce7c1748..cf1105c3d 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs @@ -245,7 +245,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests { GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -257,7 +257,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests { GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); remoteEpisode.Release.DownloadUrl = magnetUrl; var id = Subject.Download(remoteEpisode); @@ -290,7 +290,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests GivenRedirectToMagnet(); GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -303,7 +303,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests GivenRedirectToTorrent(); GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/RTorrentTests/RTorrentFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/RTorrentTests/RTorrentFixture.cs index 1f5a2713e..261925758 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/RTorrentTests/RTorrentFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/RTorrentTests/RTorrentFixture.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using System.Collections.Generic; using FluentAssertions; using Moq; @@ -116,7 +116,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.RTorrentTests { GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs index e58e4b9a8..1ce5215aa 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Collections.Generic; using FizzWare.NBuilder; @@ -8,7 +8,7 @@ using NUnit.Framework; using NzbDrone.Core.Download; using NzbDrone.Core.Download.Clients.Sabnzbd; using NzbDrone.Core.Download.Clients.Sabnzbd.Responses; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; using NzbDrone.Test.Common; using NzbDrone.Core.RemotePathMappings; using NzbDrone.Common.Disk; @@ -281,7 +281,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests { GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); remoteEpisode.Release.Title = title; var id = Subject.Download(remoteEpisode); @@ -295,7 +295,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests { GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -336,10 +336,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests .Setup(s => s.DownloadNzb(It.IsAny(), It.IsAny(), It.IsAny(), (int)SabnzbdPriority.High, It.IsAny())) .Returns(new SabnzbdAddResponse()); - var remoteEpisode = CreateRemoteEpisode(); - remoteEpisode.Episodes = Builder.CreateListOfSize(1) + var remoteEpisode = CreateRemoteAlbum(); + remoteEpisode.Albums = Builder.CreateListOfSize(1) .All() - .With(e => e.AirDate = DateTime.Today.ToString(Episode.AIR_DATE_FORMAT)) + .With(e => e.ReleaseDate = DateTime.Today) .Build() .ToList(); diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/TransmissionTests/TransmissionFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/TransmissionTests/TransmissionFixture.cs index 57e6007d6..0ab9f227d 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/TransmissionTests/TransmissionFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/TransmissionTests/TransmissionFixture.cs @@ -55,7 +55,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests { GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -68,7 +68,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests GivenTvDirectory(); GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -84,7 +84,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests GivenTvCategory(); GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -102,7 +102,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests _transmissionConfigItems["download-dir"] += "/"; - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -117,7 +117,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests { GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -132,7 +132,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests { GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); remoteEpisode.Release.DownloadUrl = magnetUrl; var id = Subject.Download(remoteEpisode); diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/UTorrentTests/UTorrentFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/UTorrentTests/UTorrentFixture.cs index 104ab6e09..c77741cce 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/UTorrentTests/UTorrentFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/UTorrentTests/UTorrentFixture.cs @@ -30,8 +30,8 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests Port = 2222, Username = "admin", Password = "pass", - TvCategory = "tv" - }; + TvCategory = "lidarr" + }; _queued = new UTorrentTorrent { @@ -41,7 +41,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests Size = 1000, Remaining = 1000, Progress = 0, - Label = "tv", + Label = "lidarr", DownloadUrl = _downloadUrl, RootDownloadPath = "somepath" }; @@ -54,7 +54,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests Size = 1000, Remaining = 100, Progress = 0.9, - Label = "tv", + Label = "lidarr", DownloadUrl = _downloadUrl, RootDownloadPath = "somepath" }; @@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests Size = 1000, Remaining = 100, Progress = 0.9, - Label = "tv", + Label = "lidarr", DownloadUrl = _downloadUrl, RootDownloadPath = "somepath" }; @@ -80,7 +80,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests Size = 1000, Remaining = 0, Progress = 1.0, - Label = "tv", + Label = "lidarr", DownloadUrl = _downloadUrl, RootDownloadPath = "somepath" }; @@ -229,7 +229,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests { GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -253,7 +253,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests { GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); remoteEpisode.Release.DownloadUrl = magnetUrl; var id = Subject.Download(remoteEpisode); @@ -328,7 +328,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests result.IsLocalhost.Should().BeTrue(); result.OutputRootFolders.Should().NotBeNull(); - result.OutputRootFolders.First().Should().Be(@"C:\Downloads\Finished\utorrent\tv".AsOsAgnostic()); + result.OutputRootFolders.First().Should().Be(@"C:\Downloads\Finished\utorrent\lidarr".AsOsAgnostic()); } [Test] @@ -351,7 +351,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests GivenRedirectToMagnet(); GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -364,7 +364,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests GivenRedirectToTorrent(); GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/VuzeTests/VuzeFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/VuzeTests/VuzeFixture.cs index 17fdf1291..160ad1384 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/VuzeTests/VuzeFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/VuzeTests/VuzeFixture.cs @@ -57,7 +57,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests { GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -70,7 +70,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests GivenTvDirectory(); GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -86,7 +86,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests GivenTvCategory(); GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -104,7 +104,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests _transmissionConfigItems["download-dir"] += "/"; - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -119,7 +119,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests { GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); var id = Subject.Download(remoteEpisode); @@ -134,7 +134,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests { GivenSuccessfulDownload(); - var remoteEpisode = CreateRemoteEpisode(); + var remoteEpisode = CreateRemoteAlbum(); remoteEpisode.Release.DownloadUrl = magnetUrl; var id = Subject.Download(remoteEpisode); diff --git a/src/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs index b82216b19..dca02000f 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Net; @@ -12,7 +12,7 @@ using NzbDrone.Core.Exceptions; using NzbDrone.Core.Indexers; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.Download @@ -20,7 +20,7 @@ namespace NzbDrone.Core.Test.Download [TestFixture] public class DownloadServiceFixture : CoreTest { - private RemoteEpisode _parseResult; + private RemoteAlbum _parseResult; private List _downloadClients; [SetUp] public void Setup() @@ -35,10 +35,10 @@ namespace NzbDrone.Core.Test.Download .Setup(v => v.GetDownloadClient(It.IsAny())) .Returns(v => _downloadClients.FirstOrDefault(d => d.Protocol == v)); - var episodes = Builder.CreateListOfSize(2) + var episodes = Builder.CreateListOfSize(2) .TheFirst(1).With(s => s.Id = 12) .TheNext(1).With(s => s.Id = 99) - .All().With(s => s.SeriesId = 5) + .All().With(s => s.ArtistId = 5) .Build().ToList(); var releaseInfo = Builder.CreateNew() @@ -46,10 +46,10 @@ namespace NzbDrone.Core.Test.Download .With(v => v.DownloadUrl = "http://test.site/download1.ext") .Build(); - _parseResult = Builder.CreateNew() - .With(c => c.Series = Builder.CreateNew().Build()) + _parseResult = Builder.CreateNew() + .With(c => c.Artist = Builder.CreateNew().Build()) .With(c => c.Release = releaseInfo) - .With(c => c.Episodes = episodes) + .With(c => c.Albums = episodes) .Build(); } @@ -81,42 +81,42 @@ namespace NzbDrone.Core.Test.Download public void Download_report_should_publish_on_grab_event() { var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())); + mock.Setup(s => s.Download(It.IsAny())); Subject.DownloadReport(_parseResult); - VerifyEventPublished(); + VerifyEventPublished(); } [Test] public void Download_report_should_grab_using_client() { var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())); + mock.Setup(s => s.Download(It.IsAny())); Subject.DownloadReport(_parseResult); - mock.Verify(s => s.Download(It.IsAny()), Times.Once()); + mock.Verify(s => s.Download(It.IsAny()), Times.Once()); } [Test] public void Download_report_should_not_publish_on_failed_grab_event() { var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())) + mock.Setup(s => s.Download(It.IsAny())) .Throws(new WebException()); Assert.Throws(() => Subject.DownloadReport(_parseResult)); - VerifyEventNotPublished(); + VerifyEventNotPublished(); } [Test] public void Download_report_should_trigger_indexer_backoff_on_indexer_error() { var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())) - .Callback(v => { + mock.Setup(s => s.Download(It.IsAny())) + .Callback(v => { throw new ReleaseDownloadException(v.Release, "Error", new WebException()); }); @@ -134,8 +134,8 @@ namespace NzbDrone.Core.Test.Download response.Headers["Retry-After"] = "300"; var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())) - .Callback(v => { + mock.Setup(s => s.Download(It.IsAny())) + .Callback(v => { throw new ReleaseDownloadException(v.Release, "Error", new TooManyRequestsException(request, response)); }); @@ -153,8 +153,8 @@ namespace NzbDrone.Core.Test.Download response.Headers["Retry-After"] = DateTime.UtcNow.AddSeconds(300).ToString("r"); var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())) - .Callback(v => + mock.Setup(s => s.Download(It.IsAny())) + .Callback(v => { throw new ReleaseDownloadException(v.Release, "Error", new TooManyRequestsException(request, response)); }); @@ -170,7 +170,7 @@ namespace NzbDrone.Core.Test.Download public void Download_report_should_not_trigger_indexer_backoff_on_downloadclient_error() { var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())) + mock.Setup(s => s.Download(It.IsAny())) .Throws(new DownloadClientException("Some Error")); Assert.Throws(() => Subject.DownloadReport(_parseResult)); @@ -184,7 +184,7 @@ namespace NzbDrone.Core.Test.Download { Subject.DownloadReport(_parseResult); - Mocker.GetMock().Verify(c => c.Download(It.IsAny()), Times.Never()); + Mocker.GetMock().Verify(c => c.Download(It.IsAny()), Times.Never()); VerifyEventNotPublished(); ExceptionVerification.ExpectedWarns(1); @@ -198,8 +198,8 @@ namespace NzbDrone.Core.Test.Download Subject.DownloadReport(_parseResult); - mockTorrent.Verify(c => c.Download(It.IsAny()), Times.Never()); - mockUsenet.Verify(c => c.Download(It.IsAny()), Times.Once()); + mockTorrent.Verify(c => c.Download(It.IsAny()), Times.Never()); + mockUsenet.Verify(c => c.Download(It.IsAny()), Times.Once()); } [Test] @@ -212,8 +212,8 @@ namespace NzbDrone.Core.Test.Download Subject.DownloadReport(_parseResult); - mockTorrent.Verify(c => c.Download(It.IsAny()), Times.Once()); - mockUsenet.Verify(c => c.Download(It.IsAny()), Times.Never()); + mockTorrent.Verify(c => c.Download(It.IsAny()), Times.Once()); + mockUsenet.Verify(c => c.Download(It.IsAny()), Times.Never()); } } } diff --git a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/AddFixture.cs b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/AddFixture.cs index 7929ac45f..9e9652ab7 100644 --- a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/AddFixture.cs +++ b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/AddFixture.cs @@ -12,7 +12,7 @@ using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests { @@ -20,20 +20,20 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests public class AddFixture : CoreTest { private DownloadDecision _temporarilyRejected; - private Series _series; - private Episode _episode; + private Artist _artist; + private Album _album; private Profile _profile; private ReleaseInfo _release; - private ParsedEpisodeInfo _parsedEpisodeInfo; - private RemoteEpisode _remoteEpisode; + private ParsedAlbumInfo _parsedAlbumInfo; + private RemoteAlbum _remoteAlbum; [SetUp] public void Setup() { - _series = Builder.CreateNew() + _artist = Builder.CreateNew() .Build(); - _episode = Builder.CreateNew() + _album = Builder.CreateNew() .Build(); _profile = new Profile @@ -48,32 +48,32 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests }, }; - _series.Profile = new LazyLoaded(_profile); + _artist.Profile = new LazyLoaded(_profile); _release = Builder.CreateNew().Build(); - _parsedEpisodeInfo = Builder.CreateNew().Build(); - _parsedEpisodeInfo.Quality = new QualityModel(Quality.MP3_256); + _parsedAlbumInfo = Builder.CreateNew().Build(); + _parsedAlbumInfo.Quality = new QualityModel(Quality.MP3_256); - _remoteEpisode = new RemoteEpisode(); - _remoteEpisode.Episodes = new List{ _episode }; - _remoteEpisode.Series = _series; - _remoteEpisode.ParsedEpisodeInfo = _parsedEpisodeInfo; - _remoteEpisode.Release = _release; + _remoteAlbum = new RemoteAlbum(); + _remoteAlbum.Albums = new List{ _album }; + _remoteAlbum.Artist = _artist; + _remoteAlbum.ParsedAlbumInfo = _parsedAlbumInfo; + _remoteAlbum.Release = _release; - _temporarilyRejected = new DownloadDecision(_remoteEpisode, new Rejection("Temp Rejected", RejectionType.Temporary)); + _temporarilyRejected = new DownloadDecision(_remoteAlbum, new Rejection("Temp Rejected", RejectionType.Temporary)); Mocker.GetMock() .Setup(s => s.All()) .Returns(new List()); - Mocker.GetMock() - .Setup(s => s.GetSeries(It.IsAny())) - .Returns(_series); + Mocker.GetMock() + .Setup(s => s.GetArtist(It.IsAny())) + .Returns(_artist); Mocker.GetMock() - .Setup(s => s.GetEpisodes(It.IsAny(), _series, true, null)) - .Returns(new List {_episode}); + .Setup(s => s.GetAlbums(It.IsAny(), _artist, null)) + .Returns(new List {_album}); Mocker.GetMock() .Setup(s => s.PrioritizeDecisions(It.IsAny>())) @@ -89,7 +89,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests var heldReleases = Builder.CreateListOfSize(1) .All() - .With(h => h.SeriesId = _series.Id) + .With(h => h.ArtistId = _artist.Id) .With(h => h.Title = title) .With(h => h.Release = release) .Build(); diff --git a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveGrabbedFixture.cs b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveGrabbedFixture.cs index e03b36956..4fb99c8f8 100644 --- a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveGrabbedFixture.cs +++ b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveGrabbedFixture.cs @@ -12,7 +12,7 @@ using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests { @@ -20,20 +20,20 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests public class RemoveGrabbedFixture : CoreTest { private DownloadDecision _temporarilyRejected; - private Series _series; - private Episode _episode; + private Artist _artist; + private Album _album; private Profile _profile; private ReleaseInfo _release; - private ParsedEpisodeInfo _parsedEpisodeInfo; - private RemoteEpisode _remoteEpisode; + private ParsedAlbumInfo _parsedAlbumInfo; + private RemoteAlbum _remoteAlbum; [SetUp] public void Setup() { - _series = Builder.CreateNew() + _artist = Builder.CreateNew() .Build(); - _episode = Builder.CreateNew() + _album = Builder.CreateNew() .Build(); _profile = new Profile @@ -48,32 +48,32 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests }, }; - _series.Profile = new LazyLoaded(_profile); + _artist.Profile = new LazyLoaded(_profile); _release = Builder.CreateNew().Build(); - _parsedEpisodeInfo = Builder.CreateNew().Build(); - _parsedEpisodeInfo.Quality = new QualityModel(Quality.MP3_256); + _parsedAlbumInfo = Builder.CreateNew().Build(); + _parsedAlbumInfo.Quality = new QualityModel(Quality.MP3_256); - _remoteEpisode = new RemoteEpisode(); - _remoteEpisode.Episodes = new List{ _episode }; - _remoteEpisode.Series = _series; - _remoteEpisode.ParsedEpisodeInfo = _parsedEpisodeInfo; - _remoteEpisode.Release = _release; + _remoteAlbum = new RemoteAlbum(); + _remoteAlbum.Albums = new List{ _album }; + _remoteAlbum.Artist = _artist; + _remoteAlbum.ParsedAlbumInfo = _parsedAlbumInfo; + _remoteAlbum.Release = _release; - _temporarilyRejected = new DownloadDecision(_remoteEpisode, new Rejection("Temp Rejected", RejectionType.Temporary)); + _temporarilyRejected = new DownloadDecision(_remoteAlbum, new Rejection("Temp Rejected", RejectionType.Temporary)); Mocker.GetMock() .Setup(s => s.All()) .Returns(new List()); - Mocker.GetMock() - .Setup(s => s.GetSeries(It.IsAny())) - .Returns(_series); + Mocker.GetMock() + .Setup(s => s.GetArtist(It.IsAny())) + .Returns(_artist); Mocker.GetMock() - .Setup(s => s.GetEpisodes(It.IsAny(), _series, true, null)) - .Returns(new List {_episode}); + .Setup(s => s.GetAlbums(It.IsAny(), _artist, null)) + .Returns(new List {_album}); Mocker.GetMock() .Setup(s => s.PrioritizeDecisions(It.IsAny>())) @@ -82,14 +82,14 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests private void GivenHeldRelease(QualityModel quality) { - var parsedEpisodeInfo = _parsedEpisodeInfo.JsonClone(); + var parsedEpisodeInfo = _parsedAlbumInfo.JsonClone(); parsedEpisodeInfo.Quality = quality; var heldReleases = Builder.CreateListOfSize(1) .All() - .With(h => h.SeriesId = _series.Id) + .With(h => h.ArtistId = _artist.Id) .With(h => h.Release = _release.JsonClone()) - .With(h => h.ParsedEpisodeInfo = parsedEpisodeInfo) + .With(h => h.ParsedAlbumInfo = parsedEpisodeInfo) .Build(); Mocker.GetMock() @@ -100,9 +100,9 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests [Test] public void should_delete_if_the_grabbed_quality_is_the_same() { - GivenHeldRelease(_parsedEpisodeInfo.Quality); + GivenHeldRelease(_parsedAlbumInfo.Quality); - Subject.Handle(new EpisodeGrabbedEvent(_remoteEpisode)); + Subject.Handle(new AlbumGrabbedEvent(_remoteAlbum)); VerifyDelete(); } @@ -112,7 +112,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests { GivenHeldRelease(new QualityModel(Quality.MP3_192)); - Subject.Handle(new EpisodeGrabbedEvent(_remoteEpisode)); + Subject.Handle(new AlbumGrabbedEvent(_remoteAlbum)); VerifyDelete(); } @@ -122,7 +122,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests { GivenHeldRelease(new QualityModel(Quality.MP3_512)); - Subject.Handle(new EpisodeGrabbedEvent(_remoteEpisode)); + Subject.Handle(new AlbumGrabbedEvent(_remoteAlbum)); VerifyNoDelete(); } diff --git a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemovePendingFixture.cs b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemovePendingFixture.cs index 44c2a1029..adab71ee9 100644 --- a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemovePendingFixture.cs +++ b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemovePendingFixture.cs @@ -8,7 +8,7 @@ using NzbDrone.Core.Download.Pending; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests { @@ -16,48 +16,48 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests public class RemovePendingFixture : CoreTest { private List _pending; - private Episode _episode; + private Album _album; [SetUp] public void Setup() { _pending = new List(); - _episode = Builder.CreateNew() + _album = Builder.CreateNew() .Build(); Mocker.GetMock() - .Setup(s => s.AllBySeriesId(It.IsAny())) + .Setup(s => s.AllByArtistId(It.IsAny())) .Returns(_pending); Mocker.GetMock() .Setup(s => s.All()) .Returns( _pending); - Mocker.GetMock() - .Setup(s => s.GetSeries(It.IsAny())) - .Returns(new Series()); + Mocker.GetMock() + .Setup(s => s.GetArtist(It.IsAny())) + .Returns(new Artist()); Mocker.GetMock() - .Setup(s => s.GetEpisodes(It.IsAny(), It.IsAny(), It.IsAny(), null)) - .Returns(new List{ _episode }); + .Setup(s => s.GetAlbums(It.IsAny(), It.IsAny(), null)) + .Returns(new List{ _album }); } - private void AddPending(int id, int seasonNumber, int[] episodes) + private void AddPending(int id, string album) { _pending.Add(new PendingRelease { Id = id, - ParsedEpisodeInfo = new ParsedEpisodeInfo { SeasonNumber = seasonNumber, EpisodeNumbers = episodes } + ParsedAlbumInfo = new ParsedAlbumInfo { AlbumTitle = album} }); } [Test] public void should_remove_same_release() { - AddPending(id: 1, seasonNumber: 2, episodes: new[] { 3 }); + AddPending(id: 1, album: "Album" ); - var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _episode.Id)); + var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-album{1}", 1, _album.Id)); Subject.RemovePendingQueueItems(queueId); @@ -67,12 +67,12 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests [Test] public void should_remove_multiple_releases_release() { - AddPending(id: 1, seasonNumber: 2, episodes: new[] { 1 }); - AddPending(id: 2, seasonNumber: 2, episodes: new[] { 2 }); - AddPending(id: 3, seasonNumber: 2, episodes: new[] { 3 }); - AddPending(id: 4, seasonNumber: 2, episodes: new[] { 3 }); + AddPending(id: 1, album: "Album 1"); + AddPending(id: 2, album: "Album 2"); + AddPending(id: 3, album: "Album 3"); + AddPending(id: 4, album: "Album 3"); - var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 3, _episode.Id)); + var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-album{1}", 3, _album.Id)); Subject.RemovePendingQueueItems(queueId); @@ -80,60 +80,19 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests } [Test] - public void should_not_remove_diffrent_season() + public void should_not_remove_diffrent_albums() { - AddPending(id: 1, seasonNumber: 2, episodes: new[] { 1 }); - AddPending(id: 2, seasonNumber: 2, episodes: new[] { 1 }); - AddPending(id: 3, seasonNumber: 3, episodes: new[] { 1 }); - AddPending(id: 4, seasonNumber: 3, episodes: new[] { 1 }); + AddPending(id: 1, album: "Album 1"); + AddPending(id: 2, album: "Album 1"); + AddPending(id: 3, album: "Album 2"); + AddPending(id: 4, album: "Album 3"); - var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _episode.Id)); + var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-album{1}", 1, _album.Id)); Subject.RemovePendingQueueItems(queueId); AssertRemoved(1, 2); } - - [Test] - public void should_not_remove_diffrent_episodes() - { - AddPending(id: 1, seasonNumber: 2, episodes: new[] { 1 }); - AddPending(id: 2, seasonNumber: 2, episodes: new[] { 1 }); - AddPending(id: 3, seasonNumber: 2, episodes: new[] { 2 }); - AddPending(id: 4, seasonNumber: 2, episodes: new[] { 3 }); - - var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _episode.Id)); - - Subject.RemovePendingQueueItems(queueId); - - AssertRemoved(1, 2); - } - - [Test] - public void should_not_remove_multiepisodes() - { - AddPending(id: 1, seasonNumber: 2, episodes: new[] { 1 }); - AddPending(id: 2, seasonNumber: 2, episodes: new[] { 1, 2 }); - - var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _episode.Id)); - - Subject.RemovePendingQueueItems(queueId); - - AssertRemoved(1); - } - - [Test] - public void should_not_remove_singleepisodes() - { - AddPending(id: 1, seasonNumber: 2, episodes: new[] { 1 }); - AddPending(id: 2, seasonNumber: 2, episodes: new[] { 1, 2 }); - - var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 2, _episode.Id)); - - Subject.RemovePendingQueueItems(queueId); - - AssertRemoved(2); - } private void AssertRemoved(params int[] ids) { diff --git a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveRejectedFixture.cs b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveRejectedFixture.cs index 3b4f68efd..46a16830a 100644 --- a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveRejectedFixture.cs +++ b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveRejectedFixture.cs @@ -14,7 +14,7 @@ using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests { @@ -22,20 +22,20 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests public class RemoveRejectedFixture : CoreTest { private DownloadDecision _temporarilyRejected; - private Series _series; - private Episode _episode; + private Artist _artist; + private Album _album; private Profile _profile; private ReleaseInfo _release; - private ParsedEpisodeInfo _parsedEpisodeInfo; - private RemoteEpisode _remoteEpisode; + private ParsedAlbumInfo _parsedAlbumInfo; + private RemoteAlbum _remoteAlbum; [SetUp] public void Setup() { - _series = Builder.CreateNew() + _artist = Builder.CreateNew() .Build(); - _episode = Builder.CreateNew() + _album = Builder.CreateNew() .Build(); _profile = new Profile @@ -50,32 +50,32 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests }, }; - _series.Profile = new LazyLoaded(_profile); + _artist.Profile = new LazyLoaded(_profile); _release = Builder.CreateNew().Build(); - _parsedEpisodeInfo = Builder.CreateNew().Build(); - _parsedEpisodeInfo.Quality = new QualityModel(Quality.MP3_192); + _parsedAlbumInfo = Builder.CreateNew().Build(); + _parsedAlbumInfo.Quality = new QualityModel(Quality.MP3_192); - _remoteEpisode = new RemoteEpisode(); - _remoteEpisode.Episodes = new List{ _episode }; - _remoteEpisode.Series = _series; - _remoteEpisode.ParsedEpisodeInfo = _parsedEpisodeInfo; - _remoteEpisode.Release = _release; + _remoteAlbum = new RemoteAlbum(); + _remoteAlbum.Albums = new List{ _album }; + _remoteAlbum.Artist = _artist; + _remoteAlbum.ParsedAlbumInfo = _parsedAlbumInfo; + _remoteAlbum.Release = _release; - _temporarilyRejected = new DownloadDecision(_remoteEpisode, new Rejection("Temp Rejected", RejectionType.Temporary)); + _temporarilyRejected = new DownloadDecision(_remoteAlbum, new Rejection("Temp Rejected", RejectionType.Temporary)); Mocker.GetMock() .Setup(s => s.All()) .Returns(new List()); - Mocker.GetMock() - .Setup(s => s.GetSeries(It.IsAny())) - .Returns(_series); + Mocker.GetMock() + .Setup(s => s.GetArtist(It.IsAny())) + .Returns(_artist); Mocker.GetMock() - .Setup(s => s.GetEpisodes(It.IsAny(), _series, true, null)) - .Returns(new List {_episode}); + .Setup(s => s.GetAlbums(It.IsAny(), _artist, null)) + .Returns(new List {_album}); Mocker.GetMock() .Setup(s => s.PrioritizeDecisions(It.IsAny>())) @@ -91,7 +91,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests var heldReleases = Builder.CreateListOfSize(1) .All() - .With(h => h.SeriesId = _series.Id) + .With(h => h.ArtistId = _artist.Id) .With(h => h.Title = title) .With(h => h.Release = release) .Build(); diff --git a/src/NzbDrone.Core.Test/Download/TrackedDownloads/TrackedDownloadServiceFixture.cs b/src/NzbDrone.Core.Test/Download/TrackedDownloads/TrackedDownloadServiceFixture.cs index 912b60335..834b6d26a 100644 --- a/src/NzbDrone.Core.Test/Download/TrackedDownloads/TrackedDownloadServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Download/TrackedDownloads/TrackedDownloadServiceFixture.cs @@ -8,7 +8,7 @@ using NzbDrone.Core.History; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; using NzbDrone.Core.Indexers; using System.Linq; @@ -24,9 +24,9 @@ namespace NzbDrone.Core.Test.Download.TrackedDownloads .Returns(new List(){ new History.History(){ DownloadId = "35238", - SourceTitle = "TV Series S01", - SeriesId = 5, - EpisodeId = 4 + SourceTitle = "Audio Artist - Audio Album", + ArtistId = 5, + AlbumId = 4, } }); } @@ -36,20 +36,20 @@ namespace NzbDrone.Core.Test.Download.TrackedDownloads { GivenDownloadHistory(); - var remoteEpisode = new RemoteEpisode + var remoteAlbum = new RemoteAlbum { - Series = new Series() { Id = 5 }, - Episodes = new List { new Episode { Id = 4 } }, - ParsedEpisodeInfo = new ParsedEpisodeInfo() + Artist = new Artist() { Id = 5 }, + Albums = new List { new Album { Id = 4 } }, + ParsedAlbumInfo = new ParsedAlbumInfo() { - SeriesTitle = "TV Series", - SeasonNumber = 1 + AlbumTitle = "Audio Album", + ArtistName = "Audio Artist" } }; Mocker.GetMock() - .Setup(s => s.Map(It.Is(i => i.SeasonNumber == 1 && i.SeriesTitle == "TV Series"), It.IsAny(), It.IsAny>())) - .Returns(remoteEpisode); + .Setup(s => s.Map(It.Is(i => i.AlbumTitle == "Audio Album" && i.ArtistName == "Audio Artist"), It.IsAny(), It.IsAny>())) + .Returns(remoteAlbum); var client = new DownloadClientDefinition() { @@ -66,67 +66,11 @@ namespace NzbDrone.Core.Test.Download.TrackedDownloads var trackedDownload = Subject.TrackDownload(client, item); trackedDownload.Should().NotBeNull(); - trackedDownload.RemoteEpisode.Should().NotBeNull(); - trackedDownload.RemoteEpisode.Series.Should().NotBeNull(); - trackedDownload.RemoteEpisode.Series.Id.Should().Be(5); - trackedDownload.RemoteEpisode.Episodes.First().Id.Should().Be(4); - trackedDownload.RemoteEpisode.ParsedEpisodeInfo.SeasonNumber.Should().Be(1); + trackedDownload.RemoteAlbum.Should().NotBeNull(); + trackedDownload.RemoteAlbum.Artist.Should().NotBeNull(); + trackedDownload.RemoteAlbum.Artist.Id.Should().Be(5); + trackedDownload.RemoteAlbum.Albums.First().Id.Should().Be(4); } - [Test] - public void should_parse_as_special_when_source_title_parsing_fails() - { - var remoteEpisode = new RemoteEpisode - { - Series = new Series() { Id = 5 }, - Episodes = new List { new Episode { Id = 4 } }, - ParsedEpisodeInfo = new ParsedEpisodeInfo() - { - SeriesTitle = "TV Series", - SeasonNumber = 0, - EpisodeNumbers = new []{ 1 } - } - }; - - Mocker.GetMock() - .Setup(s => s.FindByDownloadId(It.Is(sr => sr == "35238"))) - .Returns(new List(){ - new History.History(){ - DownloadId = "35238", - SourceTitle = "TV Series Special", - SeriesId = 5, - EpisodeId = 4 - } - }); - - Mocker.GetMock() - .Setup(s => s.Map(It.Is(i => i.SeasonNumber == 0 && i.SeriesTitle == "TV Series"), It.IsAny(), It.IsAny>())) - .Returns(remoteEpisode); - - Mocker.GetMock() - .Setup(s => s.ParseSpecialEpisodeTitle(It.IsAny(), It.IsAny(), It.IsAny(), null)) - .Returns(remoteEpisode.ParsedEpisodeInfo); - - var client = new DownloadClientDefinition() - { - Id = 1, - Protocol = DownloadProtocol.Torrent - }; - - var item = new DownloadClientItem() - { - Title = "The torrent release folder", - DownloadId = "35238", - }; - - var trackedDownload = Subject.TrackDownload(client, item); - - trackedDownload.Should().NotBeNull(); - trackedDownload.RemoteEpisode.Should().NotBeNull(); - trackedDownload.RemoteEpisode.Series.Should().NotBeNull(); - trackedDownload.RemoteEpisode.Series.Id.Should().Be(5); - trackedDownload.RemoteEpisode.Episodes.First().Id.Should().Be(4); - trackedDownload.RemoteEpisode.ParsedEpisodeInfo.SeasonNumber.Should().Be(0); - } } } diff --git a/src/NzbDrone.Core.Test/HistoryTests/HistoryRepositoryFixture.cs b/src/NzbDrone.Core.Test/HistoryTests/HistoryRepositoryFixture.cs index 4d330c1a0..92355343e 100644 --- a/src/NzbDrone.Core.Test/HistoryTests/HistoryRepositoryFixture.cs +++ b/src/NzbDrone.Core.Test/HistoryTests/HistoryRepositoryFixture.cs @@ -32,13 +32,13 @@ namespace NzbDrone.Core.Test.HistoryTests { var historyBluray = Builder.CreateNew() .With(c => c.Quality = new QualityModel(Quality.MP3_320)) - .With(c => c.SeriesId = 12) + .With(c => c.ArtistId = 12) .With(c => c.EventType = HistoryEventType.Grabbed) .BuildNew(); var historyDvd = Builder.CreateNew() .With(c => c.Quality = new QualityModel(Quality.MP3_192)) - .With(c => c.SeriesId = 12) + .With(c => c.ArtistId = 12) .With(c => c.EventType = HistoryEventType.Grabbed) .BuildNew(); diff --git a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedHistoryItemsFixture.cs b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedHistoryItemsFixture.cs index 022248abd..fa1085cca 100644 --- a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedHistoryItemsFixture.cs +++ b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedHistoryItemsFixture.cs @@ -4,44 +4,44 @@ using NUnit.Framework; using NzbDrone.Core.Housekeeping.Housekeepers; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Test.Housekeeping.Housekeepers { [TestFixture] public class CleanupOrphanedHistoryItemsFixture : DbTest { - private Series _series; - private Episode _episode; + private Artist _artist; + private Album _album; [SetUp] public void Setup() { - _series = Builder.CreateNew() + _artist = Builder.CreateNew() .BuildNew(); - _episode = Builder.CreateNew() + _album = Builder.CreateNew() .BuildNew(); } - private void GivenSeries() + private void GivenArtist() { - Db.Insert(_series); + Db.Insert(_artist); } - private void GivenEpisode() + private void GivenAlbum() { - Db.Insert(_episode); + Db.Insert(_album); } [Test] - public void should_delete_orphaned_items_by_series() + public void should_delete_orphaned_items_by_artist() { - GivenEpisode(); + GivenAlbum(); var history = Builder.CreateNew() .With(h => h.Quality = new QualityModel()) - .With(h => h.EpisodeId = _episode.Id) + .With(h => h.AlbumId = _album.Id) .BuildNew(); Db.Insert(history); @@ -50,13 +50,13 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers } [Test] - public void should_delete_orphaned_items_by_episode() + public void should_delete_orphaned_items_by_album() { - GivenSeries(); + GivenArtist(); var history = Builder.CreateNew() .With(h => h.Quality = new QualityModel()) - .With(h => h.SeriesId = _series.Id) + .With(h => h.ArtistId = _artist.Id) .BuildNew(); Db.Insert(history); @@ -65,45 +65,45 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers } [Test] - public void should_not_delete_unorphaned_data_by_series() + public void should_not_delete_unorphaned_data_by_artist() { - GivenSeries(); - GivenEpisode(); + GivenArtist(); + GivenAlbum(); var history = Builder.CreateListOfSize(2) .All() .With(h => h.Quality = new QualityModel()) - .With(h => h.EpisodeId = _episode.Id) + .With(h => h.AlbumId = _album.Id) .TheFirst(1) - .With(h => h.SeriesId = _series.Id) + .With(h => h.ArtistId = _artist.Id) .BuildListOfNew(); Db.InsertMany(history); Subject.Clean(); AllStoredModels.Should().HaveCount(1); - AllStoredModels.Should().Contain(h => h.SeriesId == _series.Id); + AllStoredModels.Should().Contain(h => h.ArtistId == _artist.Id); } [Test] - public void should_not_delete_unorphaned_data_by_episode() + public void should_not_delete_unorphaned_data_by_album() { - GivenSeries(); - GivenEpisode(); + GivenArtist(); + GivenAlbum(); var history = Builder.CreateListOfSize(2) .All() .With(h => h.Quality = new QualityModel()) - .With(h => h.SeriesId = _series.Id) + .With(h => h.ArtistId = _artist.Id) .TheFirst(1) - .With(h => h.EpisodeId = _episode.Id) + .With(h => h.AlbumId = _album.Id) .BuildListOfNew(); Db.InsertMany(history); Subject.Clean(); AllStoredModels.Should().HaveCount(1); - AllStoredModels.Should().Contain(h => h.EpisodeId == _episode.Id); + AllStoredModels.Should().Contain(h => h.AlbumId == _album.Id); } } } \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedPendingReleasesFixture.cs b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedPendingReleasesFixture.cs index 104ba9bfc..c0d7aea4d 100644 --- a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedPendingReleasesFixture.cs +++ b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedPendingReleasesFixture.cs @@ -5,7 +5,7 @@ using NzbDrone.Core.Download.Pending; using NzbDrone.Core.Housekeeping.Housekeepers; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Test.Housekeeping.Housekeepers { @@ -16,7 +16,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers public void should_delete_orphaned_pending_items() { var pendingRelease = Builder.CreateNew() - .With(h => h.ParsedEpisodeInfo = new ParsedEpisodeInfo()) + .With(h => h.ParsedAlbumInfo = new ParsedAlbumInfo()) .With(h => h.Release = new ReleaseInfo()) .BuildNew(); @@ -28,13 +28,13 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers [Test] public void should_not_delete_unorphaned_pending_items() { - var series = Builder.CreateNew().BuildNew(); + var artist = Builder.CreateNew().BuildNew(); - Db.Insert(series); + Db.Insert(artist); var pendingRelease = Builder.CreateNew() - .With(h => h.SeriesId = series.Id) - .With(h => h.ParsedEpisodeInfo = new ParsedEpisodeInfo()) + .With(h => h.ArtistId = artist.Id) + .With(h => h.ParsedAlbumInfo = new ParsedAlbumInfo()) .With(h => h.Release = new ReleaseInfo()) .BuildNew(); diff --git a/src/NzbDrone.Core.Test/IndexerTests/BroadcastheNetTests/BroadcastheNetFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/BroadcastheNetTests/BroadcastheNetFixture.cs index e1b43d988..7291f9b94 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/BroadcastheNetTests/BroadcastheNetFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/BroadcastheNetTests/BroadcastheNetFixture.cs @@ -51,8 +51,6 @@ namespace NzbDrone.Core.Test.IndexerTests.BroadcastheNetTests torrentInfo.PublishDate.Should().Be(DateTime.Parse("2014/09/16 21:15:33")); torrentInfo.Size.Should().Be(505099926); torrentInfo.InfoHash.Should().Be("123"); - torrentInfo.TvdbId.Should().Be(71998); - torrentInfo.TvRageId.Should().Be(4055); torrentInfo.MagnetUrl.Should().BeNullOrEmpty(); torrentInfo.Peers.Should().Be(40+9); torrentInfo.Seeders.Should().Be(40); diff --git a/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabRequestGeneratorFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabRequestGeneratorFixture.cs index 1c7941695..5e5ef63d3 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabRequestGeneratorFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabRequestGeneratorFixture.cs @@ -36,7 +36,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests _singleAlbumSearchCriteria = new AlbumSearchCriteria { Artist = new Music.Artist { Name = "Alien Ant Farm" }, - Album = new Music.Album { Title = "TruANT" } + Albums = new List { new Music.Album { Title = "TruANT" } } }; diff --git a/src/NzbDrone.Core.Test/IndexerTests/RarbgTests/RarbgFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/RarbgTests/RarbgFixture.cs index 7f442fcb2..387f4047b 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/RarbgTests/RarbgFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/RarbgTests/RarbgFixture.cs @@ -56,8 +56,6 @@ namespace NzbDrone.Core.Test.IndexerTests.RarbgTests torrentInfo.MagnetUrl.Should().BeNull(); torrentInfo.Peers.Should().Be(304 + 200); torrentInfo.Seeders.Should().Be(304); - torrentInfo.TvdbId.Should().Be(268156); - torrentInfo.TvRageId.Should().Be(35197); } [Test] diff --git a/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs index 8701fdc9a..95963a75f 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs @@ -60,8 +60,6 @@ namespace NzbDrone.Core.Test.IndexerTests.TorznabTests releaseInfo.Indexer.Should().Be(Subject.Definition.Name); releaseInfo.PublishDate.Should().Be(DateTime.Parse("2015/03/14 21:10:42")); releaseInfo.Size.Should().Be(2538463390); - releaseInfo.TvdbId.Should().Be(273181); - releaseInfo.TvRageId.Should().Be(37780); releaseInfo.InfoHash.Should().Be("63e07ff523710ca268567dad344ce1e0e6b7e8a3"); releaseInfo.Seeders.Should().Be(7); releaseInfo.Peers.Should().Be(7); diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index a7e4d7937..6d6c90208 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -151,13 +151,12 @@ - - + @@ -167,7 +166,7 @@ - + diff --git a/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs index 2712c8dbf..d794172aa 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs @@ -1,4 +1,4 @@ -using FluentAssertions; +using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.Parser; using NzbDrone.Core.Test.Framework; @@ -62,5 +62,52 @@ namespace NzbDrone.Core.Test.ParserTests { Parser.Parser.ParseTitle(postTitle).SeriesTitle.Should().Be(title); } + + [TestCase("VA - The Best 101 Love Ballads (2017) MP3 [192 kbps]", "The Best 101 Love Ballads")] + [TestCase("ATCQ - The Love Movement 1998 2CD 192kbps RIP", "The Love Movement")] + [TestCase("A Tribe Called Quest - The Love Movement 1998 2CD [192kbps] RIP", "The Love Movement")] + [TestCase("Maula - Jism 2 [2012] Mp3 - 192Kbps [Extended]- TK", "Jism 2")] + [TestCase("VA - Complete Clubland - The Ultimate Ride Of Your Lfe [2014][MP3][192 kbps]")] + [TestCase("Complete Clubland - The Ultimate Ride Of Your Lfe [2014][MP3](192kbps)", "The Ultimate Ride Of Your Lfe")] + [TestCase("The Ultimate Ride Of Your Lfe [192 KBPS][2014][MP3]", "The Ultimate Ride Of Your Lfe")] + [TestCase("Gary Clark Jr - Live North America 2016 (2017) MP3 192kbps", "Live North America 2016")] + [TestCase("Beyoncé Lemonade [320] 2016 Beyonce Lemonade [320] 2016", "Lemonade")] + [TestCase("Childish Gambino - Awaken, My Love Album 2016 mp3 320 Kbps", "Awaken, My Love Album")] + [TestCase("Maluma – Felices Los 4 MP3 320 Kbps 2017 Download", "Felices Los 4")] + [TestCase("Ricardo Arjona - APNEA (Single 2014) (320 kbps)", "APNEA")] + [TestCase("Kehlani - SweetSexySavage (Deluxe Edition) (2017) 320", "SweetSexySavage")] + [TestCase("Anderson Paak - Malibu (320)(2016)", "Malibu")] + [TestCase("Caetano Veloso Discografia Completa MP3 @256","")] + [TestCase("Little Mix - Salute [Deluxe Edition] [2013] [M4A-256]-V3nom [GLT", "Salute")] + [TestCase("Ricky Martin - A Quien Quiera Escuchar (2015) 256 kbps [GloDLS]", "A Quien Quiera Escuchar")] + [TestCase("Jake Bugg - Jake Bugg (Album) [2012] {MP3 256 kbps}", "Jake Bugg")] + [TestCase("Milky Chance - Sadnecessary [256 Kbps] [M4A]", "Sadnecessary")] + [TestCase("Clean Bandit - New Eyes [2014] [Mp3-256]-V3nom [GLT]", "New Eyes")] + [TestCase("Armin van Buuren - A State Of Trance 810 (20.04.2017) 256 kbps", "A State Of Trance 810")] + [TestCase("PJ Harvey - Let England Shake [mp3-256-2011][trfkad]", "Let England Shake")] + [TestCase("X-Men Soundtracks (2006-2014) AAC, 256 kbps","")] + [TestCase("Walk the Line Soundtrack (2005) [AAC, 256 kbps]", "Walk the Line Soundtrack")] + [TestCase("Emeli Sande Next To Me (512 Kbps)", "Next To Me")] + [TestCase("Kendrick Lamar - DAMN (2017) FLAC", "DAMN")] + [TestCase("Alicia Keys - Vault Playlist Vol. 1 (2017) [FLAC CD]", "Vault Playlist Vol 1")] + [TestCase("Gorillaz - Humanz (Deluxe) - lossless FLAC Tracks - 2017 - CDrip", "Humanz")] + [TestCase("David Bowie - Blackstar (2016) [FLAC]", "Blackstar")] + [TestCase("The Cure - Greatest Hits (2001) FLAC Soup", "Greatest Hits")] + [TestCase("Slowdive - Souvlaki (FLAC)", "Souvlaki")] + [TestCase("John Coltrane - Kulu Se Mama (1965) [EAC-FLAC]", "Kulu Se Mama")] + [TestCase("The Rolling Stones - The Very Best Of '75-'94 (1995) {FLAC}", "The Very Best Of '75-'94")] + [TestCase("Migos-No_Label_II-CD-FLAC-2014-FORSAKEN", "No Label II")] + [TestCase("ADELE 25 CD FLAC 2015 PERFECT", "25")] + [TestCase("A.I. - Sex & Robots [2007/MP3/V0(VBR)]", "Sex & Robots")] + [TestCase("Jay-Z - 4:44 (Deluxe Edition) (2017) 320", "444")] + [TestCase("Roberta Flack 2006 - The Very Best of", "The Very Best of")] + [TestCase("VA - NOW Thats What I Call Music 96 (2017) [Mp3~Kbps]", "NOW Thats What I Call Music 96")] + [TestCase("Queen - The Ultimate Best Of Queen(2011)[mp3]", "The Ultimate Best Of Queen")] + [TestCase("Little Mix - Salute [Deluxe Edition] [2013] [M4A-256]-V3nom [GLT]", "Salute")] + [TestCase("Barış Manço - Ben Bilirim [1993/FLAC/Lossless/Log]", "Ben Bilirim")] + public void should_parse_album_title(string postTitle, string title) + { + Parser.Parser.ParseAlbumTitle(postTitle).AlbumTitle.Should().Be(title); + } } } diff --git a/src/NzbDrone.Core/Datastore/Migration/112_music_history.cs b/src/NzbDrone.Core/Datastore/Migration/112_music_history.cs new file mode 100644 index 000000000..48d287843 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/112_music_history.cs @@ -0,0 +1,36 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(112)] + public class music_history : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Alter.Table("History") + .AddColumn("ArtistId").AsInt32().WithDefaultValue(0) + .AddColumn("AlbumId").AsInt32().WithDefaultValue(0); + + Alter.Table("PendingReleases") + .AddColumn("ArtistId").AsInt32().WithDefaultValue(0) + .AddColumn("ParsedAlbumInfo").AsString().WithDefaultValue(""); + + Alter.Table("Tracks") + .AddColumn("Duration").AsInt32().WithDefaultValue(0); + + Alter.Table("Albums") + .AddColumn("Duration").AsInt32().WithDefaultValue(0); + + Delete.Column("SeriesId").FromTable("History"); + Delete.Column("EpisodeId").FromTable("History"); + Delete.Column("SeriesId").FromTable("PendingReleases"); + Delete.Column("ParsedEpisodeInfo").FromTable("PendingReleases"); + } + + } +} diff --git a/src/NzbDrone.Core/Datastore/TableMapping.cs b/src/NzbDrone.Core/Datastore/TableMapping.cs index 1b13c5af5..37a3a7658 100644 --- a/src/NzbDrone.Core/Datastore/TableMapping.cs +++ b/src/NzbDrone.Core/Datastore/TableMapping.cs @@ -106,7 +106,7 @@ namespace NzbDrone.Core.Datastore .For("Tracks") .LazyLoad(condition: parent => parent.Id > 0, query: (db, parent) => db.Query().Where(c => c.ArtistId == parent.Id).ToList()) // TODO: Figure what the hell to do here - .HasOne(file => file.Artist, file => file.AlbumId); + .HasOne(file => file.Artist, file => file.ArtistId); Mapper.Entity().RegisterModel("Tracks") //.Ignore(e => e.SeriesTitle) diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecision.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecision.cs index cad8177cb..c9d306ae8 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecision.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecision.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using NzbDrone.Core.Parser.Model; @@ -6,7 +6,7 @@ namespace NzbDrone.Core.DecisionEngine { public class DownloadDecision { - public RemoteEpisode RemoteEpisode { get; private set; } + public RemoteAlbum RemoteAlbum { get; private set; } public IEnumerable Rejections { get; private set; } public bool Approved => !Rejections.Any(); @@ -27,20 +27,20 @@ namespace NzbDrone.Core.DecisionEngine } } - public DownloadDecision(RemoteEpisode episode, params Rejection[] rejections) + public DownloadDecision(RemoteAlbum album, params Rejection[] rejections) { - RemoteEpisode = episode; + RemoteAlbum = album; Rejections = rejections.ToList(); } - + public override string ToString() { if (Approved) { - return "[OK] " + RemoteEpisode; + return "[OK] " + RemoteAlbum; } - return "[Rejected " + Rejections.Count() + "]" + RemoteEpisode; + return "[Rejected " + Rejections.Count() + "]" + RemoteAlbum; } } } \ No newline at end of file diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionComparer.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionComparer.cs index a85410046..ab7020625 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionComparer.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionComparer.cs @@ -4,7 +4,6 @@ using System.Linq; using NzbDrone.Core.Indexers; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Delay; -using NzbDrone.Core.Tv; namespace NzbDrone.Core.DecisionEngine { @@ -25,9 +24,8 @@ namespace NzbDrone.Core.DecisionEngine { CompareQuality, CompareProtocol, - CompareEpisodeCount, - CompareEpisodeNumber, ComparePeersIfTorrent, + CompareAlbumCount, CompareAgeIfUsenet, CompareSize }; @@ -57,67 +55,48 @@ namespace NzbDrone.Core.DecisionEngine private int CompareQuality(DownloadDecision x, DownloadDecision y) { - return CompareAll(CompareBy(x.RemoteEpisode, y.RemoteEpisode, remoteEpisode => remoteEpisode.Series.Profile.Value.Items.FindIndex(v => v.Quality == remoteEpisode.ParsedEpisodeInfo.Quality.Quality)), - CompareBy(x.RemoteEpisode, y.RemoteEpisode, remoteEpisode => remoteEpisode.ParsedEpisodeInfo.Quality.Revision.Real), - CompareBy(x.RemoteEpisode, y.RemoteEpisode, remoteEpisode => remoteEpisode.ParsedEpisodeInfo.Quality.Revision.Version)); + return CompareAll(CompareBy(x.RemoteAlbum, y.RemoteAlbum, remoteAlbum => remoteAlbum.Artist.Profile.Value.Items.FindIndex(v => v.Quality == remoteAlbum.ParsedAlbumInfo.Quality.Quality)), + CompareBy(x.RemoteAlbum, y.RemoteAlbum, remoteAlbum => remoteAlbum.ParsedAlbumInfo.Quality.Revision.Real), + CompareBy(x.RemoteAlbum, y.RemoteAlbum, remoteAlbum => remoteAlbum.ParsedAlbumInfo.Quality.Revision.Version)); } private int CompareProtocol(DownloadDecision x, DownloadDecision y) { - var result = CompareBy(x.RemoteEpisode, y.RemoteEpisode, remoteEpisode => + var result = CompareBy(x.RemoteAlbum, y.RemoteAlbum, remoteAlbum => { - var delayProfile = _delayProfileService.BestForTags(remoteEpisode.Series.Tags); - var downloadProtocol = remoteEpisode.Release.DownloadProtocol; + var delayProfile = _delayProfileService.BestForTags(remoteAlbum.Artist.Tags); + var downloadProtocol = remoteAlbum.Release.DownloadProtocol; return downloadProtocol == delayProfile.PreferredProtocol; }); return result; } - private int CompareEpisodeCount(DownloadDecision x, DownloadDecision y) + private int CompareAlbumCount(DownloadDecision x, DownloadDecision y) { - var seasonPackCompare = CompareBy(x.RemoteEpisode, y.RemoteEpisode, - remoteEpisode => remoteEpisode.ParsedEpisodeInfo.FullSeason); - - if (seasonPackCompare != 0) - { - return seasonPackCompare; - } - - if (x.RemoteEpisode.Series.SeriesType == SeriesTypes.Anime & - y.RemoteEpisode.Series.SeriesType == SeriesTypes.Anime) - { - return CompareBy(x.RemoteEpisode, y.RemoteEpisode, remoteEpisode => remoteEpisode.Episodes.Count); - } - - return CompareByReverse(x.RemoteEpisode, y.RemoteEpisode, remoteEpisode => remoteEpisode.Episodes.Count); - } - - private int CompareEpisodeNumber(DownloadDecision x, DownloadDecision y) - { - return CompareByReverse(x.RemoteEpisode, y.RemoteEpisode, remoteEpisode => remoteEpisode.Episodes.Select(e => e.EpisodeNumber).MinOrDefault()); + return CompareByReverse(x.RemoteAlbum, y.RemoteAlbum, remoteAlbum => remoteAlbum.Albums.Count); } private int ComparePeersIfTorrent(DownloadDecision x, DownloadDecision y) { // Different protocols should get caught when checking the preferred protocol, // since we're dealing with the same series in our comparisions - if (x.RemoteEpisode.Release.DownloadProtocol != DownloadProtocol.Torrent || - y.RemoteEpisode.Release.DownloadProtocol != DownloadProtocol.Torrent) + if (x.RemoteAlbum.Release.DownloadProtocol != DownloadProtocol.Torrent || + y.RemoteAlbum.Release.DownloadProtocol != DownloadProtocol.Torrent) { return 0; } return CompareAll( - CompareBy(x.RemoteEpisode, y.RemoteEpisode, remoteEpisode => + CompareBy(x.RemoteAlbum, y.RemoteAlbum, remoteAlbum => { - var seeders = TorrentInfo.GetSeeders(remoteEpisode.Release); + var seeders = TorrentInfo.GetSeeders(remoteAlbum.Release); return seeders.HasValue && seeders.Value > 0 ? Math.Round(Math.Log10(seeders.Value)) : 0; }), - CompareBy(x.RemoteEpisode, y.RemoteEpisode, remoteEpisode => + CompareBy(x.RemoteAlbum, y.RemoteAlbum, remoteAlbum => { - var peers = TorrentInfo.GetPeers(remoteEpisode.Release); + var peers = TorrentInfo.GetPeers(remoteAlbum.Release); return peers.HasValue && peers.Value > 0 ? Math.Round(Math.Log10(peers.Value)) : 0; })); @@ -125,16 +104,16 @@ namespace NzbDrone.Core.DecisionEngine private int CompareAgeIfUsenet(DownloadDecision x, DownloadDecision y) { - if (x.RemoteEpisode.Release.DownloadProtocol != DownloadProtocol.Usenet || - y.RemoteEpisode.Release.DownloadProtocol != DownloadProtocol.Usenet) + if (x.RemoteAlbum.Release.DownloadProtocol != DownloadProtocol.Usenet || + y.RemoteAlbum.Release.DownloadProtocol != DownloadProtocol.Usenet) { return 0; } - return CompareBy(x.RemoteEpisode, y.RemoteEpisode, remoteEpisode => + return CompareBy(x.RemoteAlbum, y.RemoteAlbum, remoteAlbum => { - var ageHours = remoteEpisode.Release.AgeHours; - var age = remoteEpisode.Release.Age; + var ageHours = remoteAlbum.Release.AgeHours; + var age = remoteAlbum.Release.Age; if (ageHours < 1) { @@ -159,7 +138,7 @@ namespace NzbDrone.Core.DecisionEngine { // TODO: Is smaller better? Smaller for usenet could mean no par2 files. - return CompareBy(x.RemoteEpisode, y.RemoteEpisode, remoteEpisode => remoteEpisode.Release.Size.Round(200.Megabytes())); + return CompareBy(x.RemoteAlbum, y.RemoteAlbum, remoteAlbum => remoteAlbum.Release.Size.Round(200.Megabytes())); } } } diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs index bb1a70873..7976f57b8 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using NLog; @@ -32,21 +32,20 @@ namespace NzbDrone.Core.DecisionEngine public List GetRssDecision(List reports) { - return GetDecisions(reports).ToList(); + return GetAlbumDecisions(reports).ToList(); } public List GetSearchDecision(List reports, SearchCriteriaBase searchCriteriaBase) { - return GetDecisions(reports, searchCriteriaBase).ToList(); + return GetAlbumDecisions(reports, searchCriteriaBase).ToList(); } - private IEnumerable GetDecisions(List reports, SearchCriteriaBase searchCriteria = null) + private IEnumerable GetAlbumDecisions(List reports, SearchCriteriaBase searchCriteria = null) { if (reports.Any()) { _logger.ProgressInfo("Processing {0} releases", reports.Count); } - else { _logger.ProgressInfo("No results found"); @@ -61,35 +60,25 @@ namespace NzbDrone.Core.DecisionEngine try { - var parsedEpisodeInfo = Parser.Parser.ParseTitle(report.Title); + var parsedAlbumInfo = Parser.Parser.ParseAlbumTitle(report.Title); - if (parsedEpisodeInfo == null || parsedEpisodeInfo.IsPossibleSpecialEpisode) + if (parsedAlbumInfo != null && !parsedAlbumInfo.ArtistName.IsNullOrWhiteSpace()) { - var specialEpisodeInfo = _parsingService.ParseSpecialEpisodeTitle(report.Title, report.TvdbId, report.TvRageId, searchCriteria); + var remoteAlbum = _parsingService.Map(parsedAlbumInfo, searchCriteria); + remoteAlbum.Release = report; - if (specialEpisodeInfo != null) + if (remoteAlbum.Artist == null) { - parsedEpisodeInfo = specialEpisodeInfo; + decision = new DownloadDecision(remoteAlbum, new Rejection("Unknown Artist")); } - } - - if (parsedEpisodeInfo != null && !parsedEpisodeInfo.SeriesTitle.IsNullOrWhiteSpace()) - { - var remoteEpisode = _parsingService.Map(parsedEpisodeInfo, report.TvdbId, report.TvRageId, searchCriteria); - remoteEpisode.Release = report; - - if (remoteEpisode.Series == null) + else if (remoteAlbum.Albums.Empty()) { - decision = new DownloadDecision(remoteEpisode, new Rejection("Unknown Series")); - } - else if (remoteEpisode.Episodes.Empty()) - { - decision = new DownloadDecision(remoteEpisode, new Rejection("Unable to parse episodes from release name")); + decision = new DownloadDecision(remoteAlbum, new Rejection("Unable to parse albums from release name")); } else { - remoteEpisode.DownloadAllowed = remoteEpisode.Episodes.Any(); - decision = GetDecisionForReport(remoteEpisode, searchCriteria); + remoteAlbum.DownloadAllowed = remoteAlbum.Albums.Any(); + decision = GetDecisionForReport(remoteAlbum, searchCriteria); } } } @@ -97,8 +86,8 @@ namespace NzbDrone.Core.DecisionEngine { _logger.Error(e, "Couldn't process release."); - var remoteEpisode = new RemoteEpisode { Release = report }; - decision = new DownloadDecision(remoteEpisode, new Rejection("Unexpected error processing release")); + var remoteAlbum = new RemoteAlbum { Release = report }; + decision = new DownloadDecision(remoteAlbum, new Rejection("Unexpected error processing release")); } reportNumber++; @@ -120,30 +109,34 @@ namespace NzbDrone.Core.DecisionEngine } } - private DownloadDecision GetDecisionForReport(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria = null) + private DownloadDecision GetDecisionForReport(RemoteAlbum remoteAlbum, SearchCriteriaBase searchCriteria = null) { - var reasons = _specifications.Select(c => EvaluateSpec(c, remoteEpisode, searchCriteria)) + var reasons = _specifications.Select(c => EvaluateSpec(c, remoteAlbum, searchCriteria)) .Where(c => c != null); - return new DownloadDecision(remoteEpisode, reasons.ToArray()); + return new DownloadDecision(remoteAlbum, reasons.ToArray()); } - private Rejection EvaluateSpec(IDecisionEngineSpecification spec, RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteriaBase = null) + private Rejection EvaluateSpec(IDecisionEngineSpecification spec, RemoteAlbum remoteAlbum, SearchCriteriaBase searchCriteriaBase = null) { try { - var result = spec.IsSatisfiedBy(remoteEpisode, searchCriteriaBase); + var result = spec.IsSatisfiedBy(remoteAlbum, searchCriteriaBase); if (!result.Accepted) { return new Rejection(result.Reason, spec.Type); } } + catch (NotImplementedException e) + { + _logger.Trace("Spec " + spec.GetType().Name + " not implemented."); + } catch (Exception e) { - e.Data.Add("report", remoteEpisode.Release.ToJson()); - e.Data.Add("parsed", remoteEpisode.ParsedEpisodeInfo.ToJson()); - _logger.Error(e, "Couldn't evaluate decision on {0}", remoteEpisode.Release.Title); + e.Data.Add("report", remoteAlbum.Release.ToJson()); + e.Data.Add("parsed", remoteAlbum.ParsedAlbumInfo.ToJson()); + _logger.Error(e, "Couldn't evaluate decision on {0}", remoteAlbum.Release.Title); return new Rejection($"{spec.GetType().Name}: {e.Message}"); } diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionPriorizationService.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionPriorizationService.cs index 33fc32f5d..469141328 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionPriorizationService.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionPriorizationService.cs @@ -20,13 +20,13 @@ namespace NzbDrone.Core.DecisionEngine public List PrioritizeDecisions(List decisions) { - return decisions.Where(c => c.RemoteEpisode.Series != null) - .GroupBy(c => c.RemoteEpisode.Series.Id, (seriesId, downloadDecisions) => + return decisions.Where(c => c.RemoteAlbum.Artist != null) + .GroupBy(c => c.RemoteAlbum.Artist.Id, (artistId, downloadDecisions) => { return downloadDecisions.OrderByDescending(decision => decision, new DownloadDecisionComparer(_delayProfileService)); }) .SelectMany(c => c) - .Union(decisions.Where(c => c.RemoteEpisode.Series == null)) + .Union(decisions.Where(c => c.RemoteAlbum.Artist == null)) .ToList(); } } diff --git a/src/NzbDrone.Core/DecisionEngine/IDecisionEngineSpecification.cs b/src/NzbDrone.Core/DecisionEngine/IDecisionEngineSpecification.cs index 199984734..937ce8d40 100644 --- a/src/NzbDrone.Core/DecisionEngine/IDecisionEngineSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/IDecisionEngineSpecification.cs @@ -1,4 +1,4 @@ -using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.DecisionEngine @@ -7,6 +7,6 @@ namespace NzbDrone.Core.DecisionEngine { RejectionType Type { get; } - Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria); + Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria); } } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/AcceptableSizeSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/AcceptableSizeSpecification.cs index 4ab566d2e..09045d5fe 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/AcceptableSizeSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/AcceptableSizeSpecification.cs @@ -1,10 +1,9 @@ -using System.Linq; +using System.Linq; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; using System.Collections.Generic; namespace NzbDrone.Core.DecisionEngine.Specifications @@ -12,29 +11,21 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public class AcceptableSizeSpecification : IDecisionEngineSpecification { private readonly IQualityDefinitionService _qualityDefinitionService; - private readonly IEpisodeService _episodeService; private readonly Logger _logger; - public AcceptableSizeSpecification(IQualityDefinitionService qualityDefinitionService, IEpisodeService episodeService, Logger logger) + public AcceptableSizeSpecification(IQualityDefinitionService qualityDefinitionService, Logger logger) { _qualityDefinitionService = qualityDefinitionService; - _episodeService = episodeService; _logger = logger; } public RejectionType Type => RejectionType.Permanent; - - public Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) + + public Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) { _logger.Debug("Beginning size check for: {0}", subject); - var quality = subject.ParsedEpisodeInfo.Quality.Quality; - - if (subject.ParsedEpisodeInfo.Special) - { - _logger.Debug("Special release found, skipping size check."); - return Decision.Accept(); - } + var quality = subject.ParsedAlbumInfo.Quality.Quality; if (subject.Release.Size == 0) { @@ -43,20 +34,22 @@ namespace NzbDrone.Core.DecisionEngine.Specifications } var qualityDefinition = _qualityDefinitionService.Get(quality); + var albumsDuration = subject.Albums.Sum(album => album.Duration) / 60000; + if (qualityDefinition.MinSize.HasValue) { var minSize = qualityDefinition.MinSize.Value.Megabytes(); - //Multiply maxSize by Series.Runtime - minSize = minSize * subject.Series.Runtime * subject.Episodes.Count; + //Multiply minSize by Album.Duration + minSize = minSize * albumsDuration; //If the parsed size is smaller than minSize we don't want it if (subject.Release.Size < minSize) { - var runtimeMessage = subject.Episodes.Count == 1 ? $"{subject.Series.Runtime}min" : $"{subject.Episodes.Count}x {subject.Series.Runtime}min"; + var runtimeMessage = $"{albumsDuration}min"; - _logger.Debug("Item: {0}, Size: {1} is smaller than minimum allowed size ({2} bytes for {3}), rejecting.", subject, subject.Release.Size, minSize, runtimeMessage); - return Decision.Reject("{0} is smaller than minimum allowed {1} (for {2})", subject.Release.Size.SizeSuffix(), minSize.SizeSuffix(), runtimeMessage); + _logger.Debug("Item: {0}, Size: {1} is smaller than minimum allowed size ({2} bytes), rejecting.", subject, subject.Release.Size, minSize); + return Decision.Reject("{0} is smaller than minimum allowed {1}", subject.Release.Size.SizeSuffix(), minSize.SizeSuffix()); } } if (!qualityDefinition.MaxSize.HasValue || qualityDefinition.MaxSize.Value == 0) @@ -67,40 +60,16 @@ namespace NzbDrone.Core.DecisionEngine.Specifications { var maxSize = qualityDefinition.MaxSize.Value.Megabytes(); - //Multiply maxSize by Series.Runtime - maxSize = maxSize * subject.Series.Runtime * subject.Episodes.Count; - - if (subject.Episodes.Count == 1) - { - Episode episode = subject.Episodes.First(); - List seasonEpisodes; - - var seasonSearchCriteria = searchCriteria as SeasonSearchCriteria; - if (seasonSearchCriteria != null && !seasonSearchCriteria.Series.UseSceneNumbering && seasonSearchCriteria.Episodes.Any(v => v.Id == episode.Id)) - { - seasonEpisodes = (searchCriteria as SeasonSearchCriteria).Episodes; - } - else - { - seasonEpisodes = _episodeService.GetEpisodesBySeason(episode.SeriesId, episode.SeasonNumber); - } - - //Ensure that this is either the first episode - //or is the last episode in a season that has 10 or more episodes - if (seasonEpisodes.First().Id == episode.Id || (seasonEpisodes.Count() >= 10 && seasonEpisodes.Last().Id == episode.Id)) - { - _logger.Debug("Possible double episode, doubling allowed size."); - maxSize = maxSize * 2; - } - } + //Multiply maxSize by Album.Duration + maxSize = maxSize * albumsDuration; //If the parsed size is greater than maxSize we don't want it if (subject.Release.Size > maxSize) { - var runtimeMessage = subject.Episodes.Count == 1 ? $"{subject.Series.Runtime}min" : $"{subject.Episodes.Count}x {subject.Series.Runtime}min"; + var runtimeMessage = $"{albumsDuration}min"; - _logger.Debug("Item: {0}, Size: {1} is greater than maximum allowed size ({2} for {3}), rejecting.", subject, subject.Release.Size, maxSize, runtimeMessage); - return Decision.Reject("{0} is larger than maximum allowed {1} (for {2})", subject.Release.Size.SizeSuffix(), maxSize.SizeSuffix(), runtimeMessage); + _logger.Debug("Item: {0}, Size: {1} is greater than maximum allowed size ({2}), rejecting.", subject, subject.Release.Size, maxSize); + return Decision.Reject("{0} is larger than maximum allowed {1}", subject.Release.Size.SizeSuffix(), maxSize.SizeSuffix()); } } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/AnimeVersionUpgradeSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/AnimeVersionUpgradeSpecification.cs deleted file mode 100644 index c2f93f7c0..000000000 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/AnimeVersionUpgradeSpecification.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System.Linq; -using NLog; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.DecisionEngine.Specifications -{ - public class AnimeVersionUpgradeSpecification : IDecisionEngineSpecification - { - private readonly QualityUpgradableSpecification _qualityUpgradableSpecification; - private readonly Logger _logger; - - public AnimeVersionUpgradeSpecification(QualityUpgradableSpecification qualityUpgradableSpecification, Logger logger) - { - _qualityUpgradableSpecification = qualityUpgradableSpecification; - _logger = logger; - } - - public RejectionType Type => RejectionType.Permanent; - - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - var releaseGroup = subject.ParsedEpisodeInfo.ReleaseGroup; - - if (subject.Series.SeriesType != SeriesTypes.Anime) - { - return Decision.Accept(); - } - - foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value)) - { - if (_qualityUpgradableSpecification.IsRevisionUpgrade(file.Quality, subject.ParsedEpisodeInfo.Quality)) - { - if (file.ReleaseGroup.IsNullOrWhiteSpace()) - { - _logger.Debug("Unable to compare release group, existing file's release group is unknown"); - return Decision.Reject("Existing release group is unknown"); - } - - if (releaseGroup.IsNullOrWhiteSpace()) - { - _logger.Debug("Unable to compare release group, release's release group is unknown"); - return Decision.Reject("Release group is unknown"); - } - - if (file.ReleaseGroup != releaseGroup) - { - _logger.Debug("Existing Release group is: {0} - release's release group is: {1}", file.ReleaseGroup, releaseGroup); - return Decision.Reject("{0} does not match existing release group {1}", releaseGroup, file.ReleaseGroup); - } - } - } - - return Decision.Accept(); - } - } -} diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/BlacklistSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/BlacklistSpecification.cs index 18b216263..3e487abb0 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/BlacklistSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/BlacklistSpecification.cs @@ -1,4 +1,4 @@ -using NLog; +using NLog; using NzbDrone.Core.Blacklisting; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; @@ -18,9 +18,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public RejectionType Type => RejectionType.Permanent; - public Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - if (_blacklistService.Blacklisted(subject.Series.Id, subject.Release)) + public Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + { + if (_blacklistService.Blacklisted(subject.Artist.Id, subject.Release)) { _logger.Debug("{0} is blacklisted, rejecting.", subject.Release.Title); return Decision.Reject("Release is blacklisted"); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/CutoffSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/CutoffSpecification.cs index c5d52a48a..ff02eacdf 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/CutoffSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/CutoffSpecification.cs @@ -1,39 +1,46 @@ -using System.Linq; +using System; +using System.Linq; using NLog; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.MediaFiles; namespace NzbDrone.Core.DecisionEngine.Specifications { public class CutoffSpecification : IDecisionEngineSpecification { private readonly QualityUpgradableSpecification _qualityUpgradableSpecification; + private readonly IMediaFileService _mediaFileService; private readonly Logger _logger; - public CutoffSpecification(QualityUpgradableSpecification qualityUpgradableSpecification, Logger logger) + public CutoffSpecification(QualityUpgradableSpecification qualityUpgradableSpecification, Logger logger, IMediaFileService mediaFileService) { _qualityUpgradableSpecification = qualityUpgradableSpecification; _logger = logger; + _mediaFileService = mediaFileService; } public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) { - foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value)) + + foreach (var album in subject.Albums) { - if (file == null) - { - _logger.Debug("File is no longer available, skipping this file."); - continue; - } + var trackFiles = _mediaFileService.GetFilesByAlbum(album.ArtistId, album.Id); - _logger.Debug("Comparing file quality with report. Existing file is {0}", file.Quality); - - if (!_qualityUpgradableSpecification.CutoffNotMet(subject.Series.Profile, file.Quality, subject.ParsedEpisodeInfo.Quality)) + if (trackFiles.Any()) { - _logger.Debug("Cutoff already met, rejecting."); - return Decision.Reject("Existing file meets cutoff: {0}", subject.Series.Profile.Value.Cutoff); + var lowestQuality = trackFiles.Select(c => c.Quality).OrderBy(c => c.Quality.Id).First(); + + _logger.Debug("Comparing file quality with report. Existing file is {0}", lowestQuality); + + if (!_qualityUpgradableSpecification.CutoffNotMet(subject.Artist.Profile, lowestQuality, subject.ParsedAlbumInfo.Quality)) + { + _logger.Debug("Cutoff already met, rejecting."); + return Decision.Reject("Existing file meets cutoff: {0}", subject.Artist.Profile.Value.Cutoff); + } + } } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/DiscographySpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/DiscographySpecification.cs new file mode 100644 index 000000000..ff25de723 --- /dev/null +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/DiscographySpecification.cs @@ -0,0 +1,26 @@ +using System; +using NLog; +using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Parser.Model; +using NzbDrone.Common.Extensions; +using System.Linq; + +namespace NzbDrone.Core.DecisionEngine.Specifications +{ + public class DiscographySpecification : IDecisionEngineSpecification + { + private readonly Logger _logger; + + public DiscographySpecification(Logger logger) + { + _logger = logger; + } + + public RejectionType Type => RejectionType.Permanent; + + public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/FullSeasonSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/FullSeasonSpecification.cs deleted file mode 100644 index 023b6be60..000000000 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/FullSeasonSpecification.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using NLog; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Parser.Model; -using NzbDrone.Common.Extensions; -using System.Linq; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.DecisionEngine.Specifications -{ - public class FullSeasonSpecification : IDecisionEngineSpecification - { - private readonly Logger _logger; - private readonly IEpisodeService _episodeService; - - public FullSeasonSpecification(Logger logger, IEpisodeService episodeService) - { - _logger = logger; - _episodeService = episodeService; - } - - public RejectionType Type => RejectionType.Permanent; - - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - if (subject.ParsedEpisodeInfo.FullSeason) - { - _logger.Debug("Checking if all episodes in full season release have aired. {0}", subject.Release.Title); - - if (subject.Episodes.Any(e => !e.AirDateUtc.HasValue || e.AirDateUtc.Value.After(DateTime.UtcNow))) - { - _logger.Debug("Full season release {0} rejected. All episodes haven't aired yet.", subject.Release.Title); - return Decision.Reject("Full season release rejected. All episodes haven't aired yet."); - } - } - - return Decision.Accept(); - } - } -} diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/LanguageSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/LanguageSpecification.cs index 9f7f75038..3ee173b22 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/LanguageSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/LanguageSpecification.cs @@ -1,4 +1,4 @@ -using NLog; +using NLog; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; @@ -15,16 +15,16 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) { - var wantedLanguage = subject.Series.Profile.Value.Language; - - _logger.Debug("Checking if report meets language requirements. {0}", subject.ParsedEpisodeInfo.Language); + var wantedLanguage = subject.Artist.Profile.Value.Language; - if (subject.ParsedEpisodeInfo.Language != wantedLanguage) + _logger.Debug("Checking if report meets language requirements. {0}", subject.ParsedAlbumInfo.Language); + + if (subject.ParsedAlbumInfo.Language != wantedLanguage) { - _logger.Debug("Report Language: {0} rejected because it is not wanted, wanted {1}", subject.ParsedEpisodeInfo.Language, wantedLanguage); - return Decision.Reject("{0} is wanted, but found {1}", wantedLanguage, subject.ParsedEpisodeInfo.Language); + _logger.Debug("Report Language: {0} rejected because it is not wanted, wanted {1}", subject.ParsedAlbumInfo.Language, wantedLanguage); + return Decision.Reject("{0} is wanted, but found {1}", wantedLanguage, subject.ParsedAlbumInfo.Language); } return Decision.Accept(); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/MinimumAgeSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/MinimumAgeSpecification.cs index 449d7be76..47b09ab66 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/MinimumAgeSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/MinimumAgeSpecification.cs @@ -18,7 +18,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public RejectionType Type => RejectionType.Temporary; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) { if (subject.Release.DownloadProtocol != Indexers.DownloadProtocol.Usenet) { diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/NotSampleSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/NotSampleSpecification.cs index 02ff7653a..ab4e2e3ff 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/NotSampleSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/NotSampleSpecification.cs @@ -1,4 +1,5 @@ -using NLog; +using System; +using NLog; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; @@ -15,15 +16,16 @@ namespace NzbDrone.Core.DecisionEngine.Specifications _logger = logger; } - public Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) + public Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) { - if (subject.Release.Title.ToLower().Contains("sample") && subject.Release.Size < 70.Megabytes()) - { - _logger.Debug("Sample release, rejecting."); - return Decision.Reject("Sample"); - } + if (subject.Release.Title.ToLower().Contains("sample") && subject.Release.Size < 20.Megabytes()) + { + _logger.Debug("Sample release, rejecting."); + return Decision.Reject("Sample"); + } - return Decision.Accept(); + return Decision.Accept(); } + } } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/ProtocolSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/ProtocolSpecification.cs index 008e58812..7d37b8770 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/ProtocolSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/ProtocolSpecification.cs @@ -1,4 +1,4 @@ -using NLog; +using NLog; using NzbDrone.Core.Indexers; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; @@ -20,20 +20,20 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) { - var delayProfile = _delayProfileService.BestForTags(subject.Series.Tags); + var delayProfile = _delayProfileService.BestForTags(subject.Artist.Tags); if (subject.Release.DownloadProtocol == DownloadProtocol.Usenet && !delayProfile.EnableUsenet) { - _logger.Debug("[{0}] Usenet is not enabled for this series", subject.Release.Title); - return Decision.Reject("Usenet is not enabled for this series"); + _logger.Debug("[{0}] Usenet is not enabled for this artist", subject.Release.Title); + return Decision.Reject("Usenet is not enabled for this artist"); } if (subject.Release.DownloadProtocol == DownloadProtocol.Torrent && !delayProfile.EnableTorrent) { - _logger.Debug("[{0}] Torrent is not enabled for this series", subject.Release.Title); - return Decision.Reject("Torrent is not enabled for this series"); + _logger.Debug("[{0}] Torrent is not enabled for this artist", subject.Release.Title); + return Decision.Reject("Torrent is not enabled for this artist"); } return Decision.Accept(); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/QualityAllowedByProfileSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/QualityAllowedByProfileSpecification.cs index 7913e0e7e..cc2f44331 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/QualityAllowedByProfileSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/QualityAllowedByProfileSpecification.cs @@ -1,4 +1,4 @@ -using NLog; +using NLog; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; @@ -15,13 +15,13 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) { - _logger.Debug("Checking if report meets quality requirements. {0}", subject.ParsedEpisodeInfo.Quality); - if (!subject.Series.Profile.Value.Items.Exists(v => v.Allowed && v.Quality == subject.ParsedEpisodeInfo.Quality.Quality)) + _logger.Debug("Checking if report meets quality requirements. {0}", subject.ParsedAlbumInfo.Quality); + if (!subject.Artist.Profile.Value.Items.Exists(v => v.Allowed && v.Quality == subject.ParsedAlbumInfo.Quality.Quality)) { - _logger.Debug("Quality {0} rejected by Series' quality profile", subject.ParsedEpisodeInfo.Quality); - return Decision.Reject("{0} is not wanted in profile", subject.ParsedEpisodeInfo.Quality.Quality); + _logger.Debug("Quality {0} rejected by Artist's quality profile", subject.ParsedAlbumInfo.Quality); + return Decision.Reject("{0} is not wanted in profile", subject.ParsedAlbumInfo.Quality.Quality); } return Decision.Accept(); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/QueueSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/QueueSpecification.cs index 6f3ec1bea..38464e36c 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/QueueSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/QueueSpecification.cs @@ -1,3 +1,4 @@ +using System; using System.Linq; using NLog; using NzbDrone.Core.IndexerSearch.Definitions; @@ -23,32 +24,33 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public RejectionType Type => RejectionType.Permanent; - public Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) + public Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) { var queue = _queueService.GetQueue() - .Select(q => q.RemoteEpisode).ToList(); + .Select(q => q.RemoteAlbum).ToList(); - var matchingSeries = queue.Where(q => q.Series.Id == subject.Series.Id); - var matchingEpisode = matchingSeries.Where(q => q.Episodes.Select(e => e.Id).Intersect(subject.Episodes.Select(e => e.Id)).Any()); + var matchingArtist = queue.Where(q => q.Artist.Id == subject.Artist.Id); + var matchingAlbum = matchingArtist.Where(q => q.Albums.Select(e => e.Id).Intersect(subject.Albums.Select(e => e.Id)).Any()); - foreach (var remoteEpisode in matchingEpisode) + foreach (var remoteAlbum in matchingAlbum) { - _logger.Debug("Checking if existing release in queue meets cutoff. Queued quality is: {0}", remoteEpisode.ParsedEpisodeInfo.Quality); + _logger.Debug("Checking if existing release in queue meets cutoff. Queued quality is: {0}", remoteAlbum.ParsedAlbumInfo.Quality); - if (!_qualityUpgradableSpecification.CutoffNotMet(subject.Series.Profile, remoteEpisode.ParsedEpisodeInfo.Quality, subject.ParsedEpisodeInfo.Quality)) + if (!_qualityUpgradableSpecification.CutoffNotMet(subject.Artist.Profile, remoteAlbum.ParsedAlbumInfo.Quality, subject.ParsedAlbumInfo.Quality)) { - return Decision.Reject("Quality for release in queue already meets cutoff: {0}", remoteEpisode.ParsedEpisodeInfo.Quality); + return Decision.Reject("Quality for release in queue already meets cutoff: {0}", remoteAlbum.ParsedAlbumInfo.Quality); } - _logger.Debug("Checking if release is higher quality than queued release. Queued quality is: {0}", remoteEpisode.ParsedEpisodeInfo.Quality); + _logger.Debug("Checking if release is higher quality than queued release. Queued quality is: {0}", remoteAlbum.ParsedAlbumInfo.Quality); - if (!_qualityUpgradableSpecification.IsUpgradable(subject.Series.Profile, remoteEpisode.ParsedEpisodeInfo.Quality, subject.ParsedEpisodeInfo.Quality)) + if (!_qualityUpgradableSpecification.IsUpgradable(subject.Artist.Profile, remoteAlbum.ParsedAlbumInfo.Quality, subject.ParsedAlbumInfo.Quality)) { - return Decision.Reject("Quality for release in queue is of equal or higher preference: {0}", remoteEpisode.ParsedEpisodeInfo.Quality); + return Decision.Reject("Quality for release in queue is of equal or higher preference: {0}", remoteAlbum.ParsedAlbumInfo.Quality); } } return Decision.Accept(); + } } } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RawDiskSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RawDiskSpecification.cs index 7f278cb7e..c079cefce 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RawDiskSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RawDiskSpecification.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Core.IndexerSearch.Definitions; @@ -8,9 +8,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications { public class RawDiskSpecification : IDecisionEngineSpecification { - private static readonly string[] _dvdContainerTypes = new[] { "vob", "iso" }; - - private static readonly string[] _blurayContainerTypes = new[] { "m2ts" }; + private static readonly string[] _cdContainerTypes = new[] { "vob", "iso" }; private readonly Logger _logger; @@ -21,24 +19,18 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) { if (subject.Release == null || subject.Release.Container.IsNullOrWhiteSpace()) { return Decision.Accept(); } - if (_dvdContainerTypes.Contains(subject.Release.Container.ToLower())) - { - _logger.Debug("Release contains raw DVD, rejecting."); - return Decision.Reject("Raw DVD release"); - } - - if (_blurayContainerTypes.Contains(subject.Release.Container.ToLower())) - { - _logger.Debug("Release contains raw Bluray, rejecting."); - return Decision.Reject("Raw Bluray release"); - } + if (_cdContainerTypes.Contains(subject.Release.Container.ToLower())) + { + _logger.Debug("Release contains raw CD, rejecting."); + return Decision.Reject("Raw CD release"); + } return Decision.Accept(); } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/ReleaseRestrictionsSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/ReleaseRestrictionsSpecification.cs index 9fb8c13f5..37de16679 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/ReleaseRestrictionsSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/ReleaseRestrictionsSpecification.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using NLog; @@ -22,19 +22,19 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) { _logger.Debug("Checking if release meets restrictions: {0}", subject); var title = subject.Release.Title; - var restrictions = _restrictionService.AllForTags(subject.Series.Tags); + var restrictions = _restrictionService.AllForTags(subject.Artist.Tags); var required = restrictions.Where(r => r.Required.IsNotNullOrWhiteSpace()); var ignored = restrictions.Where(r => r.Ignored.IsNotNullOrWhiteSpace()); foreach (var r in required) { - var requiredTerms = r.Required.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).ToList(); + var requiredTerms = r.Required.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); var foundTerms = ContainsAny(requiredTerms, title); if (foundTerms.Empty()) diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RetentionSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RetentionSpecification.cs index 97802f871..f2f3b1fa3 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RetentionSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RetentionSpecification.cs @@ -18,7 +18,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) { if (subject.Release.DownloadProtocol != Indexers.DownloadProtocol.Usenet) { diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DelaySpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DelaySpecification.cs index 68551c66c..ae9c64ec8 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DelaySpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DelaySpecification.cs @@ -1,10 +1,11 @@ -using System.Linq; +using System.Linq; using NLog; using NzbDrone.Core.Download.Pending; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Delay; using NzbDrone.Core.Qualities; +using NzbDrone.Core.MediaFiles; namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync { @@ -13,22 +14,25 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync private readonly IPendingReleaseService _pendingReleaseService; private readonly IQualityUpgradableSpecification _qualityUpgradableSpecification; private readonly IDelayProfileService _delayProfileService; + private readonly IMediaFileService _mediaFileService; private readonly Logger _logger; public DelaySpecification(IPendingReleaseService pendingReleaseService, IQualityUpgradableSpecification qualityUpgradableSpecification, IDelayProfileService delayProfileService, + IMediaFileService mediaFileService, Logger logger) { _pendingReleaseService = pendingReleaseService; _qualityUpgradableSpecification = qualityUpgradableSpecification; _delayProfileService = delayProfileService; + _mediaFileService = mediaFileService; _logger = logger; } public RejectionType Type => RejectionType.Temporary; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) { if (searchCriteria != null && searchCriteria.UserInvokedSearch) { @@ -36,8 +40,8 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync return Decision.Accept(); } - var profile = subject.Series.Profile.Value; - var delayProfile = _delayProfileService.BestForTags(subject.Series.Tags); + var profile = subject.Artist.Profile.Value; + var delayProfile = _delayProfileService.BestForTags(subject.Artist.Tags); var delay = delayProfile.GetProtocolDelay(subject.Release.DownloadProtocol); var isPreferredProtocol = subject.Release.DownloadProtocol == delayProfile.PreferredProtocol; @@ -51,18 +55,24 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync if (isPreferredProtocol) { - foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value)) + foreach (var album in subject.Albums) { - var upgradable = _qualityUpgradableSpecification.IsUpgradable(profile, file.Quality, subject.ParsedEpisodeInfo.Quality); + var trackFiles = _mediaFileService.GetFilesByAlbum(album.ArtistId, album.Id); - if (upgradable) + if (trackFiles.Any()) { - var revisionUpgrade = _qualityUpgradableSpecification.IsRevisionUpgrade(file.Quality, subject.ParsedEpisodeInfo.Quality); + var lowestQuality = trackFiles.Select(c => c.Quality).OrderBy(c => c.Quality.Id).First(); + var upgradable = _qualityUpgradableSpecification.IsUpgradable(profile, lowestQuality, subject.ParsedAlbumInfo.Quality); - if (revisionUpgrade) + if (upgradable) { - _logger.Debug("New quality is a better revision for existing quality, skipping delay"); - return Decision.Accept(); + var revisionUpgrade = _qualityUpgradableSpecification.IsRevisionUpgrade(lowestQuality, subject.ParsedAlbumInfo.Quality); + + if (revisionUpgrade) + { + _logger.Debug("New quality is a better revision for existing quality, skipping delay"); + return Decision.Accept(); + } } } } @@ -70,7 +80,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync // If quality meets or exceeds the best allowed quality in the profile accept it immediately var bestQualityInProfile = new QualityModel(profile.LastAllowedQuality()); - var isBestInProfile = comparer.Compare(subject.ParsedEpisodeInfo.Quality, bestQualityInProfile) >= 0; + var isBestInProfile = comparer.Compare(subject.ParsedAlbumInfo.Quality, bestQualityInProfile) >= 0; if (isBestInProfile && isPreferredProtocol) { @@ -78,9 +88,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync return Decision.Accept(); } - var episodeIds = subject.Episodes.Select(e => e.Id); + var albumIds = subject.Albums.Select(e => e.Id); - var oldest = _pendingReleaseService.OldestPendingRelease(subject.Series.Id, episodeIds); + var oldest = _pendingReleaseService.OldestPendingRelease(subject.Artist.Id, albumIds); if (oldest != null && oldest.Release.AgeMinutes > delay) { diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/HistorySpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/HistorySpecification.cs index 9aa4fabf1..d654cfd84 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/HistorySpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/HistorySpecification.cs @@ -1,4 +1,4 @@ -using System; +using System; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Core.Configuration; @@ -28,7 +28,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) { if (searchCriteria != null) { @@ -39,16 +39,16 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync var cdhEnabled = _configService.EnableCompletedDownloadHandling; _logger.Debug("Performing history status check on report"); - foreach (var episode in subject.Episodes) + foreach (var album in subject.Albums) { - _logger.Debug("Checking current status of episode [{0}] in history", episode.Id); - var mostRecent = _historyService.MostRecentForEpisode(episode.Id); + _logger.Debug("Checking current status of album [{0}] in history", album.Id); + var mostRecent = _historyService.MostRecentForAlbum(album.Id); if (mostRecent != null && mostRecent.EventType == HistoryEventType.Grabbed) { var recent = mostRecent.Date.After(DateTime.UtcNow.AddHours(-12)); - var cutoffUnmet = _qualityUpgradableSpecification.CutoffNotMet(subject.Series.Profile, mostRecent.Quality, subject.ParsedEpisodeInfo.Quality); - var upgradeable = _qualityUpgradableSpecification.IsUpgradable(subject.Series.Profile, mostRecent.Quality, subject.ParsedEpisodeInfo.Quality); + var cutoffUnmet = _qualityUpgradableSpecification.CutoffNotMet(subject.Artist.Profile, mostRecent.Quality, subject.ParsedAlbumInfo.Quality); + var upgradeable = _qualityUpgradableSpecification.IsUpgradable(subject.Artist.Profile, mostRecent.Quality, subject.ParsedAlbumInfo.Quality); if (!recent && cdhEnabled) { @@ -59,7 +59,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync { if (recent) { - return Decision.Reject("Recent grab event in history already meets cutoff: {0}", mostRecent.Quality); + return Decision.Reject("Recent grab event in history already meets cutoff: {0}", mostRecent.Quality); } return Decision.Reject("CDH is disabled and grab event in history already meets cutoff: {0}", mostRecent.Quality); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredEpisodeSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredAlbumSpecification.cs similarity index 52% rename from src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredEpisodeSpecification.cs rename to src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredAlbumSpecification.cs index f56f26478..335d31497 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredEpisodeSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredAlbumSpecification.cs @@ -1,22 +1,22 @@ -using System.Linq; +using System.Linq; using NLog; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync { - public class MonitoredEpisodeSpecification : IDecisionEngineSpecification + public class MonitoredAlbumSpecification : IDecisionEngineSpecification { private readonly Logger _logger; - public MonitoredEpisodeSpecification(Logger logger) + public MonitoredAlbumSpecification(Logger logger) { _logger = logger; } public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) { if (searchCriteria != null) { @@ -27,20 +27,20 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync } } - if (!subject.Series.Monitored) + if (!subject.Artist.Monitored) { - _logger.Debug("{0} is present in the DB but not tracked. skipping.", subject.Series); - return Decision.Reject("Series is not monitored"); + _logger.Debug("{0} is present in the DB but not tracked. skipping.", subject.Artist); + return Decision.Reject("Artist is not monitored"); } - var monitoredCount = subject.Episodes.Count(episode => episode.Monitored); - if (monitoredCount == subject.Episodes.Count) + var monitoredCount = subject.Albums.Count(album => album.Monitored); + if (monitoredCount == subject.Albums.Count) { return Decision.Accept(); } - _logger.Debug("Only {0}/{1} episodes are monitored. skipping.", monitoredCount, subject.Episodes.Count); - return Decision.Reject("Episode is not monitored"); + _logger.Debug("Only {0}/{1} albums are monitored. skipping.", monitoredCount, subject.Albums.Count); + return Decision.Reject("Album is not monitored"); } } } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/ProperSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/ProperSpecification.cs index 0c6632d25..09d9f4828 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/ProperSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/ProperSpecification.cs @@ -1,9 +1,10 @@ -using System; +using System; using System.Linq; using NLog; using NzbDrone.Core.Configuration; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.MediaFiles; namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync { @@ -11,39 +12,52 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync { private readonly QualityUpgradableSpecification _qualityUpgradableSpecification; private readonly IConfigService _configService; + private readonly IMediaFileService _mediaFileService; private readonly Logger _logger; - public ProperSpecification(QualityUpgradableSpecification qualityUpgradableSpecification, IConfigService configService, Logger logger) + public ProperSpecification(QualityUpgradableSpecification qualityUpgradableSpecification, IConfigService configService, IMediaFileService mediaFileService, Logger logger) { _qualityUpgradableSpecification = qualityUpgradableSpecification; _configService = configService; + _mediaFileService = mediaFileService; _logger = logger; } public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) { if (searchCriteria != null) { return Decision.Accept(); } - foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value)) + foreach (var album in subject.Albums) { - if (_qualityUpgradableSpecification.IsRevisionUpgrade(file.Quality, subject.ParsedEpisodeInfo.Quality)) + var trackFiles = _mediaFileService.GetFilesByAlbum(album.ArtistId, album.Id); + + if (trackFiles.Any()) { - if (file.DateAdded < DateTime.Today.AddDays(-7)) - { - _logger.Debug("Proper for old file, rejecting: {0}", subject); - return Decision.Reject("Proper for old file"); - } + var lowestQuality = trackFiles.Select(c => c.Quality).OrderBy(c => c.Quality.Id).First(); + var dateAdded = trackFiles[0].DateAdded; - if (!_configService.AutoDownloadPropers) + _logger.Debug("Comparing file quality with report. Existing file is {0}", lowestQuality); + + if (_qualityUpgradableSpecification.IsRevisionUpgrade(lowestQuality, subject.ParsedAlbumInfo.Quality)) { - _logger.Debug("Auto downloading of propers is disabled"); - return Decision.Reject("Proper downloading is disabled"); + if (dateAdded < DateTime.Today.AddDays(-7)) + { + _logger.Debug("Proper for old file, rejecting: {0}", subject); + return Decision.Reject("Proper for old file"); + } + + if (!_configService.AutoDownloadPropers) + { + _logger.Debug("Auto downloading of propers is disabled"); + return Decision.Reject("Proper downloading is disabled"); + } } + } } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/SameEpisodesGrabSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/SameEpisodesGrabSpecification.cs deleted file mode 100644 index 1a8c5db5b..000000000 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/SameEpisodesGrabSpecification.cs +++ /dev/null @@ -1,31 +0,0 @@ -using NLog; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.DecisionEngine.Specifications -{ - public class SameEpisodesGrabSpecification : IDecisionEngineSpecification - { - private readonly SameEpisodesSpecification _sameEpisodesSpecification; - private readonly Logger _logger; - - public SameEpisodesGrabSpecification(SameEpisodesSpecification sameEpisodesSpecification, Logger logger) - { - _sameEpisodesSpecification = sameEpisodesSpecification; - _logger = logger; - } - - public RejectionType Type => RejectionType.Permanent; - - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) - { - if (_sameEpisodesSpecification.IsSatisfiedBy(subject.Episodes)) - { - return Decision.Accept(); - } - - _logger.Debug("Episode file on disk contains more episodes than this release contains"); - return Decision.Reject("Episode file on disk contains more episodes than this release contains"); - } - } -} diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/SameTracksGrabSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/SameTracksGrabSpecification.cs new file mode 100644 index 000000000..c7098f11d --- /dev/null +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/SameTracksGrabSpecification.cs @@ -0,0 +1,28 @@ +using System; +using NLog; +using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Parser.Model; + +namespace NzbDrone.Core.DecisionEngine.Specifications +{ + public class SameTracksGrabSpecification : IDecisionEngineSpecification + { + private readonly SameTracksSpecification _sameTracksSpecification; + private readonly Logger _logger; + + public SameTracksGrabSpecification(SameTracksSpecification sameTracksSpecification, Logger logger) + { + _sameTracksSpecification = sameTracksSpecification; + _logger = logger; + } + + public RejectionType Type => RejectionType.Permanent; + + public Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + { + throw new NotImplementedException(); + + // TODO: Rework for Tracks if we can parse from release details. + } + } +} diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/AlbumRequestedSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/AlbumRequestedSpecification.cs new file mode 100644 index 000000000..b513b575d --- /dev/null +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/AlbumRequestedSpecification.cs @@ -0,0 +1,40 @@ +using System.Linq; +using NLog; +using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Music; + + +namespace NzbDrone.Core.DecisionEngine.Specifications.Search +{ + public class AlbumRequestedSpecification : IDecisionEngineSpecification + { + private readonly Logger _logger; + + public AlbumRequestedSpecification(Logger logger) + { + _logger = logger; + } + + public RejectionType Type => RejectionType.Permanent; + + public Decision IsSatisfiedBy(RemoteAlbum remoteAlbum, SearchCriteriaBase searchCriteria) + { + if (searchCriteria == null) + { + return Decision.Accept(); + } + + var criteriaAlbum = searchCriteria.Albums.Select(v => v.Id).ToList(); + var remoteAlbums = remoteAlbum.Albums.Select(v => v.Id).ToList(); + + if (!criteriaAlbum.Intersect(remoteAlbums).Any()) + { + _logger.Debug("Release rejected since the album wasn't requested: {0}", remoteAlbum.ParsedAlbumInfo); + return Decision.Reject("Album wasn't requested"); + } + + return Decision.Accept(); + } + } +} diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/ArtistSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/ArtistSpecification.cs new file mode 100644 index 000000000..cef67f820 --- /dev/null +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/ArtistSpecification.cs @@ -0,0 +1,36 @@ +using NLog; +using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Parser.Model; + +namespace NzbDrone.Core.DecisionEngine.Specifications.Search +{ + public class ArtistSpecification : IDecisionEngineSpecification + { + private readonly Logger _logger; + + public ArtistSpecification(Logger logger) + { + _logger = logger; + } + + public RejectionType Type => RejectionType.Permanent; + + public Decision IsSatisfiedBy(RemoteAlbum remoteAlbum, SearchCriteriaBase searchCriteria) + { + if (searchCriteria == null) + { + return Decision.Accept(); + } + + _logger.Debug("Checking if artist matches searched artist"); + + if (remoteAlbum.Artist.Id != searchCriteria.Artist.Id) + { + _logger.Debug("Artist {0} does not match {1}", remoteAlbum.Artist, searchCriteria.Artist); + return Decision.Reject("Wrong artist"); + } + + return Decision.Accept(); + } + } +} \ No newline at end of file diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/DailyAudioMatchSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/DailyAudioMatchSpecification.cs new file mode 100644 index 000000000..e023a92f4 --- /dev/null +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/DailyAudioMatchSpecification.cs @@ -0,0 +1,26 @@ +using System; +using NLog; +using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Parser.Model; + +namespace NzbDrone.Core.DecisionEngine.Specifications.Search +{ + public class DailyAudioMatchSpecification : IDecisionEngineSpecification + { + private readonly Logger _logger; + + public DailyAudioMatchSpecification(Logger logger) + { + _logger = logger; + } + + public RejectionType Type => RejectionType.Permanent; + + public Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) + { + throw new NotImplementedException(); + + // TODO Rework for Daily Audio/Podcasts + } + } +} \ No newline at end of file diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/DailyEpisodeMatchSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/DailyEpisodeMatchSpecification.cs deleted file mode 100644 index 50fd9b3cc..000000000 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/DailyEpisodeMatchSpecification.cs +++ /dev/null @@ -1,43 +0,0 @@ -using NLog; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.DecisionEngine.Specifications.Search -{ - public class DailyEpisodeMatchSpecification : IDecisionEngineSpecification - { - private readonly Logger _logger; - private readonly IEpisodeService _episodeService; - - public DailyEpisodeMatchSpecification(Logger logger, IEpisodeService episodeService) - { - _logger = logger; - _episodeService = episodeService; - } - - public RejectionType Type => RejectionType.Permanent; - - public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria) - { - if (searchCriteria == null) - { - return Decision.Accept(); - } - - var dailySearchSpec = searchCriteria as DailyEpisodeSearchCriteria; - - if (dailySearchSpec == null) return Decision.Accept(); - - var episode = _episodeService.GetEpisode(dailySearchSpec.Series.Id, dailySearchSpec.AirDate.ToString(Episode.AIR_DATE_FORMAT)); - - if (!remoteEpisode.ParsedEpisodeInfo.IsDaily || remoteEpisode.ParsedEpisodeInfo.AirDate != episode.AirDate) - { - _logger.Debug("Episode AirDate does not match searched episode number, skipping."); - return Decision.Reject("Episode does not match"); - } - - return Decision.Accept(); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/EpisodeRequestedSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/EpisodeRequestedSpecification.cs deleted file mode 100644 index 60640442f..000000000 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/EpisodeRequestedSpecification.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Linq; -using NLog; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Parser.Model; - - -namespace NzbDrone.Core.DecisionEngine.Specifications.Search -{ - public class EpisodeRequestedSpecification : IDecisionEngineSpecification - { - private readonly Logger _logger; - - public EpisodeRequestedSpecification(Logger logger) - { - _logger = logger; - } - - public RejectionType Type => RejectionType.Permanent; - - public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria) - { - if (searchCriteria == null) - { - return Decision.Accept(); - } - - var criteriaEpisodes = searchCriteria.Episodes.Select(v => v.Id).ToList(); - var remoteEpisodes = remoteEpisode.Episodes.Select(v => v.Id).ToList(); - - if (!criteriaEpisodes.Intersect(remoteEpisodes).Any()) - { - _logger.Debug("Release rejected since the episode wasn't requested: {0}", remoteEpisode.ParsedEpisodeInfo); - return Decision.Reject("Episode wasn't requested"); - } - - return Decision.Accept(); - } - } -} diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SeasonMatchSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SeasonMatchSpecification.cs index b09d888ec..0a78db5e6 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SeasonMatchSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SeasonMatchSpecification.cs @@ -1,3 +1,4 @@ +using System; using NLog; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; @@ -15,23 +16,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search public RejectionType Type => RejectionType.Permanent; - public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) { - if (searchCriteria == null) - { - return Decision.Accept(); - } - - var singleEpisodeSpec = searchCriteria as SeasonSearchCriteria; - if (singleEpisodeSpec == null) return Decision.Accept(); - - if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber) - { - _logger.Debug("Season number does not match searched season number, skipping."); - return Decision.Reject("Wrong season"); - } - - return Decision.Accept(); + throw new NotImplementedException(); } } } \ No newline at end of file diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SeriesSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SeriesSpecification.cs deleted file mode 100644 index 7f1201b33..000000000 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SeriesSpecification.cs +++ /dev/null @@ -1,36 +0,0 @@ -using NLog; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.DecisionEngine.Specifications.Search -{ - public class SeriesSpecification : IDecisionEngineSpecification - { - private readonly Logger _logger; - - public SeriesSpecification(Logger logger) - { - _logger = logger; - } - - public RejectionType Type => RejectionType.Permanent; - - public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria) - { - if (searchCriteria == null) - { - return Decision.Accept(); - } - - _logger.Debug("Checking if series matches searched series"); - - if (remoteEpisode.Series.Id != searchCriteria.Series.Id) - { - _logger.Debug("Series {0} does not match {1}", remoteEpisode.Series, searchCriteria.Series); - return Decision.Reject("Wrong series"); - } - - return Decision.Accept(); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleAlbumSearchMatchSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleAlbumSearchMatchSpecification.cs new file mode 100644 index 000000000..08919597d --- /dev/null +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleAlbumSearchMatchSpecification.cs @@ -0,0 +1,48 @@ +using System; +using System.Linq; +using NLog; +using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Parser.Model; + +namespace NzbDrone.Core.DecisionEngine.Specifications.Search +{ + public class SingleAlbumSearchMatchSpecification : IDecisionEngineSpecification + { + private readonly Logger _logger; + + public SingleAlbumSearchMatchSpecification(Logger logger) + { + _logger = logger; + } + + public RejectionType Type => RejectionType.Permanent; + + public virtual Decision IsSatisfiedBy(RemoteAlbum remoteAlbum, SearchCriteriaBase searchCriteria) + { + if (searchCriteria == null) + { + return Decision.Accept(); + } + + var singleAlbumSpec = searchCriteria as AlbumSearchCriteria; + if (singleAlbumSpec == null) + { + return Decision.Accept(); + } + + if (Parser.Parser.CleanArtistTitle(singleAlbumSpec.AlbumTitle) != Parser.Parser.CleanArtistTitle(remoteAlbum.ParsedAlbumInfo.AlbumTitle)) + { + _logger.Debug("Album does not match searched album title, skipping."); + return Decision.Reject("Wrong album"); + } + + if (!remoteAlbum.ParsedAlbumInfo.AlbumTitle.Any()) + { + _logger.Debug("Full discography result during single album search, skipping."); + return Decision.Reject("Full artist pack"); + } + + return Decision.Accept(); + } + } +} \ No newline at end of file diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleEpisodeSearchMatchSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleEpisodeSearchMatchSpecification.cs deleted file mode 100644 index fb056734f..000000000 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleEpisodeSearchMatchSpecification.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Linq; -using NLog; -using NzbDrone.Core.IndexerSearch.Definitions; -using NzbDrone.Core.Parser.Model; - -namespace NzbDrone.Core.DecisionEngine.Specifications.Search -{ - public class SingleEpisodeSearchMatchSpecification : IDecisionEngineSpecification - { - private readonly Logger _logger; - - public SingleEpisodeSearchMatchSpecification(Logger logger) - { - _logger = logger; - } - - public RejectionType Type => RejectionType.Permanent; - - public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria) - { - if (searchCriteria == null) - { - return Decision.Accept(); - } - - var singleEpisodeSpec = searchCriteria as SingleEpisodeSearchCriteria; - if (singleEpisodeSpec == null) return Decision.Accept(); - - if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber) - { - _logger.Debug("Season number does not match searched season number, skipping."); - return Decision.Reject("Wrong season"); - } - - if (!remoteEpisode.ParsedEpisodeInfo.EpisodeNumbers.Any()) - { - _logger.Debug("Full season result during single episode search, skipping."); - return Decision.Reject("Full season pack"); - } - - if (!remoteEpisode.ParsedEpisodeInfo.EpisodeNumbers.Contains(singleEpisodeSpec.EpisodeNumber)) - { - _logger.Debug("Episode number does not match searched episode number, skipping."); - return Decision.Reject("Wrong episode"); - } - - return Decision.Accept(); - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/TorrentSeedingSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/TorrentSeedingSpecification.cs index 87c244b53..3ceb3ef1a 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/Search/TorrentSeedingSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/Search/TorrentSeedingSpecification.cs @@ -1,4 +1,4 @@ -using NLog; +using NLog; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; @@ -15,10 +15,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search public RejectionType Type => RejectionType.Permanent; - - public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria) + public Decision IsSatisfiedBy(RemoteAlbum remoteAlbum, SearchCriteriaBase searchCriteria) { - var torrentInfo = remoteEpisode.Release as TorrentInfo; + var torrentInfo = remoteAlbum.Release as TorrentInfo; if (torrentInfo == null) { diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradeDiskSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradeDiskSpecification.cs index 427a4cd4f..f5e75c7db 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradeDiskSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradeDiskSpecification.cs @@ -1,39 +1,44 @@ -using System.Linq; +using System; +using System.Linq; using NLog; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.MediaFiles; namespace NzbDrone.Core.DecisionEngine.Specifications { public class UpgradeDiskSpecification : IDecisionEngineSpecification { + private readonly IMediaFileService _mediaFileService; private readonly QualityUpgradableSpecification _qualityUpgradableSpecification; private readonly Logger _logger; - public UpgradeDiskSpecification(QualityUpgradableSpecification qualityUpgradableSpecification, Logger logger) + public UpgradeDiskSpecification(QualityUpgradableSpecification qualityUpgradableSpecification, IMediaFileService mediaFileService, Logger logger) { _qualityUpgradableSpecification = qualityUpgradableSpecification; + _mediaFileService = mediaFileService; _logger = logger; } public RejectionType Type => RejectionType.Permanent; - public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) + public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria) { - foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value)) - { - if(file == null) - { - _logger.Debug("File is no longer available, skipping this file."); - continue; - } - _logger.Debug("Comparing file quality with report. Existing file is {0}", file.Quality); + foreach (var album in subject.Albums) + { + var trackFiles = _mediaFileService.GetFilesByAlbum(album.ArtistId, album.Id); - if (!_qualityUpgradableSpecification.IsUpgradable(subject.Series.Profile, file.Quality, subject.ParsedEpisodeInfo.Quality)) + if (trackFiles.Any()) { - return Decision.Reject("Quality for existing file on disk is of equal or higher preference: {0}", file.Quality); + var lowestQuality = trackFiles.Select(c => c.Quality).OrderBy(c => c.Quality.Id).First(); + + if (!_qualityUpgradableSpecification.IsUpgradable(subject.Artist.Profile, lowestQuality, subject.ParsedAlbumInfo.Quality)) + { + return Decision.Reject("Quality for existing file on disk is of equal or higher preference: {0}", lowestQuality); + } } + } return Decision.Accept(); diff --git a/src/NzbDrone.Core/Download/Clients/Blackhole/TorrentBlackhole.cs b/src/NzbDrone.Core/Download/Clients/Blackhole/TorrentBlackhole.cs index 0e5406a88..4eef97920 100644 --- a/src/NzbDrone.Core/Download/Clients/Blackhole/TorrentBlackhole.cs +++ b/src/NzbDrone.Core/Download/Clients/Blackhole/TorrentBlackhole.cs @@ -38,14 +38,14 @@ namespace NzbDrone.Core.Download.Clients.Blackhole ScanGracePeriod = TimeSpan.FromSeconds(30); } - protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) + protected override string AddFromMagnetLink(RemoteAlbum remoteAlbum, string hash, string magnetLink) { if (!Settings.SaveMagnetFiles) { throw new NotSupportedException("Blackhole does not support magnet links."); } - var title = remoteEpisode.Release.Title; + var title = remoteAlbum.Release.Title; title = FileNameBuilder.CleanFileName(title); @@ -62,9 +62,9 @@ namespace NzbDrone.Core.Download.Clients.Blackhole return null; } - protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) + protected override string AddFromTorrentFile(RemoteAlbum remoteAlbum, string hash, string filename, byte[] fileContent) { - var title = remoteEpisode.Release.Title; + var title = remoteAlbum.Release.Title; title = FileNameBuilder.CleanFileName(title); diff --git a/src/NzbDrone.Core/Download/Clients/Blackhole/UsenetBlackhole.cs b/src/NzbDrone.Core/Download/Clients/Blackhole/UsenetBlackhole.cs index 9355518fb..5181fee64 100644 --- a/src/NzbDrone.Core/Download/Clients/Blackhole/UsenetBlackhole.cs +++ b/src/NzbDrone.Core/Download/Clients/Blackhole/UsenetBlackhole.cs @@ -32,9 +32,9 @@ namespace NzbDrone.Core.Download.Clients.Blackhole ScanGracePeriod = TimeSpan.FromSeconds(30); } - protected override string AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContent) + protected override string AddFromNzbFile(RemoteAlbum remoteAlbum, string filename, byte[] fileContent) { - var title = remoteEpisode.Release.Title; + var title = remoteAlbum.Release.Title; title = FileNameBuilder.CleanFileName(title); diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs index 266776fb7..a8bf1e336 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs @@ -31,7 +31,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge _proxy = proxy; } - protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) + protected override string AddFromMagnetLink(RemoteAlbum remoteAlbum, string hash, string magnetLink) { var actualHash = _proxy.AddTorrentFromMagnet(magnetLink, Settings); @@ -42,10 +42,10 @@ namespace NzbDrone.Core.Download.Clients.Deluge _proxy.SetTorrentConfiguration(actualHash, "remove_at_ratio", false, Settings); - var isRecentEpisode = remoteEpisode.IsRecentEpisode(); + var isRecentAlbum = remoteAlbum.IsRecentAlbum(); - if (isRecentEpisode && Settings.RecentTvPriority == (int)DelugePriority.First || - !isRecentEpisode && Settings.OlderTvPriority == (int)DelugePriority.First) + if (isRecentAlbum && Settings.RecentTvPriority == (int)DelugePriority.First || + !isRecentAlbum && Settings.OlderTvPriority == (int)DelugePriority.First) { _proxy.MoveTorrentToTopInQueue(actualHash, Settings); } @@ -53,7 +53,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge return actualHash.ToUpper(); } - protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) + protected override string AddFromTorrentFile(RemoteAlbum remoteAlbum, string hash, string filename, byte[] fileContent) { var actualHash = _proxy.AddTorrentFromFile(filename, fileContent, Settings); @@ -64,7 +64,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge _proxy.SetTorrentConfiguration(actualHash, "remove_at_ratio", false, Settings); - var isRecentEpisode = remoteEpisode.IsRecentEpisode(); + var isRecentEpisode = remoteAlbum.IsRecentAlbum(); if (isRecentEpisode && Settings.RecentTvPriority == (int)DelugePriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)DelugePriority.First) diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs index 36e89a84b..20615515f 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs @@ -146,7 +146,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation return finalPath; } - protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) + protected override string AddFromMagnetLink(RemoteAlbum remoteAlbum, string hash, string magnetLink) { var hashedSerialNumber = _serialNumberProvider.GetSerialNumber(Settings); @@ -156,7 +156,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation if (item != null) { - _logger.Debug("{0} added correctly", remoteEpisode); + _logger.Debug("{0} added correctly", remoteAlbum); return CreateDownloadId(item.Id, hashedSerialNumber); } @@ -165,7 +165,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation throw new DownloadClientException("Failed to add magnet task to Download Station"); } - protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) + protected override string AddFromTorrentFile(RemoteAlbum remoteAlbum, string hash, string filename, byte[] fileContent) { var hashedSerialNumber = _serialNumberProvider.GetSerialNumber(Settings); @@ -177,7 +177,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation if (item != null) { - _logger.Debug("{0} added correctly", remoteEpisode); + _logger.Debug("{0} added correctly", remoteAlbum); return CreateDownloadId(item.Id, hashedSerialNumber); } diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs index 9aa916b7a..3a44405ae 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs @@ -160,7 +160,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation _logger.Debug("{0} removed correctly", downloadId); } - protected override string AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContent) + protected override string AddFromNzbFile(RemoteAlbum remoteAlbum, string filename, byte[] fileContent) { var hashedSerialNumber = _serialNumberProvider.GetSerialNumber(Settings); @@ -172,7 +172,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation if (item != null) { - _logger.Debug("{0} added correctly", remoteEpisode); + _logger.Debug("{0} added correctly", remoteAlbum); return CreateDownloadId(item.Id, hashedSerialNumber); } diff --git a/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs b/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs index 5727dea8b..ac629b63b 100644 --- a/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs +++ b/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs @@ -149,14 +149,14 @@ namespace NzbDrone.Core.Download.Clients.Hadouken failures.AddIfNotNull(TestGetTorrents()); } - protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) + protected override string AddFromMagnetLink(RemoteAlbum remoteAlbum, string hash, string magnetLink) { _proxy.AddTorrentUri(Settings, magnetLink); return hash.ToUpper(); } - protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) + protected override string AddFromTorrentFile(RemoteAlbum remoteAlbum, string hash, string filename, byte[] fileContent) { return _proxy.AddTorrentFile(Settings, fileContent).ToUpper(); } diff --git a/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs b/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs index dc3595615..b5a07c980 100644 --- a/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs +++ b/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs @@ -29,9 +29,9 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex _proxy = proxy; } - protected override string AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContent) + protected override string AddFromNzbFile(RemoteAlbum remoteAlbum, string filename, byte[] fileContent) { - var priority = remoteEpisode.IsRecentEpisode() ? Settings.RecentTvPriority : Settings.OlderTvPriority; + var priority = remoteAlbum.IsRecentAlbum() ? Settings.RecentTvPriority : Settings.OlderTvPriority; var response = _proxy.DownloadNzb(fileContent, filename, priority, Settings); diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs index f5f3f2c01..746e4d259 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs @@ -31,11 +31,11 @@ namespace NzbDrone.Core.Download.Clients.Nzbget _proxy = proxy; } - protected override string AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContent) + protected override string AddFromNzbFile(RemoteAlbum remoteAlbum, string filename, byte[] fileContent) { var category = Settings.TvCategory; - var priority = remoteEpisode.IsRecentEpisode() ? Settings.RecentTvPriority : Settings.OlderTvPriority; + var priority = remoteAlbum.IsRecentAlbum() ? Settings.RecentTvPriority : Settings.OlderTvPriority; var addpaused = Settings.AddPaused; diff --git a/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs b/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs index 5eab58b3b..8337fac9b 100644 --- a/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs +++ b/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs @@ -32,15 +32,10 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic public override DownloadProtocol Protocol => DownloadProtocol.Usenet; - public override string Download(RemoteEpisode remoteEpisode) + public override string Download(RemoteAlbum remoteAlbum) { - var url = remoteEpisode.Release.DownloadUrl; - var title = remoteEpisode.Release.Title; - - if (remoteEpisode.ParsedEpisodeInfo.FullSeason) - { - throw new NotSupportedException("Full season releases are not supported with Pneumatic."); - } + var url = remoteAlbum.Release.DownloadUrl; + var title = remoteAlbum.Release.Title; title = FileNameBuilder.CleanFileName(title); diff --git a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs index 852cbff06..b589aa19d 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs @@ -31,7 +31,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent _proxy = proxy; } - protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) + protected override string AddFromMagnetLink(RemoteAlbum remoteAlbum, string hash, string magnetLink) { _proxy.AddTorrentFromUrl(magnetLink, Settings); @@ -40,7 +40,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent _proxy.SetTorrentLabel(hash.ToLower(), Settings.TvCategory, Settings); } - var isRecentEpisode = remoteEpisode.IsRecentEpisode(); + var isRecentEpisode = remoteAlbum.IsRecentAlbum(); if (isRecentEpisode && Settings.RecentTvPriority == (int)QBittorrentPriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)QBittorrentPriority.First) @@ -51,7 +51,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent return hash; } - protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, Byte[] fileContent) + protected override string AddFromTorrentFile(RemoteAlbum remoteAlbum, string hash, string filename, Byte[] fileContent) { _proxy.AddTorrentFromFile(filename, fileContent, Settings); @@ -60,7 +60,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent _proxy.SetTorrentLabel(hash.ToLower(), Settings.TvCategory, Settings); } - var isRecentEpisode = remoteEpisode.IsRecentEpisode(); + var isRecentEpisode = remoteAlbum.IsRecentAlbum(); if (isRecentEpisode && Settings.RecentTvPriority == (int)QBittorrentPriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)QBittorrentPriority.First) diff --git a/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs b/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs index 3c874d978..27ecc4cf9 100644 --- a/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs +++ b/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs @@ -32,10 +32,10 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd // patch can be a number (releases) or 'x' (git) private static readonly Regex VersionRegex = new Regex(@"(?\d+)\.(?\d+)\.(?\d+|x)", RegexOptions.Compiled); - protected override string AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContent) + protected override string AddFromNzbFile(RemoteAlbum remoteAlbum, string filename, byte[] fileContent) { var category = Settings.TvCategory; - var priority = remoteEpisode.IsRecentEpisode() ? Settings.RecentTvPriority : Settings.OlderTvPriority; + var priority = remoteAlbum.IsRecentAlbum() ? Settings.RecentTvPriority : Settings.OlderTvPriority; var response = _proxy.DownloadNzb(fileContent, filename, category, priority, Settings); diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs index 6f6b2c956..2185c03f0 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs @@ -135,11 +135,11 @@ namespace NzbDrone.Core.Download.Clients.Transmission }; } - protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) + protected override string AddFromMagnetLink(RemoteAlbum remoteAlbum, string hash, string magnetLink) { _proxy.AddTorrentFromUrl(magnetLink, GetDownloadDirectory(), Settings); - var isRecentEpisode = remoteEpisode.IsRecentEpisode(); + var isRecentEpisode = remoteAlbum.IsRecentAlbum(); if (isRecentEpisode && Settings.RecentTvPriority == (int)TransmissionPriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)TransmissionPriority.First) @@ -150,11 +150,11 @@ namespace NzbDrone.Core.Download.Clients.Transmission return hash; } - protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) + protected override string AddFromTorrentFile(RemoteAlbum remoteAlbum, string hash, string filename, byte[] fileContent) { _proxy.AddTorrentFromData(fileContent, GetDownloadDirectory(), Settings); - var isRecentEpisode = remoteEpisode.IsRecentEpisode(); + var isRecentEpisode = remoteAlbum.IsRecentAlbum(); if (isRecentEpisode && Settings.RecentTvPriority == (int)TransmissionPriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)TransmissionPriority.First) diff --git a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs index d397f03b2..bd44f7bf7 100644 --- a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs @@ -37,9 +37,9 @@ namespace NzbDrone.Core.Download.Clients.RTorrent _rTorrentDirectoryValidator = rTorrentDirectoryValidator; } - protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) + protected override string AddFromMagnetLink(RemoteAlbum remoteAlbum, string hash, string magnetLink) { - var priority = (RTorrentPriority)(remoteEpisode.IsRecentEpisode() ? Settings.RecentTvPriority : Settings.OlderTvPriority); + var priority = (RTorrentPriority)(remoteAlbum.IsRecentAlbum() ? Settings.RecentTvPriority : Settings.OlderTvPriority); _proxy.AddTorrentFromUrl(magnetLink, Settings.TvCategory, priority, Settings.TvDirectory, Settings); @@ -57,9 +57,9 @@ namespace NzbDrone.Core.Download.Clients.RTorrent return hash; } - protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) + protected override string AddFromTorrentFile(RemoteAlbum remoteEpisode, string hash, string filename, byte[] fileContent) { - var priority = (RTorrentPriority)(remoteEpisode.IsRecentEpisode() ? Settings.RecentTvPriority : Settings.OlderTvPriority); + var priority = (RTorrentPriority)(remoteEpisode.IsRecentAlbum() ? Settings.RecentTvPriority : Settings.OlderTvPriority); _proxy.AddTorrentFromFile(filename, fileContent, Settings.TvCategory, priority, Settings.TvDirectory, Settings); diff --git a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs index 8f442eb7b..a565d747a 100644 --- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs @@ -36,12 +36,12 @@ namespace NzbDrone.Core.Download.Clients.UTorrent _torrentCache = cacheManager.GetCache(GetType(), "differentialTorrents"); } - protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) + protected override string AddFromMagnetLink(RemoteAlbum remoteAlbum, string hash, string magnetLink) { _proxy.AddTorrentFromUrl(magnetLink, Settings); _proxy.SetTorrentLabel(hash, Settings.TvCategory, Settings); - var isRecentEpisode = remoteEpisode.IsRecentEpisode(); + var isRecentEpisode = remoteAlbum.IsRecentAlbum(); if (isRecentEpisode && Settings.RecentTvPriority == (int)UTorrentPriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)UTorrentPriority.First) @@ -52,12 +52,12 @@ namespace NzbDrone.Core.Download.Clients.UTorrent return hash; } - protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) + protected override string AddFromTorrentFile(RemoteAlbum remoteAlbum, string hash, string filename, byte[] fileContent) { _proxy.AddTorrentFromFile(filename, fileContent, Settings); _proxy.SetTorrentLabel(hash, Settings.TvCategory, Settings); - var isRecentEpisode = remoteEpisode.IsRecentEpisode(); + var isRecentEpisode = remoteAlbum.IsRecentAlbum(); if (isRecentEpisode && Settings.RecentTvPriority == (int)UTorrentPriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)UTorrentPriority.First) diff --git a/src/NzbDrone.Core/Download/CompletedDownloadService.cs b/src/NzbDrone.Core/Download/CompletedDownloadService.cs index d9a48965c..2e4589ecb 100644 --- a/src/NzbDrone.Core/Download/CompletedDownloadService.cs +++ b/src/NzbDrone.Core/Download/CompletedDownloadService.cs @@ -95,7 +95,7 @@ namespace NzbDrone.Core.Download { if (historyItem != null) { - series = _seriesService.GetSeries(historyItem.SeriesId); + series = _seriesService.GetSeries(historyItem.ArtistId); } if (series == null) diff --git a/src/NzbDrone.Core/Download/DownloadClientBase.cs b/src/NzbDrone.Core/Download/DownloadClientBase.cs index 49f9c4207..e557f735e 100644 --- a/src/NzbDrone.Core/Download/DownloadClientBase.cs +++ b/src/NzbDrone.Core/Download/DownloadClientBase.cs @@ -57,7 +57,7 @@ namespace NzbDrone.Core.Download get; } - public abstract string Download(RemoteEpisode remoteEpisode); + public abstract string Download(RemoteAlbum remoteAlbum); public abstract IEnumerable GetItems(); public abstract void RemoveItem(string downloadId, bool deleteData); public abstract DownloadClientStatus GetStatus(); diff --git a/src/NzbDrone.Core/Download/DownloadFailedEvent.cs b/src/NzbDrone.Core/Download/DownloadFailedEvent.cs index 1c0ca855a..47e2d6349 100644 --- a/src/NzbDrone.Core/Download/DownloadFailedEvent.cs +++ b/src/NzbDrone.Core/Download/DownloadFailedEvent.cs @@ -12,8 +12,12 @@ namespace NzbDrone.Core.Download Data = new Dictionary(); } + [System.Obsolete("Used for sonarr, not lidarr")] public int SeriesId { get; set; } + public int ArtistId { get; set; } + [System.Obsolete("Used for sonarr, not lidarr")] public List EpisodeIds { get; set; } + public List AlbumIds { get; set; } public QualityModel Quality { get; set; } public string SourceTitle { get; set; } public string DownloadClient { get; set; } diff --git a/src/NzbDrone.Core/Download/DownloadService.cs b/src/NzbDrone.Core/Download/DownloadService.cs index 4f76b1507..c4f1e155e 100644 --- a/src/NzbDrone.Core/Download/DownloadService.cs +++ b/src/NzbDrone.Core/Download/DownloadService.cs @@ -14,10 +14,9 @@ namespace NzbDrone.Core.Download { public interface IDownloadService { - void DownloadReport(RemoteEpisode remoteEpisode); + void DownloadReport(RemoteAlbum remoteAlbum); } - public class DownloadService : IDownloadService { private readonly IProvideDownloadClient _downloadClientProvider; @@ -39,57 +38,57 @@ namespace NzbDrone.Core.Download _logger = logger; } - public void DownloadReport(RemoteEpisode remoteEpisode) + public void DownloadReport(RemoteAlbum remoteAlbum) { - Ensure.That(remoteEpisode.Series, () => remoteEpisode.Series).IsNotNull(); - Ensure.That(remoteEpisode.Episodes, () => remoteEpisode.Episodes).HasItems(); + Ensure.That(remoteAlbum.Artist, () => remoteAlbum.Artist).IsNotNull(); + Ensure.That(remoteAlbum.Albums, () => remoteAlbum.Albums).HasItems(); - var downloadTitle = remoteEpisode.Release.Title; - var downloadClient = _downloadClientProvider.GetDownloadClient(remoteEpisode.Release.DownloadProtocol); + var downloadTitle = remoteAlbum.Release.Title; + var downloadClient = _downloadClientProvider.GetDownloadClient(remoteAlbum.Release.DownloadProtocol); if (downloadClient == null) { - _logger.Warn("{0} Download client isn't configured yet.", remoteEpisode.Release.DownloadProtocol); + _logger.Warn("{0} Download client isn't configured yet.", remoteAlbum.Release.DownloadProtocol); return; } // Limit grabs to 2 per second. - if (remoteEpisode.Release.DownloadUrl.IsNotNullOrWhiteSpace() && !remoteEpisode.Release.DownloadUrl.StartsWith("magnet:")) + if (remoteAlbum.Release.DownloadUrl.IsNotNullOrWhiteSpace() && !remoteAlbum.Release.DownloadUrl.StartsWith("magnet:")) { - var url = new HttpUri(remoteEpisode.Release.DownloadUrl); + var url = new HttpUri(remoteAlbum.Release.DownloadUrl); _rateLimitService.WaitAndPulse(url.Host, TimeSpan.FromSeconds(2)); } string downloadClientId; try { - downloadClientId = downloadClient.Download(remoteEpisode); - _indexerStatusService.RecordSuccess(remoteEpisode.Release.IndexerId); + downloadClientId = downloadClient.Download(remoteAlbum); + _indexerStatusService.RecordSuccess(remoteAlbum.Release.IndexerId); } catch (ReleaseDownloadException ex) { var http429 = ex.InnerException as TooManyRequestsException; if (http429 != null) { - _indexerStatusService.RecordFailure(remoteEpisode.Release.IndexerId, http429.RetryAfter); + _indexerStatusService.RecordFailure(remoteAlbum.Release.IndexerId, http429.RetryAfter); } else { - _indexerStatusService.RecordFailure(remoteEpisode.Release.IndexerId); + _indexerStatusService.RecordFailure(remoteAlbum.Release.IndexerId); } throw; } - var episodeGrabbedEvent = new EpisodeGrabbedEvent(remoteEpisode); - episodeGrabbedEvent.DownloadClient = downloadClient.GetType().Name; + var albumGrabbedEvent = new AlbumGrabbedEvent(remoteAlbum); + albumGrabbedEvent.DownloadClient = downloadClient.GetType().Name; if (!string.IsNullOrWhiteSpace(downloadClientId)) { - episodeGrabbedEvent.DownloadId = downloadClientId; + albumGrabbedEvent.DownloadId = downloadClientId; } _logger.ProgressInfo("Report sent to {0}. {1}", downloadClient.Definition.Name, downloadTitle); - _eventAggregator.PublishEvent(episodeGrabbedEvent); + _eventAggregator.PublishEvent(albumGrabbedEvent); } } } \ No newline at end of file diff --git a/src/NzbDrone.Core/Download/FailedDownloadService.cs b/src/NzbDrone.Core/Download/FailedDownloadService.cs index d55fd0b22..935401864 100644 --- a/src/NzbDrone.Core/Download/FailedDownloadService.cs +++ b/src/NzbDrone.Core/Download/FailedDownloadService.cs @@ -87,8 +87,8 @@ namespace NzbDrone.Core.Download var downloadFailedEvent = new DownloadFailedEvent { - SeriesId = historyItem.SeriesId, - EpisodeIds = historyItems.Select(h => h.EpisodeId).ToList(), + ArtistId = historyItem.ArtistId, + AlbumIds = historyItems.Select(h => h.AlbumId).ToList(), Quality = historyItem.Quality, SourceTitle = historyItem.SourceTitle, DownloadClient = historyItem.Data.GetValueOrDefault(History.History.DOWNLOAD_CLIENT), diff --git a/src/NzbDrone.Core/Download/IDownloadClient.cs b/src/NzbDrone.Core/Download/IDownloadClient.cs index 6703d8a22..b16555dcf 100644 --- a/src/NzbDrone.Core/Download/IDownloadClient.cs +++ b/src/NzbDrone.Core/Download/IDownloadClient.cs @@ -9,7 +9,7 @@ namespace NzbDrone.Core.Download { DownloadProtocol Protocol { get; } - string Download(RemoteEpisode remoteEpisode); + string Download(RemoteAlbum remoteAlbum); IEnumerable GetItems(); void RemoveItem(string downloadId, bool deleteData); DownloadClientStatus GetStatus(); diff --git a/src/NzbDrone.Core/Download/Pending/PendingRelease.cs b/src/NzbDrone.Core/Download/Pending/PendingRelease.cs index a713fe48c..976d9ae38 100644 --- a/src/NzbDrone.Core/Download/Pending/PendingRelease.cs +++ b/src/NzbDrone.Core/Download/Pending/PendingRelease.cs @@ -6,13 +6,14 @@ namespace NzbDrone.Core.Download.Pending { public class PendingRelease : ModelBase { - public int SeriesId { get; set; } + public int ArtistId { get; set; } public string Title { get; set; } public DateTime Added { get; set; } - public ParsedEpisodeInfo ParsedEpisodeInfo { get; set; } + public ParsedAlbumInfo ParsedAlbumInfo { get; set; } public ReleaseInfo Release { get; set; } //Not persisted public RemoteEpisode RemoteEpisode { get; set; } + public RemoteAlbum RemoteAlbum { get; set; } } } diff --git a/src/NzbDrone.Core/Download/Pending/PendingReleaseRepository.cs b/src/NzbDrone.Core/Download/Pending/PendingReleaseRepository.cs index b98334978..50e670721 100644 --- a/src/NzbDrone.Core/Download/Pending/PendingReleaseRepository.cs +++ b/src/NzbDrone.Core/Download/Pending/PendingReleaseRepository.cs @@ -6,8 +6,8 @@ namespace NzbDrone.Core.Download.Pending { public interface IPendingReleaseRepository : IBasicRepository { - void DeleteBySeriesId(int seriesId); - List AllBySeriesId(int seriesId); + void DeleteByArtistId(int artistId); + List AllByArtistId(int artistId); } public class PendingReleaseRepository : BasicRepository, IPendingReleaseRepository @@ -17,14 +17,14 @@ namespace NzbDrone.Core.Download.Pending { } - public void DeleteBySeriesId(int seriesId) + public void DeleteByArtistId(int artistId) { - Delete(r => r.SeriesId == seriesId); + Delete(r => r.ArtistId == artistId); } - public List AllBySeriesId(int seriesId) + public List AllByArtistId(int artistId) { - return Query.Where(p => p.SeriesId == seriesId); + return Query.Where(p => p.ArtistId == artistId); } } } \ No newline at end of file diff --git a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs index 8585a1704..d978b759d 100644 --- a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs +++ b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using NLog; +using NLog; using NzbDrone.Common.Crypto; using NzbDrone.Common.Extensions; using NzbDrone.Core.Configuration; @@ -13,8 +10,11 @@ using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles.Delay; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Tv.Events; +using NzbDrone.Core.Music; +using NzbDrone.Core.Music.Events; +using System; +using System.Collections.Generic; +using System.Linq; namespace NzbDrone.Core.Download.Pending { @@ -23,21 +23,21 @@ namespace NzbDrone.Core.Download.Pending void Add(DownloadDecision decision); List GetPending(); - List GetPendingRemoteEpisodes(int seriesId); + List GetPendingRemoteAlbums(int artistId); List GetPendingQueue(); Queue.Queue FindPendingQueueItem(int queueId); void RemovePendingQueueItems(int queueId); - RemoteEpisode OldestPendingRelease(int seriesId, IEnumerable episodeIds); + RemoteAlbum OldestPendingRelease(int artistId, IEnumerable albumIds); } public class PendingReleaseService : IPendingReleaseService, - IHandle, - IHandle, + IHandle, + IHandle, IHandle { private readonly IIndexerStatusService _indexerStatusService; private readonly IPendingReleaseRepository _repository; - private readonly ISeriesService _seriesService; + private readonly IArtistService _artistService; private readonly IParsingService _parsingService; private readonly IDelayProfileService _delayProfileService; private readonly ITaskManager _taskManager; @@ -47,7 +47,7 @@ namespace NzbDrone.Core.Download.Pending public PendingReleaseService(IIndexerStatusService indexerStatusService, IPendingReleaseRepository repository, - ISeriesService seriesService, + IArtistService artistService, IParsingService parsingService, IDelayProfileService delayProfileService, ITaskManager taskManager, @@ -57,7 +57,7 @@ namespace NzbDrone.Core.Download.Pending { _indexerStatusService = indexerStatusService; _repository = repository; - _seriesService = seriesService; + _artistService = artistService; _parsingService = parsingService; _delayProfileService = delayProfileService; _taskManager = taskManager; @@ -71,13 +71,13 @@ namespace NzbDrone.Core.Download.Pending { var alreadyPending = GetPendingReleases(); - var episodeIds = decision.RemoteEpisode.Episodes.Select(e => e.Id); + var albumIds = decision.RemoteAlbum.Albums.Select(e => e.Id); - var existingReports = alreadyPending.Where(r => r.RemoteEpisode.Episodes.Select(e => e.Id) - .Intersect(episodeIds) + var existingReports = alreadyPending.Where(r => r.RemoteAlbum.Albums.Select(e => e.Id) + .Intersect(albumIds) .Any()); - if (existingReports.Any(MatchingReleasePredicate(decision.RemoteEpisode.Release))) + if (existingReports.Any(MatchingReleasePredicate(decision.RemoteAlbum.Release))) { _logger.Debug("This release is already pending, not adding again"); return; @@ -106,9 +106,9 @@ namespace NzbDrone.Core.Download.Pending return releases.Where(release => !blockedIndexers.Contains(release.IndexerId)).ToList(); } - public List GetPendingRemoteEpisodes(int seriesId) + public List GetPendingRemoteAlbums(int artistId) { - return _repository.AllBySeriesId(seriesId).Select(GetRemoteEpisode).ToList(); + return _repository.AllByArtistId(artistId).Select(GetRemoteAlbum).ToList(); } public List GetPendingQueue() @@ -119,9 +119,9 @@ namespace NzbDrone.Core.Download.Pending foreach (var pendingRelease in GetPendingReleases()) { - foreach (var episode in pendingRelease.RemoteEpisode.Episodes) + foreach (var album in pendingRelease.RemoteAlbum.Albums) { - var ect = pendingRelease.Release.PublishDate.AddMinutes(GetDelay(pendingRelease.RemoteEpisode)); + var ect = pendingRelease.Release.PublishDate.AddMinutes(GetDelay(pendingRelease.RemoteAlbum)); if (ect < nextRssSync.Value) { @@ -134,30 +134,30 @@ namespace NzbDrone.Core.Download.Pending var queue = new Queue.Queue { - Id = GetQueueId(pendingRelease, episode), - Series = pendingRelease.RemoteEpisode.Series, - Episode = episode, - Quality = pendingRelease.RemoteEpisode.ParsedEpisodeInfo.Quality, + Id = GetQueueId(pendingRelease, album), + Artist = pendingRelease.RemoteAlbum.Artist, + Album = album, + Quality = pendingRelease.RemoteAlbum.ParsedAlbumInfo.Quality, Title = pendingRelease.Title, - Size = pendingRelease.RemoteEpisode.Release.Size, - Sizeleft = pendingRelease.RemoteEpisode.Release.Size, - RemoteEpisode = pendingRelease.RemoteEpisode, + Size = pendingRelease.RemoteAlbum.Release.Size, + Sizeleft = pendingRelease.RemoteAlbum.Release.Size, + RemoteAlbum = pendingRelease.RemoteAlbum, Timeleft = ect.Subtract(DateTime.UtcNow), EstimatedCompletionTime = ect, Status = "Pending", - Protocol = pendingRelease.RemoteEpisode.Release.DownloadProtocol + Protocol = pendingRelease.RemoteAlbum.Release.DownloadProtocol }; queued.Add(queue); } } //Return best quality release for each episode - var deduped = queued.GroupBy(q => q.Episode.Id).Select(g => + var deduped = queued.GroupBy(q => q.Album.Id).Select(g => { - var series = g.First().Series; + var artist = g.First().Artist; - return g.OrderByDescending(e => e.Quality, new QualityModelComparer(series.Profile)) - .ThenBy(q => PrioritizeDownloadProtocol(q.Series, q.Protocol)) + return g.OrderByDescending(e => e.Quality, new QualityModelComparer(artist.Profile)) + .ThenBy(q => PrioritizeDownloadProtocol(q.Artist, q.Protocol)) .First(); }); @@ -172,18 +172,17 @@ namespace NzbDrone.Core.Download.Pending public void RemovePendingQueueItems(int queueId) { var targetItem = FindPendingRelease(queueId); - var seriesReleases = _repository.AllBySeriesId(targetItem.SeriesId); + var artistReleases = _repository.AllByArtistId(targetItem.ArtistId); - var releasesToRemove = seriesReleases.Where( - c => c.ParsedEpisodeInfo.SeasonNumber == targetItem.ParsedEpisodeInfo.SeasonNumber && - c.ParsedEpisodeInfo.EpisodeNumbers.SequenceEqual(targetItem.ParsedEpisodeInfo.EpisodeNumbers)); + var releasesToRemove = artistReleases.Where( + c => c.ParsedAlbumInfo.AlbumTitle == targetItem.ParsedAlbumInfo.AlbumTitle); _repository.DeleteMany(releasesToRemove.Select(c => c.Id)); } - public RemoteEpisode OldestPendingRelease(int seriesId, IEnumerable episodeIds) + public RemoteAlbum OldestPendingRelease(int artistId, IEnumerable albumIds) { - return GetPendingRemoteEpisodes(seriesId).Where(r => r.Episodes.Select(e => e.Id).Intersect(episodeIds).Any()) + return GetPendingRemoteAlbums(artistId).Where(r => r.Albums.Select(e => e.Id).Intersect(albumIds).Any()) .OrderByDescending(p => p.Release.AgeHours) .FirstOrDefault(); } @@ -194,11 +193,14 @@ namespace NzbDrone.Core.Download.Pending foreach (var release in _repository.All()) { - var remoteEpisode = GetRemoteEpisode(release); + var remoteAlbum = GetRemoteAlbum(release); - if (remoteEpisode == null) continue; + if (remoteAlbum == null) + { + continue; + } - release.RemoteEpisode = remoteEpisode; + release.RemoteAlbum = remoteAlbum; result.Add(release); } @@ -206,20 +208,23 @@ namespace NzbDrone.Core.Download.Pending return result; } - private RemoteEpisode GetRemoteEpisode(PendingRelease release) + private RemoteAlbum GetRemoteAlbum(PendingRelease release) { - var series = _seriesService.GetSeries(release.SeriesId); + var artist = _artistService.GetArtist(release.ArtistId); //Just in case the series was removed, but wasn't cleaned up yet (housekeeper will clean it up) - if (series == null) return null; + if (artist == null) + { + return null; + } - var episodes = _parsingService.GetEpisodes(release.ParsedEpisodeInfo, series, true); + var album = _parsingService.GetAlbums(release.ParsedAlbumInfo, artist); - return new RemoteEpisode + return new RemoteAlbum { - Series = series, - Episodes = episodes, - ParsedEpisodeInfo = release.ParsedEpisodeInfo, + Artist = artist, + Albums = album, + ParsedAlbumInfo = release.ParsedAlbumInfo, Release = release.Release }; } @@ -228,10 +233,10 @@ namespace NzbDrone.Core.Download.Pending { _repository.Insert(new PendingRelease { - SeriesId = decision.RemoteEpisode.Series.Id, - ParsedEpisodeInfo = decision.RemoteEpisode.ParsedEpisodeInfo, - Release = decision.RemoteEpisode.Release, - Title = decision.RemoteEpisode.Release.Title, + ArtistId = decision.RemoteAlbum.Artist.Id, + ParsedAlbumInfo = decision.RemoteAlbum.ParsedAlbumInfo, + Release = decision.RemoteAlbum.Release, + Title = decision.RemoteAlbum.Release.Title, Added = DateTime.UtcNow }); @@ -251,22 +256,22 @@ namespace NzbDrone.Core.Download.Pending p.Release.Indexer == release.Indexer; } - private int GetDelay(RemoteEpisode remoteEpisode) + private int GetDelay(RemoteAlbum remoteAlbum) { - var delayProfile = _delayProfileService.AllForTags(remoteEpisode.Series.Tags).OrderBy(d => d.Order).First(); - var delay = delayProfile.GetProtocolDelay(remoteEpisode.Release.DownloadProtocol); + var delayProfile = _delayProfileService.AllForTags(remoteAlbum.Artist.Tags).OrderBy(d => d.Order).First(); + var delay = delayProfile.GetProtocolDelay(remoteAlbum.Release.DownloadProtocol); var minimumAge = _configService.MinimumAge; return new[] { delay, minimumAge }.Max(); } - private void RemoveGrabbed(RemoteEpisode remoteEpisode) + private void RemoveGrabbed(RemoteAlbum remoteAlbum) { var pendingReleases = GetPendingReleases(); - var episodeIds = remoteEpisode.Episodes.Select(e => e.Id); + var albumIds = remoteAlbum.Albums.Select(e => e.Id); - var existingReports = pendingReleases.Where(r => r.RemoteEpisode.Episodes.Select(e => e.Id) - .Intersect(episodeIds) + var existingReports = pendingReleases.Where(r => r.RemoteAlbum.Albums.Select(e => e.Id) + .Intersect(albumIds) .Any()) .ToList(); @@ -275,12 +280,12 @@ namespace NzbDrone.Core.Download.Pending return; } - var profile = remoteEpisode.Series.Profile.Value; + var profile = remoteAlbum.Artist.Profile.Value; foreach (var existingReport in existingReports) { - var compare = new QualityModelComparer(profile).Compare(remoteEpisode.ParsedEpisodeInfo.Quality, - existingReport.RemoteEpisode.ParsedEpisodeInfo.Quality); + var compare = new QualityModelComparer(profile).Compare(remoteAlbum.ParsedAlbumInfo.Quality, + existingReport.RemoteAlbum.ParsedAlbumInfo.Quality); //Only remove lower/equal quality pending releases //It is safer to retry these releases on the next round than remove it and try to re-add it (if its still in the feed) @@ -299,7 +304,7 @@ namespace NzbDrone.Core.Download.Pending foreach (var rejectedRelease in rejected) { - var matching = pending.Where(MatchingReleasePredicate(rejectedRelease.RemoteEpisode.Release)); + var matching = pending.Where(MatchingReleasePredicate(rejectedRelease.RemoteAlbum.Release)); foreach (var pendingRelease in matching) { @@ -311,17 +316,17 @@ namespace NzbDrone.Core.Download.Pending private PendingRelease FindPendingRelease(int queueId) { - return GetPendingReleases().First(p => p.RemoteEpisode.Episodes.Any(e => queueId == GetQueueId(p, e))); + return GetPendingReleases().First(p => p.RemoteAlbum.Albums.Any(e => queueId == GetQueueId(p, e))); } - private int GetQueueId(PendingRelease pendingRelease, Episode episode) + private int GetQueueId(PendingRelease pendingRelease, Album album) { - return HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", pendingRelease.Id, episode.Id)); + return HashConverter.GetHashInt31(string.Format("pending-{0}-album{1}", pendingRelease.Id, album.Id)); } - private int PrioritizeDownloadProtocol(Series series, DownloadProtocol downloadProtocol) + private int PrioritizeDownloadProtocol(Artist artist, DownloadProtocol downloadProtocol) { - var delayProfile = _delayProfileService.BestForTags(series.Tags); + var delayProfile = _delayProfileService.BestForTags(artist.Tags); if (downloadProtocol == delayProfile.PreferredProtocol) { @@ -331,14 +336,14 @@ namespace NzbDrone.Core.Download.Pending return 1; } - public void Handle(SeriesDeletedEvent message) + public void Handle(ArtistDeletedEvent message) { - _repository.DeleteBySeriesId(message.Series.Id); + _repository.DeleteByArtistId(message.Artist.Id); } - public void Handle(EpisodeGrabbedEvent message) + public void Handle(AlbumGrabbedEvent message) { - RemoveGrabbed(message.Episode); + RemoveGrabbed(message.Album); } public void Handle(RssSyncCompleteEvent message) diff --git a/src/NzbDrone.Core/Download/ProcessDownloadDecisions.cs b/src/NzbDrone.Core/Download/ProcessDownloadDecisions.cs index 05719587d..1c82f3253 100644 --- a/src/NzbDrone.Core/Download/ProcessDownloadDecisions.cs +++ b/src/NzbDrone.Core/Download/ProcessDownloadDecisions.cs @@ -39,15 +39,15 @@ namespace NzbDrone.Core.Download foreach (var report in prioritizedDecisions) { - var remoteEpisode = report.RemoteEpisode; + var remoteAlbum = report.RemoteAlbum; - var episodeIds = remoteEpisode.Episodes.Select(e => e.Id).ToList(); + var albumIds = remoteAlbum.Albums.Select(e => e.Id).ToList(); //Skip if already grabbed - if (grabbed.SelectMany(r => r.RemoteEpisode.Episodes) + if (grabbed.SelectMany(r => r.RemoteAlbum.Albums) .Select(e => e.Id) .ToList() - .Intersect(episodeIds) + .Intersect(albumIds) .Any()) { continue; @@ -60,10 +60,10 @@ namespace NzbDrone.Core.Download continue; } - if (pending.SelectMany(r => r.RemoteEpisode.Episodes) + if (pending.SelectMany(r => r.RemoteAlbum.Albums) .Select(e => e.Id) .ToList() - .Intersect(episodeIds) + .Intersect(albumIds) .Any()) { continue; @@ -71,14 +71,14 @@ namespace NzbDrone.Core.Download try { - _downloadService.DownloadReport(remoteEpisode); + _downloadService.DownloadReport(remoteAlbum); grabbed.Add(report); } catch (Exception e) { //TODO: support for store & forward //We'll need to differentiate between a download client error and an indexer error - _logger.Warn(e, "Couldn't add report to download queue. " + remoteEpisode); + _logger.Warn(e, "Couldn't add report to download queue. " + remoteAlbum); } } @@ -88,7 +88,7 @@ namespace NzbDrone.Core.Download internal List GetQualifiedReports(IEnumerable decisions) { //Process both approved and temporarily rejected - return decisions.Where(c => (c.Approved || c.TemporarilyRejected) && c.RemoteEpisode.Episodes.Any()).ToList(); + return decisions.Where(c => (c.Approved || c.TemporarilyRejected) && c.RemoteAlbum.Albums.Any()).ToList(); } } } diff --git a/src/NzbDrone.Core/Download/TorrentClientBase.cs b/src/NzbDrone.Core/Download/TorrentClientBase.cs index d48fc6e9c..8e89979f6 100644 --- a/src/NzbDrone.Core/Download/TorrentClientBase.cs +++ b/src/NzbDrone.Core/Download/TorrentClientBase.cs @@ -38,23 +38,23 @@ namespace NzbDrone.Core.Download public virtual bool PreferTorrentFile => false; - protected abstract string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink); - protected abstract string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent); + protected abstract string AddFromMagnetLink(RemoteAlbum remoteAlbum, string hash, string magnetLink); + protected abstract string AddFromTorrentFile(RemoteAlbum remoteAlbum, string hash, string filename, byte[] fileContent); - public override string Download(RemoteEpisode remoteEpisode) + public override string Download(RemoteAlbum remoteAlbum) { - var torrentInfo = remoteEpisode.Release as TorrentInfo; + var torrentInfo = remoteAlbum.Release as TorrentInfo; string magnetUrl = null; string torrentUrl = null; - if (remoteEpisode.Release.DownloadUrl.IsNotNullOrWhiteSpace() && remoteEpisode.Release.DownloadUrl.StartsWith("magnet:")) + if (remoteAlbum.Release.DownloadUrl.IsNotNullOrWhiteSpace() && remoteAlbum.Release.DownloadUrl.StartsWith("magnet:")) { - magnetUrl = remoteEpisode.Release.DownloadUrl; + magnetUrl = remoteAlbum.Release.DownloadUrl; } else { - torrentUrl = remoteEpisode.Release.DownloadUrl; + torrentUrl = remoteAlbum.Release.DownloadUrl; } if (torrentInfo != null && !torrentInfo.MagnetUrl.IsNullOrWhiteSpace()) @@ -68,7 +68,7 @@ namespace NzbDrone.Core.Download { try { - return DownloadFromWebUrl(remoteEpisode, torrentUrl); + return DownloadFromWebUrl(remoteAlbum, torrentUrl); } catch (Exception ex) { @@ -85,11 +85,11 @@ namespace NzbDrone.Core.Download { try { - return DownloadFromMagnetUrl(remoteEpisode, magnetUrl); + return DownloadFromMagnetUrl(remoteAlbum, magnetUrl); } catch (NotSupportedException ex) { - throw new ReleaseDownloadException(remoteEpisode.Release, "Magnet not supported by download client. ({0})", ex.Message); + throw new ReleaseDownloadException(remoteAlbum.Release, "Magnet not supported by download client. ({0})", ex.Message); } } } @@ -99,13 +99,13 @@ namespace NzbDrone.Core.Download { try { - return DownloadFromMagnetUrl(remoteEpisode, magnetUrl); + return DownloadFromMagnetUrl(remoteAlbum, magnetUrl); } catch (NotSupportedException ex) { if (torrentUrl.IsNullOrWhiteSpace()) { - throw new ReleaseDownloadException(remoteEpisode.Release, "Magnet not supported by download client. ({0})", ex.Message); + throw new ReleaseDownloadException(remoteAlbum.Release, "Magnet not supported by download client. ({0})", ex.Message); } _logger.Debug("Magnet not supported by download client, trying torrent. ({0})", ex.Message); @@ -114,14 +114,14 @@ namespace NzbDrone.Core.Download if (torrentUrl.IsNotNullOrWhiteSpace()) { - return DownloadFromWebUrl(remoteEpisode, torrentUrl); + return DownloadFromWebUrl(remoteAlbum, torrentUrl); } } return null; } - private string DownloadFromWebUrl(RemoteEpisode remoteEpisode, string torrentUrl) + private string DownloadFromWebUrl(RemoteAlbum remoteAlbum, string torrentUrl) { byte[] torrentFile = null; @@ -145,10 +145,10 @@ namespace NzbDrone.Core.Download { if (locationHeader.StartsWith("magnet:")) { - return DownloadFromMagnetUrl(remoteEpisode, locationHeader); + return DownloadFromMagnetUrl(remoteAlbum, locationHeader); } - return DownloadFromWebUrl(remoteEpisode, locationHeader); + return DownloadFromWebUrl(remoteAlbum, locationHeader); } throw new WebException("Remote website tried to redirect without providing a location."); @@ -156,7 +156,7 @@ namespace NzbDrone.Core.Download torrentFile = response.ResponseData; - _logger.Debug("Downloading torrent for release '{0}' finished ({1} bytes from {2})", remoteEpisode.Release.Title, torrentFile.Length, torrentUrl); + _logger.Debug("Downloading torrent for release '{0}' finished ({1} bytes from {2})", remoteAlbum.Release.Title, torrentFile.Length, torrentUrl); } catch (HttpException ex) { @@ -166,33 +166,33 @@ namespace NzbDrone.Core.Download } else { - _logger.Error(ex, "Downloading torrent file for release '{0}' failed ({1})", remoteEpisode.Release.Title, torrentUrl); + _logger.Error(ex, "Downloading torrent file for release '{0}' failed ({1})", remoteAlbum.Release.Title, torrentUrl); } - throw new ReleaseDownloadException(remoteEpisode.Release, "Downloading torrent failed", ex); + throw new ReleaseDownloadException(remoteAlbum.Release, "Downloading torrent failed", ex); } catch (WebException ex) { - _logger.Error(ex, "Downloading torrent file for release '{0}' failed ({1})", remoteEpisode.Release.Title, torrentUrl); + _logger.Error(ex, "Downloading torrent file for release '{0}' failed ({1})", remoteAlbum.Release.Title, torrentUrl); - throw new ReleaseDownloadException(remoteEpisode.Release, "Downloading torrent failed", ex); + throw new ReleaseDownloadException(remoteAlbum.Release, "Downloading torrent failed", ex); } - var filename = string.Format("{0}.torrent", FileNameBuilder.CleanFileName(remoteEpisode.Release.Title)); + var filename = string.Format("{0}.torrent", FileNameBuilder.CleanFileName(remoteAlbum.Release.Title)); var hash = _torrentFileInfoReader.GetHashFromTorrentFile(torrentFile); - var actualHash = AddFromTorrentFile(remoteEpisode, hash, filename, torrentFile); + var actualHash = AddFromTorrentFile(remoteAlbum, hash, filename, torrentFile); if (actualHash.IsNotNullOrWhiteSpace() && hash != actualHash) { _logger.Debug( "{0} did not return the expected InfoHash for '{1}', Lidarr could potentially lose track of the download in progress.", - Definition.Implementation, remoteEpisode.Release.DownloadUrl); + Definition.Implementation, remoteAlbum.Release.DownloadUrl); } return actualHash; } - private string DownloadFromMagnetUrl(RemoteEpisode remoteEpisode, string magnetUrl) + private string DownloadFromMagnetUrl(RemoteAlbum remoteAlbum, string magnetUrl) { string hash = null; string actualHash = null; @@ -203,21 +203,21 @@ namespace NzbDrone.Core.Download } catch (FormatException ex) { - _logger.Error(ex, "Failed to parse magnetlink for release '{0}': '{1}'", remoteEpisode.Release.Title, magnetUrl); + _logger.Error(ex, "Failed to parse magnetlink for release '{0}': '{1}'", remoteAlbum.Release.Title, magnetUrl); return null; } if (hash != null) { - actualHash = AddFromMagnetLink(remoteEpisode, hash, magnetUrl); + actualHash = AddFromMagnetLink(remoteAlbum, hash, magnetUrl); } if (actualHash.IsNotNullOrWhiteSpace() && hash != actualHash) { _logger.Debug( "{0} did not return the expected InfoHash for '{1}', Lidarr could potentially lose track of the download in progress.", - Definition.Implementation, remoteEpisode.Release.DownloadUrl); + Definition.Implementation, remoteAlbum.Release.DownloadUrl); } return actualHash; diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs b/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs index dcaefd073..a760b71fe 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs @@ -12,7 +12,7 @@ using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Download.TrackedDownloads { public class DownloadMonitoringService : IExecute, - IHandle, + IHandle, IHandle { private readonly IProvideDownloadClient _downloadClientProvider; @@ -163,7 +163,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads Refresh(); } - public void Handle(EpisodeGrabbedEvent message) + public void Handle(AlbumGrabbedEvent message) { _refreshDebounce.Execute(); } diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs index be012d57b..ac9ec462f 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs @@ -10,6 +10,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads public TrackedDownloadStage State { get; set; } public TrackedDownloadStatus Status { get; private set; } public RemoteEpisode RemoteEpisode { get; set; } + public RemoteAlbum RemoteAlbum { get; set; } public TrackedDownloadStatusMessage[] StatusMessages { get; private set; } public DownloadProtocol Protocol { get; set; } diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs index 55ce7398d..b1e8189d4 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using NLog; using NzbDrone.Common.Cache; @@ -56,12 +56,12 @@ namespace NzbDrone.Core.Download.TrackedDownloads try { - var parsedEpisodeInfo = Parser.Parser.ParseTitle(trackedDownload.DownloadItem.Title); + var parsedAlbumInfo = Parser.Parser.ParseAlbumTitle(trackedDownload.DownloadItem.Title); var historyItems = _historyService.FindByDownloadId(downloadItem.DownloadId); - if (parsedEpisodeInfo != null) + if (parsedAlbumInfo != null) { - trackedDownload.RemoteEpisode = _parsingService.Map(parsedEpisodeInfo, 0, 0); + trackedDownload.RemoteAlbum = _parsingService.Map(parsedAlbumInfo); } if (historyItems.Any()) @@ -69,30 +69,30 @@ namespace NzbDrone.Core.Download.TrackedDownloads var firstHistoryItem = historyItems.OrderByDescending(h => h.Date).First(); trackedDownload.State = GetStateFromHistory(firstHistoryItem.EventType); - if (parsedEpisodeInfo == null || - trackedDownload.RemoteEpisode == null || - trackedDownload.RemoteEpisode.Series == null || - trackedDownload.RemoteEpisode.Episodes.Empty()) + if (parsedAlbumInfo == null || + trackedDownload.RemoteAlbum == null || + trackedDownload.RemoteAlbum.Artist == null || + trackedDownload.RemoteAlbum.Albums.Empty()) { // Try parsing the original source title and if that fails, try parsing it as a special // TODO: Pass the TVDB ID and TVRage IDs in as well so we have a better chance for finding the item - parsedEpisodeInfo = Parser.Parser.ParseTitle(firstHistoryItem.SourceTitle) ?? _parsingService.ParseSpecialEpisodeTitle(firstHistoryItem.SourceTitle, 0, 0); + parsedAlbumInfo = Parser.Parser.ParseAlbumTitle(firstHistoryItem.SourceTitle); - if (parsedEpisodeInfo != null) + if (parsedAlbumInfo != null) { - trackedDownload.RemoteEpisode = _parsingService.Map(parsedEpisodeInfo, firstHistoryItem.SeriesId, historyItems.Where(v => v.EventType == HistoryEventType.Grabbed).Select(h => h.EpisodeId).Distinct()); + trackedDownload.RemoteAlbum = _parsingService.Map(parsedAlbumInfo, firstHistoryItem.ArtistId, historyItems.Where(v => v.EventType == HistoryEventType.Grabbed).Select(h => h.AlbumId).Distinct()); } } } - if (trackedDownload.RemoteEpisode == null) + if (trackedDownload.RemoteAlbum == null) { return null; } } catch (Exception e) { - _logger.Debug(e, "Failed to find episode for " + downloadItem.Title); + _logger.Debug(e, "Failed to find album for " + downloadItem.Title); return null; } diff --git a/src/NzbDrone.Core/Download/UsenetClientBase.cs b/src/NzbDrone.Core/Download/UsenetClientBase.cs index 1d50dd178..29fdefb55 100644 --- a/src/NzbDrone.Core/Download/UsenetClientBase.cs +++ b/src/NzbDrone.Core/Download/UsenetClientBase.cs @@ -29,12 +29,12 @@ namespace NzbDrone.Core.Download public override DownloadProtocol Protocol => DownloadProtocol.Usenet; - protected abstract string AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContent); + protected abstract string AddFromNzbFile(RemoteAlbum remoteAlbum, string filename, byte[] fileContent); - public override string Download(RemoteEpisode remoteEpisode) + public override string Download(RemoteAlbum remoteAlbum) { - var url = remoteEpisode.Release.DownloadUrl; - var filename = FileNameBuilder.CleanFileName(remoteEpisode.Release.Title) + ".nzb"; + var url = remoteAlbum.Release.DownloadUrl; + var filename = FileNameBuilder.CleanFileName(remoteAlbum.Release.Title) + ".nzb"; byte[] nzbData; @@ -42,7 +42,7 @@ namespace NzbDrone.Core.Download { nzbData = _httpClient.Get(new HttpRequest(url)).ResponseData; - _logger.Debug("Downloaded nzb for release '{0}' finished ({1} bytes from {2})", remoteEpisode.Release.Title, nzbData.Length, url); + _logger.Debug("Downloaded nzb for release '{0}' finished ({1} bytes from {2})", remoteAlbum.Release.Title, nzbData.Length, url); } catch (HttpException ex) { @@ -52,20 +52,20 @@ namespace NzbDrone.Core.Download } else { - _logger.Error(ex, "Downloading nzb for release '{0}' failed ({1})", remoteEpisode.Release.Title, url); + _logger.Error(ex, "Downloading nzb for release '{0}' failed ({1})", remoteAlbum.Release.Title, url); } - throw new ReleaseDownloadException(remoteEpisode.Release, "Downloading nzb failed", ex); + throw new ReleaseDownloadException(remoteAlbum.Release, "Downloading nzb failed", ex); } catch (WebException ex) { - _logger.Error(ex, "Downloading nzb for release '{0}' failed ({1})", remoteEpisode.Release.Title, url); + _logger.Error(ex, "Downloading nzb for release '{0}' failed ({1})", remoteAlbum.Release.Title, url); - throw new ReleaseDownloadException(remoteEpisode.Release, "Downloading nzb failed", ex); + throw new ReleaseDownloadException(remoteAlbum.Release, "Downloading nzb failed", ex); } - _logger.Info("Adding report [{0}] to the queue.", remoteEpisode.Release.Title); - return AddFromNzbFile(remoteEpisode, filename, nzbData); + _logger.Info("Adding report [{0}] to the queue.", remoteAlbum.Release.Title); + return AddFromNzbFile(remoteAlbum, filename, nzbData); } } } diff --git a/src/NzbDrone.Core/History/History.cs b/src/NzbDrone.Core/History/History.cs index be35637c8..5c017a71c 100644 --- a/src/NzbDrone.Core/History/History.cs +++ b/src/NzbDrone.Core/History/History.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using NzbDrone.Core.Datastore; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.History { @@ -14,14 +14,14 @@ namespace NzbDrone.Core.History { Data = new Dictionary(); } - - public int EpisodeId { get; set; } - public int SeriesId { get; set; } + + public int AlbumId { get; set; } + public int ArtistId { get; set; } public string SourceTitle { get; set; } public QualityModel Quality { get; set; } public DateTime Date { get; set; } - public Episode Episode { get; set; } - public Series Series { get; set; } + public Album Album { get; set; } + public Artist Artist { get; set; } public HistoryEventType EventType { get; set; } public Dictionary Data { get; set; } diff --git a/src/NzbDrone.Core/History/HistoryRepository.cs b/src/NzbDrone.Core/History/HistoryRepository.cs index 35199a878..68cd40ae7 100644 --- a/src/NzbDrone.Core/History/HistoryRepository.cs +++ b/src/NzbDrone.Core/History/HistoryRepository.cs @@ -4,18 +4,18 @@ using Marr.Data.QGen; using NzbDrone.Core.Datastore; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.History { public interface IHistoryRepository : IBasicRepository { - List GetBestQualityInHistory(int episodeId); - History MostRecentForEpisode(int episodeId); + List GetBestQualityInHistory(int albumId); + History MostRecentForAlbum(int albumId); History MostRecentForDownloadId(string downloadId); List FindByDownloadId(string downloadId); - List FindDownloadHistory(int idSeriesId, QualityModel quality); - void DeleteForSeries(int seriesId); + List FindDownloadHistory(int idArtistId, QualityModel quality); + void DeleteForArtist(int artistId); } public class HistoryRepository : BasicRepository, IHistoryRepository @@ -27,16 +27,16 @@ namespace NzbDrone.Core.History } - public List GetBestQualityInHistory(int episodeId) + public List GetBestQualityInHistory(int albumId) { - var history = Query.Where(c => c.EpisodeId == episodeId); + var history = Query.Where(c => c.AlbumId == albumId); return history.Select(h => h.Quality).ToList(); } - public History MostRecentForEpisode(int episodeId) + public History MostRecentForAlbum(int albumId) { - return Query.Where(h => h.EpisodeId == episodeId) + return Query.Where(h => h.AlbumId == albumId) .OrderByDescending(h => h.Date) .FirstOrDefault(); } @@ -53,10 +53,10 @@ namespace NzbDrone.Core.History return Query.Where(h => h.DownloadId == downloadId); } - public List FindDownloadHistory(int idSeriesId, QualityModel quality) + public List FindDownloadHistory(int idArtistId, QualityModel quality) { return Query.Where(h => - h.SeriesId == idSeriesId && + h.ArtistId == idArtistId && h.Quality == quality && (h.EventType == HistoryEventType.Grabbed || h.EventType == HistoryEventType.DownloadFailed || @@ -64,15 +64,15 @@ namespace NzbDrone.Core.History ).ToList(); } - public void DeleteForSeries(int seriesId) + public void DeleteForArtist(int artistId) { - Delete(c => c.SeriesId == seriesId); + Delete(c => c.ArtistId == artistId); } protected override SortBuilder GetPagedQuery(QueryBuilder query, PagingSpec pagingSpec) { - var baseQuery = query.Join(JoinType.Inner, h => h.Series, (h, s) => h.SeriesId == s.Id) - .Join(JoinType.Inner, h => h.Episode, (h, e) => h.EpisodeId == e.Id); + var baseQuery = query.Join(JoinType.Inner, h => h.Artist, (h, s) => h.ArtistId == s.Id) + .Join(JoinType.Inner, h => h.Album, (h, e) => h.AlbumId == e.Id); return base.GetPagedQuery(baseQuery, pagingSpec); } diff --git a/src/NzbDrone.Core/History/HistoryService.cs b/src/NzbDrone.Core/History/HistoryService.cs index 32815beef..eb4095f4c 100644 --- a/src/NzbDrone.Core/History/HistoryService.cs +++ b/src/NzbDrone.Core/History/HistoryService.cs @@ -12,7 +12,7 @@ using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Profiles; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv.Events; +using NzbDrone.Core.Music.Events; namespace NzbDrone.Core.History { @@ -20,7 +20,7 @@ namespace NzbDrone.Core.History { QualityModel GetBestQualityInHistory(Profile profile, int episodeId); PagingSpec Paged(PagingSpec pagingSpec); - History MostRecentForEpisode(int episodeId); + History MostRecentForAlbum(int episodeId); History MostRecentForDownloadId(string downloadId); History Get(int historyId); List Find(string downloadId, HistoryEventType eventType); @@ -28,11 +28,11 @@ namespace NzbDrone.Core.History } public class HistoryService : IHistoryService, - IHandle, + IHandle, IHandle, IHandle, IHandle, - IHandle + IHandle { private readonly IHistoryRepository _historyRepository; private readonly Logger _logger; @@ -48,9 +48,9 @@ namespace NzbDrone.Core.History return _historyRepository.GetPaged(pagingSpec); } - public History MostRecentForEpisode(int episodeId) + public History MostRecentForAlbum(int albumId) { - return _historyRepository.MostRecentForEpisode(episodeId); + return _historyRepository.MostRecentForAlbum(albumId); } public History MostRecentForDownloadId(string downloadId) @@ -73,10 +73,10 @@ namespace NzbDrone.Core.History return _historyRepository.FindByDownloadId(downloadId); } - public QualityModel GetBestQualityInHistory(Profile profile, int episodeId) + public QualityModel GetBestQualityInHistory(Profile profile, int albumId) { var comparer = new QualityModelComparer(profile); - return _historyRepository.GetBestQualityInHistory(episodeId) + return _historyRepository.GetBestQualityInHistory(albumId) .OrderByDescending(q => q, comparer) .FirstOrDefault(); } @@ -85,25 +85,25 @@ namespace NzbDrone.Core.History { _logger.Debug("Trying to find downloadId for {0} from history", trackedDownload.ImportedEpisode.Path); - var episodeIds = trackedDownload.EpisodeInfo.Episodes.Select(c => c.Id).ToList(); + var albumIds = trackedDownload.EpisodeInfo.Episodes.Select(c => c.Id).ToList(); var allHistory = _historyRepository.FindDownloadHistory(trackedDownload.EpisodeInfo.Series.Id, trackedDownload.ImportedEpisode.Quality); //Find download related items for these episdoes - var episodesHistory = allHistory.Where(h => episodeIds.Contains(h.EpisodeId)).ToList(); + var albumsHistory = allHistory.Where(h => albumIds.Contains(h.AlbumId)).ToList(); - var processedDownloadId = episodesHistory + var processedDownloadId = albumsHistory .Where(c => c.EventType != HistoryEventType.Grabbed && c.DownloadId != null) .Select(c => c.DownloadId); - var stillDownloading = episodesHistory.Where(c => c.EventType == HistoryEventType.Grabbed && !processedDownloadId.Contains(c.DownloadId)).ToList(); + var stillDownloading = albumsHistory.Where(c => c.EventType == HistoryEventType.Grabbed && !processedDownloadId.Contains(c.DownloadId)).ToList(); string downloadId = null; if (stillDownloading.Any()) { - foreach (var matchingHistory in trackedDownload.EpisodeInfo.Episodes.Select(e => stillDownloading.Where(c => c.EpisodeId == e.Id).ToList())) + foreach (var matchingHistory in trackedDownload.EpisodeInfo.Episodes.Select(e => stillDownloading.Where(c => c.AlbumId == e.Id).ToList())) { if (matchingHistory.Count != 1) { @@ -126,42 +126,40 @@ namespace NzbDrone.Core.History return downloadId; } - public void Handle(EpisodeGrabbedEvent message) + public void Handle(AlbumGrabbedEvent message) { - foreach (var episode in message.Episode.Episodes) + foreach (var album in message.Album.Albums) { var history = new History { EventType = HistoryEventType.Grabbed, Date = DateTime.UtcNow, - Quality = message.Episode.ParsedEpisodeInfo.Quality, - SourceTitle = message.Episode.Release.Title, - SeriesId = episode.SeriesId, - EpisodeId = episode.Id, + Quality = message.Album.ParsedAlbumInfo.Quality, + SourceTitle = message.Album.Release.Title, + ArtistId = album.ArtistId, + AlbumId = album.Id, DownloadId = message.DownloadId }; - history.Data.Add("Indexer", message.Episode.Release.Indexer); - history.Data.Add("NzbInfoUrl", message.Episode.Release.InfoUrl); - history.Data.Add("ReleaseGroup", message.Episode.ParsedEpisodeInfo.ReleaseGroup); - history.Data.Add("Age", message.Episode.Release.Age.ToString()); - history.Data.Add("AgeHours", message.Episode.Release.AgeHours.ToString()); - history.Data.Add("AgeMinutes", message.Episode.Release.AgeMinutes.ToString()); - history.Data.Add("PublishedDate", message.Episode.Release.PublishDate.ToString("s") + "Z"); + history.Data.Add("Indexer", message.Album.Release.Indexer); + history.Data.Add("NzbInfoUrl", message.Album.Release.InfoUrl); + history.Data.Add("ReleaseGroup", message.Album.ParsedAlbumInfo.ReleaseGroup); + history.Data.Add("Age", message.Album.Release.Age.ToString()); + history.Data.Add("AgeHours", message.Album.Release.AgeHours.ToString()); + history.Data.Add("AgeMinutes", message.Album.Release.AgeMinutes.ToString()); + history.Data.Add("PublishedDate", message.Album.Release.PublishDate.ToString("s") + "Z"); history.Data.Add("DownloadClient", message.DownloadClient); - history.Data.Add("Size", message.Episode.Release.Size.ToString()); - history.Data.Add("DownloadUrl", message.Episode.Release.DownloadUrl); - history.Data.Add("Guid", message.Episode.Release.Guid); - history.Data.Add("TvdbId", message.Episode.Release.TvdbId.ToString()); - history.Data.Add("TvRageId", message.Episode.Release.TvRageId.ToString()); - history.Data.Add("Protocol", ((int)message.Episode.Release.DownloadProtocol).ToString()); - - if (!message.Episode.ParsedEpisodeInfo.ReleaseHash.IsNullOrWhiteSpace()) + history.Data.Add("Size", message.Album.Release.Size.ToString()); + history.Data.Add("DownloadUrl", message.Album.Release.DownloadUrl); + history.Data.Add("Guid", message.Album.Release.Guid); + history.Data.Add("Protocol", ((int)message.Album.Release.DownloadProtocol).ToString()); + + if (!message.Album.ParsedAlbumInfo.ReleaseHash.IsNullOrWhiteSpace()) { - history.Data.Add("ReleaseHash", message.Episode.ParsedEpisodeInfo.ReleaseHash); + history.Data.Add("ReleaseHash", message.Album.ParsedAlbumInfo.ReleaseHash); } - var torrentRelease = message.Episode.Release as TorrentInfo; + var torrentRelease = message.Album.Release as TorrentInfo; if (torrentRelease != null) { @@ -194,8 +192,8 @@ namespace NzbDrone.Core.History Date = DateTime.UtcNow, Quality = message.EpisodeInfo.Quality, SourceTitle = message.ImportedEpisode.SceneName ?? Path.GetFileNameWithoutExtension(message.EpisodeInfo.Path), - SeriesId = message.ImportedEpisode.SeriesId, - EpisodeId = episode.Id, + ArtistId = message.ImportedEpisode.SeriesId, + AlbumId = episode.Id, DownloadId = downloadId }; @@ -211,7 +209,7 @@ namespace NzbDrone.Core.History public void Handle(DownloadFailedEvent message) { - foreach (var episodeId in message.EpisodeIds) + foreach (var albumId in message.AlbumIds) { var history = new History { @@ -219,8 +217,8 @@ namespace NzbDrone.Core.History Date = DateTime.UtcNow, Quality = message.Quality, SourceTitle = message.SourceTitle, - SeriesId = message.SeriesId, - EpisodeId = episodeId, + ArtistId = message.SeriesId, + AlbumId = albumId, DownloadId = message.DownloadId }; @@ -247,8 +245,8 @@ namespace NzbDrone.Core.History Date = DateTime.UtcNow, Quality = message.EpisodeFile.Quality, SourceTitle = message.EpisodeFile.Path, - SeriesId = message.EpisodeFile.SeriesId, - EpisodeId = episode.Id, + ArtistId = message.EpisodeFile.SeriesId, + AlbumId = episode.Id, }; history.Data.Add("Reason", message.Reason.ToString()); @@ -257,9 +255,9 @@ namespace NzbDrone.Core.History } } - public void Handle(SeriesDeletedEvent message) + public void Handle(ArtistDeletedEvent message) { - _historyRepository.DeleteForSeries(message.Series.Id); + _historyRepository.DeleteForArtist(message.Artist.Id); } } } \ No newline at end of file diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedHistoryItems.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedHistoryItems.cs index ca03130e6..ded0eae75 100644 --- a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedHistoryItems.cs +++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedHistoryItems.cs @@ -13,32 +13,32 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers public void Clean() { - CleanupOrphanedBySeries(); - CleanupOrphanedByEpisode(); + CleanupOrphanedByArtist(); + CleanupOrphanedByAlbum(); } - private void CleanupOrphanedBySeries() + private void CleanupOrphanedByArtist() { var mapper = _database.GetDataMapper(); mapper.ExecuteNonQuery(@"DELETE FROM History WHERE Id IN ( SELECT History.Id FROM History - LEFT OUTER JOIN Series - ON History.SeriesId = Series.Id - WHERE Series.Id IS NULL)"); + LEFT OUTER JOIN Artists + ON History.ArtistId = Artists.Id + WHERE Artists.Id IS NULL)"); } - private void CleanupOrphanedByEpisode() + private void CleanupOrphanedByAlbum() { var mapper = _database.GetDataMapper(); mapper.ExecuteNonQuery(@"DELETE FROM History WHERE Id IN ( SELECT History.Id FROM History - LEFT OUTER JOIN Episodes - ON History.EpisodeId = Episodes.Id - WHERE Episodes.Id IS NULL)"); + LEFT OUTER JOIN Albums + ON History.AlbumId = Albums.Id + WHERE Albums.Id IS NULL)"); } } } diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedPendingReleases.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedPendingReleases.cs index 0366d7321..bdc45d099 100644 --- a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedPendingReleases.cs +++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedPendingReleases.cs @@ -18,9 +18,9 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers mapper.ExecuteNonQuery(@"DELETE FROM PendingReleases WHERE Id IN ( SELECT PendingReleases.Id FROM PendingReleases - LEFT OUTER JOIN Series - ON PendingReleases.SeriesId = Series.Id - WHERE Series.Id IS NULL)"); + LEFT OUTER JOIN Artists + ON PendingReleases.ArtistId = Artists.Id + WHERE Artists.Id IS NULL)"); } } } diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/AlbumSearchCriteria.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/AlbumSearchCriteria.cs index 82ffef1df..a5e21ebab 100644 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/AlbumSearchCriteria.cs +++ b/src/NzbDrone.Core/IndexerSearch/Definitions/AlbumSearchCriteria.cs @@ -4,18 +4,13 @@ namespace NzbDrone.Core.IndexerSearch.Definitions { public class AlbumSearchCriteria : SearchCriteriaBase { + + public string AlbumTitle { get; set; } + public int AlbumYear { get; set; } + public override string ToString() { - var baseRepresentation = $"[{Artist.Name} - {Album.Title}]"; - if (Album.ReleaseDate.HasValue) - { - var beforeLast = baseRepresentation.Length - 1; - return baseRepresentation.Insert(beforeLast, $" ({Album.ReleaseDate.Value.Year})"); - } - else - { - return baseRepresentation; - } + return string.Format("[{0} - {1} ({2})]", Artist.Name, AlbumTitle, AlbumYear); } } } diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs index 00b802c68..5b2a51097 100644 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs +++ b/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using NzbDrone.Common.EnsureThat; @@ -24,7 +24,7 @@ namespace NzbDrone.Core.IndexerSearch.Definitions public virtual bool UserInvokedSearch { get; set; } public Artist Artist { get; set; } - public Album Album { get; set; } + public List Albums { get; set; } public List Tracks { get; set; } public List QueryTitles => SceneTitles.Select(GetQueryTitle).ToList(); diff --git a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs index 2fe861fa0..ffad2b89d 100644 --- a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.Threading.Tasks; @@ -183,12 +183,25 @@ namespace NzbDrone.Core.IndexerSearch public List ArtistSearch(Artist artist, bool missingOnly, bool userInvokedSearch) { var searchSpec = Get(artist, userInvokedSearch); + var albums = _albumService.GetAlbumsByArtist(artist.Id); + + searchSpec.Albums = albums; + return Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec); } public List AlbumSearch(Album album, bool missingOnly, bool userInvokedSearch) { - var searchSpec = Get(album, userInvokedSearch); + var artist = _artistService.GetArtist(album.ArtistId); + + var searchSpec = Get(artist, new List { album }, userInvokedSearch); + + searchSpec.AlbumTitle = album.Title; + if (album.ReleaseDate.HasValue) + { + searchSpec.AlbumYear = album.ReleaseDate.Value.Year; + } + return Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec); } @@ -279,12 +292,12 @@ namespace NzbDrone.Core.IndexerSearch return spec; } - private TSpec Get(Album album, bool userInvokedSearch) where TSpec : SearchCriteriaBase, new() + private TSpec Get(Artist artist, List albums, bool userInvokedSearch) where TSpec : SearchCriteriaBase, new() { var spec = new TSpec(); - spec.Album = album; - spec.Artist = _artistService.GetArtist(album.ArtistId); + spec.Albums = albums; + spec.Artist = artist; spec.UserInvokedSearch = userInvokedSearch; return spec; diff --git a/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetParser.cs b/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetParser.cs index 6cecc3b86..ee657f0c8 100644 --- a/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetParser.cs +++ b/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetParser.cs @@ -67,14 +67,6 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet torrentInfo.DownloadUrl = RegexProtocol.Replace(torrent.DownloadURL, protocol); torrentInfo.InfoUrl = string.Format("{0}//broadcasthe.net/torrents.php?id={1}&torrentid={2}", protocol, torrent.GroupID, torrent.TorrentID); //torrentInfo.CommentUrl = - if (torrent.TvdbID.HasValue) - { - torrentInfo.TvdbId = torrent.TvdbID.Value; - } - if (torrent.TvrageID.HasValue) - { - torrentInfo.TvRageId = torrent.TvrageID.Value; - } torrentInfo.PublishDate = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).ToUniversalTime().AddSeconds(torrent.Time); //torrentInfo.MagnetUrl = torrentInfo.InfoHash = torrent.InfoHash; diff --git a/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs index 13e0233ea..fe5b2d461 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs @@ -202,7 +202,7 @@ namespace NzbDrone.Core.Indexers.Newznab AddAudioPageableRequests(pageableRequests, string.Format("&artist={0}&album={1}", searchCriteria.Artist.Name, - searchCriteria.Album.Title)); + searchCriteria.AlbumTitle)); return pageableRequests; } diff --git a/src/NzbDrone.Core/Indexers/Newznab/NewznabRssParser.cs b/src/NzbDrone.Core/Indexers/Newznab/NewznabRssParser.cs index 16c4dea9b..a0d647fcc 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/NewznabRssParser.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/NewznabRssParser.cs @@ -48,10 +48,10 @@ namespace NzbDrone.Core.Indexers.Newznab protected override ReleaseInfo ProcessItem(XElement item, ReleaseInfo releaseInfo) { releaseInfo = base.ProcessItem(item, releaseInfo); - - releaseInfo.TvdbId = GetTvdbId(item); - releaseInfo.TvRageId = GetTvRageId(item); - + + releaseInfo.Artist = GetArtist(item); + releaseInfo.Album = GetAlbum(item); + return releaseInfo; } @@ -114,30 +114,28 @@ namespace NzbDrone.Core.Indexers.Newznab return url; } - protected virtual int GetTvdbId(XElement item) + protected virtual string GetArtist(XElement item) { - var tvdbIdString = TryGetNewznabAttribute(item, "tvdbid"); - int tvdbId; + var artistString = TryGetNewznabAttribute(item, "artist"); - if (!tvdbIdString.IsNullOrWhiteSpace() && int.TryParse(tvdbIdString, out tvdbId)) + if (!artistString.IsNullOrWhiteSpace()) { - return tvdbId; + return artistString; } - return 0; + return ""; } - - protected virtual int GetTvRageId(XElement item) + + protected virtual string GetAlbum(XElement item) { - var tvRageIdString = TryGetNewznabAttribute(item, "rageid"); - int tvRageId; + var albumString = TryGetNewznabAttribute(item, "album"); - if (!tvRageIdString.IsNullOrWhiteSpace() && int.TryParse(tvRageIdString, out tvRageId)) + if (!albumString.IsNullOrWhiteSpace()) { - return tvRageId; + return albumString; } - return 0; + return ""; } protected string TryGetNewznabAttribute(XElement item, string key, string defaultValue = "") diff --git a/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs index 04e13b8d0..61a7e5797 100644 --- a/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs @@ -95,7 +95,7 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs pageableRequests.Add(GetPagedRequests(string.Format("{0}+{1}", searchCriteria.Artist.Name, - searchCriteria.Album.Title))); + searchCriteria.AlbumTitle))); return pageableRequests; diff --git a/src/NzbDrone.Core/Indexers/Rarbg/RarbgParser.cs b/src/NzbDrone.Core/Indexers/Rarbg/RarbgParser.cs index 61395a5b2..cadfa5524 100644 --- a/src/NzbDrone.Core/Indexers/Rarbg/RarbgParser.cs +++ b/src/NzbDrone.Core/Indexers/Rarbg/RarbgParser.cs @@ -56,19 +56,6 @@ namespace NzbDrone.Core.Indexers.Rarbg torrentInfo.Seeders = torrent.seeders; torrentInfo.Peers = torrent.leechers + torrent.seeders; - if (torrent.episode_info != null) - { - if (torrent.episode_info.tvdb != null) - { - torrentInfo.TvdbId = torrent.episode_info.tvdb.Value; - } - - if (torrent.episode_info.tvrage != null) - { - torrentInfo.TvRageId = torrent.episode_info.tvrage.Value; - } - } - results.Add(torrentInfo); } diff --git a/src/NzbDrone.Core/Indexers/Rarbg/RarbgRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Rarbg/RarbgRequestGenerator.cs index e8364d969..991f6d71b 100644 --- a/src/NzbDrone.Core/Indexers/Rarbg/RarbgRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Rarbg/RarbgRequestGenerator.cs @@ -81,7 +81,7 @@ namespace NzbDrone.Core.Indexers.Rarbg { var pageableRequests = new IndexerPageableRequestChain(); - pageableRequests.Add(GetPagedRequests("search", null, "{0}+{1}", searchCriteria.Artist.Name, searchCriteria.Album.Title)); + pageableRequests.Add(GetPagedRequests("search", null, "{0}+{1}", searchCriteria.Artist.Name, searchCriteria.AlbumTitle)); return pageableRequests; } diff --git a/src/NzbDrone.Core/Indexers/Rarbg/RarbgResponse.cs b/src/NzbDrone.Core/Indexers/Rarbg/RarbgResponse.cs index 51c2e8350..d07100a6c 100644 --- a/src/NzbDrone.Core/Indexers/Rarbg/RarbgResponse.cs +++ b/src/NzbDrone.Core/Indexers/Rarbg/RarbgResponse.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; namespace NzbDrone.Core.Indexers.Rarbg @@ -26,8 +26,8 @@ namespace NzbDrone.Core.Indexers.Rarbg public class RarbgTorrentInfo { - public string imdb { get; set; } - public int? tvrage { get; set; } - public int? tvdb { get; set; } + // For Future if RARBG decides to return metadata + public string artist { get; set; } + public string album { get; set; } } } diff --git a/src/NzbDrone.Core/Indexers/Torznab/TorznabRssParser.cs b/src/NzbDrone.Core/Indexers/Torznab/TorznabRssParser.cs index 253386963..038785214 100644 --- a/src/NzbDrone.Core/Indexers/Torznab/TorznabRssParser.cs +++ b/src/NzbDrone.Core/Indexers/Torznab/TorznabRssParser.cs @@ -36,16 +36,6 @@ namespace NzbDrone.Core.Indexers.Torznab throw new TorznabException("Torznab error detected: {0}", errorMessage); } - protected override ReleaseInfo ProcessItem(XElement item, ReleaseInfo releaseInfo) - { - var torrentInfo = base.ProcessItem(item, releaseInfo) as TorrentInfo; - - torrentInfo.TvdbId = GetTvdbId(item); - torrentInfo.TvRageId = GetTvRageId(item); - - return torrentInfo; - } - protected override ReleaseInfo PostProcess(XElement item, ReleaseInfo releaseInfo) { var enclosureType = item.Element("enclosure").Attribute("type").Value; @@ -100,31 +90,6 @@ namespace NzbDrone.Core.Indexers.Torznab return url; } - protected virtual int GetTvdbId(XElement item) - { - var tvdbIdString = TryGetTorznabAttribute(item, "tvdbid"); - int tvdbId; - - if (!tvdbIdString.IsNullOrWhiteSpace() && int.TryParse(tvdbIdString, out tvdbId)) - { - return tvdbId; - } - - return 0; - } - - protected virtual int GetTvRageId(XElement item) - { - var tvRageIdString = TryGetTorznabAttribute(item, "rageid"); - int tvRageId; - - if (!tvRageIdString.IsNullOrWhiteSpace() && int.TryParse(tvRageIdString, out tvRageId)) - { - return tvRageId; - } - - return 0; - } protected override string GetInfoHash(XElement item) { return TryGetTorznabAttribute(item, "infohash"); diff --git a/src/NzbDrone.Core/Indexers/Waffles/WafflesRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Waffles/WafflesRequestGenerator.cs index 19af4a864..a4520096e 100644 --- a/src/NzbDrone.Core/Indexers/Waffles/WafflesRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Waffles/WafflesRequestGenerator.cs @@ -54,7 +54,7 @@ namespace NzbDrone.Core.Indexers.Waffles { var pageableRequests = new IndexerPageableRequestChain(); - pageableRequests.Add(GetPagedRequests(string.Format("&q=artist:{0} album:{1}",searchCriteria.Artist.Name,searchCriteria.Album.Title))); + pageableRequests.Add(GetPagedRequests(string.Format("&q=artist:{0} album:{1}",searchCriteria.Artist.Name,searchCriteria.AlbumTitle))); return pageableRequests; } diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index 21c7fc6c6..e7efe1beb 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -287,6 +287,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook track.Title = resource.TrackName; track.ForeignTrackId = resource.Id; track.TrackNumber = resource.TrackNumber; + track.Duration = resource.DurationMs; return track; } diff --git a/src/NzbDrone.Core/Music/AddArtistService.cs b/src/NzbDrone.Core/Music/AddArtistService.cs index a728cc04d..41191b03c 100644 --- a/src/NzbDrone.Core/Music/AddArtistService.cs +++ b/src/NzbDrone.Core/Music/AddArtistService.cs @@ -53,7 +53,7 @@ namespace NzbDrone.Core.Music } newArtist.CleanName = newArtist.Name.CleanArtistTitle(); - //newArtist.SortTitle = ArtistNameNormalizer.Normalize(newArtist.ArtistName, newArtist.ItunesId); // There is no Sort Title + newArtist.SortName = ArtistNameNormalizer.Normalize(newArtist.Name, newArtist.ForeignArtistId); // There is no Sort Title newArtist.Added = DateTime.UtcNow; var validationResult = _addArtistValidator.Validate(newArtist); diff --git a/src/NzbDrone.Core/Music/Album.cs b/src/NzbDrone.Core/Music/Album.cs index f57655589..e46a70ceb 100644 --- a/src/NzbDrone.Core/Music/Album.cs +++ b/src/NzbDrone.Core/Music/Album.cs @@ -26,6 +26,7 @@ namespace NzbDrone.Core.Music //public int TrackCount { get; set; } public string Path { get; set; } public int ProfileId { get; set; } + public int Duration { get; set; } public List Tracks { get; set; } //public int DiscCount { get; set; } public bool Monitored { get; set; } diff --git a/src/NzbDrone.Core/Music/AlbumRepository.cs b/src/NzbDrone.Core/Music/AlbumRepository.cs index 04da93c9b..e7c113322 100644 --- a/src/NzbDrone.Core/Music/AlbumRepository.cs +++ b/src/NzbDrone.Core/Music/AlbumRepository.cs @@ -14,6 +14,7 @@ namespace NzbDrone.Core.Music bool AlbumPathExists(string path); List GetAlbums(int artistId); Album FindByName(string cleanTitle); + Album FindByTitle(int artistId, string title); Album FindByArtistAndName(string artistName, string cleanTitle); Album FindById(string spotifyId); PagingSpec AlbumsWithoutFiles(PagingSpec pagingSpec); @@ -150,6 +151,15 @@ namespace NzbDrone.Core.Music .SingleOrDefault(); } + public Album FindByTitle(int artistId, string title) + { + title = Parser.Parser.CleanArtistTitle(title); + + return Query.Where(s => s.CleanTitle == title) + .AndWhere(s => s.ArtistId == artistId) + .SingleOrDefault(); + } + public Album FindByArtistAndName(string artistName, string cleanTitle) { var cleanArtistName = Parser.Parser.CleanArtistTitle(artistName); diff --git a/src/NzbDrone.Core/Music/AlbumService.cs b/src/NzbDrone.Core/Music/AlbumService.cs index 12167745b..c6017ea06 100644 --- a/src/NzbDrone.Core/Music/AlbumService.cs +++ b/src/NzbDrone.Core/Music/AlbumService.cs @@ -20,6 +20,7 @@ namespace NzbDrone.Core.Music List GetAlbumsByArtist(int artistId); Album AddAlbum(Album newAlbum); Album FindById(string spotifyId); + Album FindByTitle(int artistId, string title); Album FindByTitleInexact(string title); void DeleteAlbum(int albumId, bool deleteFiles); List GetAllAlbums(); @@ -82,6 +83,10 @@ namespace NzbDrone.Core.Music return _albumRepository.FindById(lidarrId); } + public Album FindByTitle(int artistId, string title) + { + return _albumRepository.FindByTitle(artistId, title); + } public Album FindByTitleInexact(string title) diff --git a/src/NzbDrone.Core/Music/Artist.cs b/src/NzbDrone.Core/Music/Artist.cs index f09048fb5..7e803bd70 100644 --- a/src/NzbDrone.Core/Music/Artist.cs +++ b/src/NzbDrone.Core/Music/Artist.cs @@ -30,6 +30,7 @@ namespace NzbDrone.Core.Music public string Name { get; set; } public string NameSlug { get; set; } public string CleanName { get; set; } + public string SortName { get; set; } public string Overview { get; set; } public bool Monitored { get; set; } public bool AlbumFolder { get; set; } diff --git a/src/NzbDrone.Core/Music/ArtistNameNormalizer.cs b/src/NzbDrone.Core/Music/ArtistNameNormalizer.cs index 64003d8ff..30bebbc71 100644 --- a/src/NzbDrone.Core/Music/ArtistNameNormalizer.cs +++ b/src/NzbDrone.Core/Music/ArtistNameNormalizer.cs @@ -8,18 +8,18 @@ namespace NzbDrone.Core.Music public static class ArtistNameNormalizer { - private readonly static Dictionary PreComputedTitles = new Dictionary + private readonly static Dictionary PreComputedTitles = new Dictionary { - { 281588, "a to z" }, - { 266757, "ad trials triumph early church" }, - { 289260, "ad bible continues"} + { "281588", "a to z" }, + { "266757", "ad trials triumph early church" }, + { "289260", "ad bible continues"} }; - public static string Normalize(string title, int iTunesId) + public static string Normalize(string title, string mbID) { - if (PreComputedTitles.ContainsKey(iTunesId)) + if (PreComputedTitles.ContainsKey(mbID)) { - return PreComputedTitles[iTunesId]; + return PreComputedTitles[mbID]; } return Parser.Parser.NormalizeTitle(title).ToLower(); diff --git a/src/NzbDrone.Core/Music/RefreshAlbumService.cs b/src/NzbDrone.Core/Music/RefreshAlbumService.cs index 4b5487be8..4fddf1d6b 100644 --- a/src/NzbDrone.Core/Music/RefreshAlbumService.cs +++ b/src/NzbDrone.Core/Music/RefreshAlbumService.cs @@ -82,6 +82,7 @@ namespace NzbDrone.Core.Music albumToUpdate.Genres = album.Genres; albumToUpdate.Images = album.Images; albumToUpdate.ReleaseDate = album.ReleaseDate; + albumToUpdate.Duration = album.Tracks.Sum(track => track.Duration); successCount++; diff --git a/src/NzbDrone.Core/Music/RefreshArtistService.cs b/src/NzbDrone.Core/Music/RefreshArtistService.cs index ff3129acb..83a6856b3 100644 --- a/src/NzbDrone.Core/Music/RefreshArtistService.cs +++ b/src/NzbDrone.Core/Music/RefreshArtistService.cs @@ -75,6 +75,7 @@ namespace NzbDrone.Core.Music artist.Overview = artistInfo.Overview; artist.Status = artistInfo.Status; artist.CleanName = artistInfo.CleanName; + artist.SortName = artistInfo.SortName; artist.LastInfoSync = DateTime.UtcNow; artist.Images = artistInfo.Images; artist.Genres = artistInfo.Genres; diff --git a/src/NzbDrone.Core/Music/RefreshTrackService.cs b/src/NzbDrone.Core/Music/RefreshTrackService.cs index b8d7c3615..e84ba318a 100644 --- a/src/NzbDrone.Core/Music/RefreshTrackService.cs +++ b/src/NzbDrone.Core/Music/RefreshTrackService.cs @@ -71,6 +71,7 @@ namespace NzbDrone.Core.Music trackToUpdate.Explicit = track.Explicit; trackToUpdate.ArtistId = album.ArtistId; trackToUpdate.Compilation = track.Compilation; + trackToUpdate.Duration = track.Duration; successCount++; diff --git a/src/NzbDrone.Core/Music/Track.cs b/src/NzbDrone.Core/Music/Track.cs index 6b23fa965..26c31dfdc 100644 --- a/src/NzbDrone.Core/Music/Track.cs +++ b/src/NzbDrone.Core/Music/Track.cs @@ -26,6 +26,7 @@ namespace NzbDrone.Core.Music public bool Compilation { get; set; } public int TrackNumber { get; set; } public string Title { get; set; } + public int Duration { get; set; } //public bool Ignored { get; set; } public bool Explicit { get; set; } public bool Monitored { get; set; } diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index f1b8027ad..30a851b2c 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -295,6 +295,7 @@ Code + @@ -327,8 +328,7 @@ - - + @@ -340,19 +340,20 @@ - + - - + + - - + + - + + @@ -967,7 +968,9 @@ + + diff --git a/src/NzbDrone.Core/Parser/Model/ParsedAlbumInfo.cs b/src/NzbDrone.Core/Parser/Model/ParsedAlbumInfo.cs new file mode 100644 index 000000000..7e8ff08b4 --- /dev/null +++ b/src/NzbDrone.Core/Parser/Model/ParsedAlbumInfo.cs @@ -0,0 +1,35 @@ +using NzbDrone.Common.Extensions; +using NzbDrone.Core.Qualities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NzbDrone.Core.Parser.Model +{ + public class ParsedAlbumInfo + { + public string AlbumTitle { get; set; } + public string ArtistName { get; set; } + public ArtistTitleInfo ArtistTitleInfo { get; set; } + public QualityModel Quality { get; set; } + public string ReleaseDate { get; set; } + public Language Language { get; set; } + public string ReleaseGroup { get; set; } + public string ReleaseHash { get; set; } + + public override string ToString() + { + string albumString = "[Unknown Album]"; + + + if (AlbumTitle != null ) + { + albumString = string.Format("{0}", AlbumTitle); + } + + + return string.Format("{0} - {1} {2}", ArtistName, albumString, Quality); + } + } +} diff --git a/src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs b/src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs index 7c1680196..6514724c2 100644 --- a/src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs +++ b/src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Text; using NzbDrone.Core.Indexers; @@ -14,9 +14,9 @@ namespace NzbDrone.Core.Parser.Model public string CommentUrl { get; set; } public int IndexerId { get; set; } public string Indexer { get; set; } + public string Artist { get; set; } + public string Album { get; set; } public DownloadProtocol DownloadProtocol { get; set; } - public int TvdbId { get; set; } - public int TvRageId { get; set; } public DateTime PublishDate { get; set; } public string Origin { get; set; } @@ -80,8 +80,6 @@ namespace NzbDrone.Core.Parser.Model stringBuilder.AppendLine("Indexer: " + Indexer ?? "Empty"); stringBuilder.AppendLine("CommentUrl: " + CommentUrl ?? "Empty"); stringBuilder.AppendLine("DownloadProtocol: " + DownloadProtocol ?? "Empty"); - stringBuilder.AppendLine("TvdbId: " + TvdbId ?? "Empty"); - stringBuilder.AppendLine("TvRageId: " + TvRageId ?? "Empty"); stringBuilder.AppendLine("PublishDate: " + PublishDate ?? "Empty"); return stringBuilder.ToString(); default: diff --git a/src/NzbDrone.Core/Parser/Model/RemoteAlbum.cs b/src/NzbDrone.Core/Parser/Model/RemoteAlbum.cs index 2b1f0ceb0..9d303bbae 100644 --- a/src/NzbDrone.Core/Parser/Model/RemoteAlbum.cs +++ b/src/NzbDrone.Core/Parser/Model/RemoteAlbum.cs @@ -8,7 +8,7 @@ namespace NzbDrone.Core.Parser.Model public class RemoteAlbum { public ReleaseInfo Release { get; set; } - public ParsedTrackInfo ParsedTrackInfo { get; set; } + public ParsedAlbumInfo ParsedAlbumInfo { get; set; } public Artist Artist { get; set; } public List Albums { get; set; } public bool DownloadAllowed { get; set; } diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index ca1f1e482..25e274916 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -18,7 +18,7 @@ namespace NzbDrone.Core.Parser private static readonly Regex[] ReportMusicTitleRegex = new[] { - // Track with artist (01 - artist - trackName) + // Track with artist (01 - artist - trackName) new Regex(@"(?\d*){0,1}([-| ]{0,1})(?[a-zA-Z0-9, ().&_]*)[-| ]{0,1}(?[a-zA-Z0-9, ().&_]+)", RegexOptions.IgnoreCase | RegexOptions.Compiled), @@ -39,6 +39,29 @@ namespace NzbDrone.Core.Parser RegexOptions.IgnoreCase | RegexOptions.Compiled), }; + private static readonly Regex[] ReportAlbumTitleRegex = new[] + { + //Artist - Album (Year) Strict + new Regex(@"^(?:(?.+?)(?: - )+)(?.+?)\W*(?:\(|\[).+?(?\d{4})", + RegexOptions.IgnoreCase | RegexOptions.Compiled), + + //Artist - Album (Year) + new Regex(@"^(?:(?.+?)(?: - )+)(?.+?)\W*(?:\(|\[)(?\d{4})", + RegexOptions.IgnoreCase | RegexOptions.Compiled), + + //Artist - Album + new Regex(@"^(?:(?.+?)(?: - )+)(?.+?)\W*(?:\(|\[)", + RegexOptions.IgnoreCase | RegexOptions.Compiled), + + //Artist - Album Year + new Regex(@"^(?:(?.+?)(?: - )+)(?.+?)\W*(\d{4}|\d{3})", + RegexOptions.IgnoreCase | RegexOptions.Compiled), + + //Artist Discography + new Regex(@"^(?.+?)\W*(?Discograghy|Discografia).+(?\d{4}).+(?\d{4})", + RegexOptions.IgnoreCase | RegexOptions.Compiled), + }; + private static readonly Regex[] ReportTitleRegex = new[] { //Anime - Absolute Episode Number + Title + Season+Episode @@ -499,6 +522,110 @@ namespace NzbDrone.Core.Parser return null; } + public static ParsedAlbumInfo ParseAlbumTitle(string title) + { + try + { + if (!ValidateBeforeParsing(title)) return null; + + Logger.Debug("Parsing string '{0}'", title); + + if (ReversedTitleRegex.IsMatch(title)) + { + var titleWithoutExtension = RemoveFileExtension(title).ToCharArray(); + Array.Reverse(titleWithoutExtension); + + title = new string(titleWithoutExtension) + title.Substring(titleWithoutExtension.Length); + + Logger.Debug("Reversed name detected. Converted to '{0}'", title); + } + + var simpleTitle = SimpleTitleRegex.Replace(title, string.Empty); + + simpleTitle = RemoveFileExtension(simpleTitle); + + // TODO: Quick fix stripping [url] - prefixes. + simpleTitle = WebsitePrefixRegex.Replace(simpleTitle, string.Empty); + + simpleTitle = CleanTorrentSuffixRegex.Replace(simpleTitle, string.Empty); + + var airDateMatch = AirDateRegex.Match(simpleTitle); + if (airDateMatch.Success) + { + simpleTitle = airDateMatch.Groups[1].Value + airDateMatch.Groups["airyear"].Value + "." + airDateMatch.Groups["airmonth"].Value + "." + airDateMatch.Groups["airday"].Value; + } + + var sixDigitAirDateMatch = SixDigitAirDateRegex.Match(simpleTitle); + if (sixDigitAirDateMatch.Success) + { + var airYear = sixDigitAirDateMatch.Groups["airyear"].Value; + var airMonth = sixDigitAirDateMatch.Groups["airmonth"].Value; + var airDay = sixDigitAirDateMatch.Groups["airday"].Value; + + if (airMonth != "00" || airDay != "00") + { + var fixedDate = string.Format("20{0}.{1}.{2}", airYear, airMonth, airDay); + + simpleTitle = simpleTitle.Replace(sixDigitAirDateMatch.Groups["airdate"].Value, fixedDate); + } + } + + foreach (var regex in ReportAlbumTitleRegex) + { + var match = regex.Matches(simpleTitle); + + if (match.Count != 0) + { + Logger.Trace(regex); + try + { + var result = ParseAlbumMatchCollection(match); + + if (result != null) + { + result.Language = LanguageParser.ParseLanguage(title); + Logger.Debug("Language parsed: {0}", result.Language); + + result.Quality = QualityParser.ParseQuality(title); + Logger.Debug("Quality parsed: {0}", result.Quality); + + result.ReleaseGroup = ParseReleaseGroup(title); + + var subGroup = GetSubGroup(match); + if (!subGroup.IsNullOrWhiteSpace()) + { + result.ReleaseGroup = subGroup; + } + + Logger.Debug("Release Group parsed: {0}", result.ReleaseGroup); + + result.ReleaseHash = GetReleaseHash(match); + if (!result.ReleaseHash.IsNullOrWhiteSpace()) + { + Logger.Debug("Release Hash parsed: {0}", result.ReleaseHash); + } + + return result; + } + } + catch (InvalidDateException ex) + { + Logger.Debug(ex, ex.Message); + break; + } + } + } + } + catch (Exception e) + { + if (!title.ToLower().Contains("password") && !title.ToLower().Contains("yenc")) + Logger.Error(e, "An error has occurred while trying to parse {0}", title); + } + + Logger.Debug("Unable to parse {0}", title); + return null; + } + public static ParsedEpisodeInfo ParseTitle(string title) { try @@ -809,6 +936,30 @@ namespace NzbDrone.Core.Parser return artistTitleInfo; } + private static ParsedAlbumInfo ParseAlbumMatchCollection(MatchCollection matchCollection) + { + var artistName = matchCollection[0].Groups["artist"].Value.Replace('.', ' ').Replace('_', ' '); + var albumTitle = matchCollection[0].Groups["album"].Value.Replace('.', ' ').Replace('_', ' '); + artistName = RequestInfoRegex.Replace(artistName, "").Trim(' '); + albumTitle = RequestInfoRegex.Replace(albumTitle, "").Trim(' '); + + int airYear; + int.TryParse(matchCollection[0].Groups["year"].Value, out airYear); + + ParsedAlbumInfo result; + + result = new ParsedAlbumInfo(); + + result.ArtistName = artistName; + result.AlbumTitle = albumTitle; + result.ArtistTitleInfo = GetArtistTitleInfo(result.ArtistName); + + Logger.Debug("Album Parsed. {0}", result); + + return result; + } + + private static ParsedEpisodeInfo ParseMatchCollection(MatchCollection matchCollection) { var seriesName = matchCollection[0].Groups["title"].Value.Replace('.', ' ').Replace('_', ' '); diff --git a/src/NzbDrone.Core/Parser/ParsingService.cs b/src/NzbDrone.Core/Parser/ParsingService.cs index e8a34a6c0..1e048aeff 100644 --- a/src/NzbDrone.Core/Parser/ParsingService.cs +++ b/src/NzbDrone.Core/Parser/ParsingService.cs @@ -20,7 +20,10 @@ namespace NzbDrone.Core.Parser Series GetSeries(string title); RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria = null); RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, int seriesId, IEnumerable episodeIds); + RemoteAlbum Map(ParsedAlbumInfo parsedAlbumInfo, SearchCriteriaBase searchCriteria = null); + RemoteAlbum Map(ParsedAlbumInfo parsedAlbumInfo, int artistId, IEnumerable albumIds); List GetEpisodes(ParsedEpisodeInfo parsedEpisodeInfo, Series series, bool sceneSource, SearchCriteriaBase searchCriteria = null); + List GetAlbums(ParsedAlbumInfo parsedAlbumInfo, Artist artist, SearchCriteriaBase searchCriteria = null); ParsedEpisodeInfo ParseSpecialEpisodeTitle(string title, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria = null); // Music stuff here @@ -36,19 +39,24 @@ namespace NzbDrone.Core.Parser private readonly IAlbumRepository _albumRepository; private readonly IArtistService _artistService; + private readonly IAlbumService _albumService; private readonly ITrackService _trackService; private readonly Logger _logger; public ParsingService(IEpisodeService episodeService, ISeriesService seriesService, ITrackService trackService, + IArtistService artistService, IAlbumRepository albumRepository, + IAlbumService albumService, // ISceneMappingService sceneMappingService, Logger logger) { _episodeService = episodeService; _seriesService = seriesService; _albumRepository = albumRepository; + _albumService = albumService; + _artistService = artistService; // _sceneMappingService = sceneMappingService; _trackService = trackService; _logger = logger; @@ -128,6 +136,7 @@ namespace NzbDrone.Core.Parser return series; } + [System.Obsolete("Used for sonarr, not lidarr")] public RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria = null) { var remoteEpisode = new RemoteEpisode @@ -148,14 +157,82 @@ namespace NzbDrone.Core.Parser return remoteEpisode; } + public RemoteAlbum Map(ParsedAlbumInfo parsedAlbumInfo, SearchCriteriaBase searchCriteria = null) + { + var remoteAlbum = new RemoteAlbum + { + ParsedAlbumInfo = parsedAlbumInfo, + }; + + var artist = GetArtist(parsedAlbumInfo, searchCriteria); + + if (artist == null) + { + return remoteAlbum; + } + + remoteAlbum.Artist = artist; + remoteAlbum.Albums = GetAlbums(parsedAlbumInfo, artist, searchCriteria); + + return remoteAlbum; + } + + public List GetAlbums(ParsedAlbumInfo parsedAlbumInfo, Artist artist, SearchCriteriaBase searchCriteria = null) + { + var albumTitle = parsedAlbumInfo.AlbumTitle; + var result = new List(); + + if (parsedAlbumInfo.AlbumTitle == null) + { + return new List(); + } + + Album albumInfo = null; + + if (searchCriteria != null) + { + albumInfo = searchCriteria.Albums.SingleOrDefault(e => e.Title == albumTitle); + } + + if (albumInfo == null) + { + albumInfo = _albumService.FindByTitle(artist.Id, parsedAlbumInfo.AlbumTitle); + } + + if (albumInfo != null) + { + result.Add(albumInfo); + } + + else + { + _logger.Debug("Unable to find {0}", parsedAlbumInfo); + } + + + return result; + + } + + [System.Obsolete("Used for sonarr, not lidarr")] public RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, int seriesId, IEnumerable episodeIds) { return new RemoteEpisode - { - ParsedEpisodeInfo = parsedEpisodeInfo, - Series = _seriesService.GetSeries(seriesId), - Episodes = _episodeService.GetEpisodes(episodeIds) - }; + { + ParsedEpisodeInfo = parsedEpisodeInfo, + Series = _seriesService.GetSeries(seriesId), + Episodes = _episodeService.GetEpisodes(episodeIds) + }; + } + + public RemoteAlbum Map(ParsedAlbumInfo parsedAlbumInfo, int artistId, IEnumerable albumIds) + { + return new RemoteAlbum + { + ParsedAlbumInfo = parsedAlbumInfo, + Artist = _artistService.GetArtist(artistId), + Albums = _albumService.GetAlbums(albumIds) + }; } public List GetEpisodes(ParsedEpisodeInfo parsedEpisodeInfo, Series series, bool sceneSource, SearchCriteriaBase searchCriteria = null) @@ -262,6 +339,30 @@ namespace NzbDrone.Core.Parser return null; } + private Artist GetArtist(ParsedAlbumInfo parsedAlbumInfo, SearchCriteriaBase searchCriteria) + { + Artist artist = null; + + if (searchCriteria != null) + { + if (searchCriteria.Artist.CleanName == parsedAlbumInfo.ArtistName.CleanSeriesTitle()) + { + return searchCriteria.Artist; + } + } + + artist = _artistService.FindByName(parsedAlbumInfo.ArtistName); + + if (artist == null) + { + _logger.Debug("No matching series {0}", parsedAlbumInfo.ArtistName); + return null; + } + + return artist; + } + + private Series GetSeries(ParsedEpisodeInfo parsedEpisodeInfo, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria) { Series series = null; @@ -596,8 +697,6 @@ namespace NzbDrone.Core.Parser foreach (var trackNumber in parsedTrackInfo.TrackNumbers) { - - Track trackInfo = null; //if (searchCriteria != null) diff --git a/src/NzbDrone.Core/Queue/Queue.cs b/src/NzbDrone.Core/Queue/Queue.cs index 7164a17ae..54c949baa 100644 --- a/src/NzbDrone.Core/Queue/Queue.cs +++ b/src/NzbDrone.Core/Queue/Queue.cs @@ -6,12 +6,14 @@ using NzbDrone.Core.Indexers; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Queue { public class Queue : ModelBase { - public Series Series { get; set; } + public Artist Artist { get; set; } + public Album Album { get; set; } public Episode Episode { get; set; } public QualityModel Quality { get; set; } public decimal Size { get; set; } @@ -23,7 +25,7 @@ namespace NzbDrone.Core.Queue public string TrackedDownloadStatus { get; set; } public List StatusMessages { get; set; } public string DownloadId { get; set; } - public RemoteEpisode RemoteEpisode { get; set; } + public RemoteAlbum RemoteAlbum { get; set; } public DownloadProtocol Protocol { get; set; } } } diff --git a/src/NzbDrone.Core/Queue/QueueService.cs b/src/NzbDrone.Core/Queue/QueueService.cs index 264645ed8..e86ebee29 100644 --- a/src/NzbDrone.Core/Queue/QueueService.cs +++ b/src/NzbDrone.Core/Queue/QueueService.cs @@ -4,7 +4,7 @@ using System.Linq; using NzbDrone.Common.Crypto; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Queue { @@ -44,11 +44,11 @@ namespace NzbDrone.Core.Queue private IEnumerable MapQueue(TrackedDownload trackedDownload) { - if (trackedDownload.RemoteEpisode.Episodes != null && trackedDownload.RemoteEpisode.Episodes.Any()) + if (trackedDownload.RemoteAlbum.Albums != null && trackedDownload.RemoteAlbum.Albums.Any()) { - foreach (var episode in trackedDownload.RemoteEpisode.Episodes) + foreach (var album in trackedDownload.RemoteAlbum.Albums) { - yield return MapEpisode(trackedDownload, episode); + yield return MapAlbum(trackedDownload, album); } } else @@ -57,14 +57,14 @@ namespace NzbDrone.Core.Queue } } - private Queue MapEpisode(TrackedDownload trackedDownload, Episode episode) + private Queue MapAlbum(TrackedDownload trackedDownload, Album album) { var queue = new Queue { - Id = HashConverter.GetHashInt31(string.Format("trackedDownload-{0}-ep{1}", trackedDownload.DownloadItem.DownloadId, episode.Id)), - Series = trackedDownload.RemoteEpisode.Series, - Episode = episode, - Quality = trackedDownload.RemoteEpisode.ParsedEpisodeInfo.Quality, + Id = HashConverter.GetHashInt31(string.Format("trackedDownload-{0}-album{1}", trackedDownload.DownloadItem.DownloadId, album.Id)), + Artist = trackedDownload.RemoteAlbum.Artist, + Album = album, + Quality = trackedDownload.RemoteAlbum.ParsedAlbumInfo.Quality, Title = trackedDownload.DownloadItem.Title, Size = trackedDownload.DownloadItem.TotalSize, Sizeleft = trackedDownload.DownloadItem.RemainingSize, @@ -72,7 +72,7 @@ namespace NzbDrone.Core.Queue Status = trackedDownload.DownloadItem.Status.ToString(), TrackedDownloadStatus = trackedDownload.Status.ToString(), StatusMessages = trackedDownload.StatusMessages.ToList(), - RemoteEpisode = trackedDownload.RemoteEpisode, + RemoteAlbum = trackedDownload.RemoteAlbum, DownloadId = trackedDownload.DownloadItem.DownloadId, Protocol = trackedDownload.Protocol }; diff --git a/src/NzbDrone.Integration.Test/ApiTests/ReleaseFixture.cs b/src/NzbDrone.Integration.Test/ApiTests/ReleaseFixture.cs index d915b6ca3..fc53ac47f 100644 --- a/src/NzbDrone.Integration.Test/ApiTests/ReleaseFixture.cs +++ b/src/NzbDrone.Integration.Test/ApiTests/ReleaseFixture.cs @@ -48,7 +48,7 @@ namespace NzbDrone.Integration.Test.ApiTests releaseResource.Age.Should().BeGreaterOrEqualTo(-1); releaseResource.Title.Should().NotBeNullOrWhiteSpace(); releaseResource.DownloadUrl.Should().NotBeNullOrWhiteSpace(); - releaseResource.SeriesTitle.Should().NotBeNullOrWhiteSpace(); + releaseResource.ArtistName.Should().NotBeNullOrWhiteSpace(); //TODO: uncomment these after moving to restsharp for rss //releaseResource.NzbInfoUrl.Should().NotBeNullOrWhiteSpace(); //releaseResource.Size.Should().BeGreaterThan(0); diff --git a/src/UI/Activity/History/Details/HistoryDetailsLayoutTemplate.hbs b/src/UI/Activity/History/Details/HistoryDetailsLayoutTemplate.hbs index 892dbfc35..e24b3b861 100644 --- a/src/UI/Activity/History/Details/HistoryDetailsLayoutTemplate.hbs +++ b/src/UI/Activity/History/Details/HistoryDetailsLayoutTemplate.hbs @@ -6,8 +6,8 @@

{{#if_eq eventType compare="grabbed"}}Grabbed{{/if_eq}} {{#if_eq eventType compare="downloadFailed"}}Download Failed{{/if_eq}} - {{#if_eq eventType compare="downloadFolderImported"}}Episode Imported{{/if_eq}} - {{#if_eq eventType compare="episodeFileDeleted"}}Episode File Deleted{{/if_eq}} + {{#if_eq eventType compare="downloadFolderImported"}}Album Imported{{/if_eq}} + {{#if_eq eventType compare="episodeFileDeleted"}}Album Files Deleted{{/if_eq}}

diff --git a/src/UI/Activity/History/HistoryCollection.js b/src/UI/Activity/History/HistoryCollection.js index 3bd564309..1db28c7e4 100644 --- a/src/UI/Activity/History/HistoryCollection.js +++ b/src/UI/Activity/History/HistoryCollection.js @@ -50,15 +50,15 @@ var Collection = PageableCollection.extend({ }, sortMappings : { - 'series' : { sortKey : 'series.sortTitle' } + 'artist' : { sortKey : 'artist.sortName' } }, initialize : function(options) { - delete this.queryParams.episodeId; + delete this.queryParams.albumId; if (options) { - if (options.episodeId) { - this.queryParams.episodeId = options.episodeId; + if (options.albumId) { + this.queryParams.albumId = options.albumId; } } }, diff --git a/src/UI/Activity/History/HistoryLayout.js b/src/UI/Activity/History/HistoryLayout.js index d3d7206ff..ec7f83c33 100644 --- a/src/UI/Activity/History/HistoryLayout.js +++ b/src/UI/Activity/History/HistoryLayout.js @@ -2,9 +2,8 @@ var Marionette = require('marionette'); var Backgrid = require('backgrid'); var HistoryCollection = require('./HistoryCollection'); var EventTypeCell = require('../../Cells/EventTypeCell'); -var SeriesTitleCell = require('../../Cells/SeriesTitleCell'); -var EpisodeNumberCell = require('../../Cells/EpisodeNumberCell'); -var EpisodeTitleCell = require('../../Cells/EpisodeTitleCell'); +var ArtistTitleCell = require('../../Cells/ArtistTitleCell'); +var AlbumTitleCell = require('../../Cells/AlbumTitleCell'); var HistoryQualityCell = require('./HistoryQualityCell'); var RelativeDateCell = require('../../Cells/RelativeDateCell'); var HistoryDetailsCell = require('./HistoryDetailsCell'); @@ -29,20 +28,14 @@ module.exports = Marionette.Layout.extend({ cellValue : 'this' }, { - name : 'series', - label : 'Series', - cell : SeriesTitleCell + name : 'artist', + label : 'Artist', + cell : ArtistTitleCell }, { - name : 'episode', - label : 'Episode', - cell : EpisodeNumberCell, - sortable : false - }, - { - name : 'episode', - label : 'Episode Title', - cell : EpisodeTitleCell, + name : 'album', + label : 'Album Title', + cell : AlbumTitleCell, sortable : false }, { diff --git a/src/UI/Activity/History/HistoryModel.js b/src/UI/Activity/History/HistoryModel.js index f8ec8c538..e37fbedd5 100644 --- a/src/UI/Activity/History/HistoryModel.js +++ b/src/UI/Activity/History/HistoryModel.js @@ -1,12 +1,12 @@ var Backbone = require('backbone'); -var SeriesModel = require('../../Series/SeriesModel'); -var EpisodeModel = require('../../Series/EpisodeModel'); +var ArtistModel = require('../../Artist/ArtistModel'); +var AlbumModel = require('../../Artist/AlbumModel'); module.exports = Backbone.Model.extend({ parse : function(model) { - model.series = new SeriesModel(model.series); - model.episode = new EpisodeModel(model.episode); - model.episode.set('series', model.series); + model.artist = new ArtistModel(model.artist); + model.album = new AlbumModel(model.album); + model.album.set('artist', model.artist); return model; } }); \ No newline at end of file diff --git a/src/UI/Activity/Queue/QueueActionsCell.js b/src/UI/Activity/Queue/QueueActionsCell.js index eb2297fda..9653a71bd 100644 --- a/src/UI/Activity/Queue/QueueActionsCell.js +++ b/src/UI/Activity/Queue/QueueActionsCell.js @@ -41,7 +41,7 @@ module.exports = TemplatedCell.extend({ _grab : function() { var self = this; - var data = _.omit(this.model.toJSON(), 'series', 'episode'); + var data = _.omit(this.model.toJSON(), 'artist', 'album'); var promise = $.ajax({ url : window.NzbDrone.ApiRoot + '/queue/grab', diff --git a/src/UI/Activity/Queue/QueueCollection.js b/src/UI/Activity/Queue/QueueCollection.js index ff390af7f..b0e47070a 100644 --- a/src/UI/Activity/Queue/QueueCollection.js +++ b/src/UI/Activity/Queue/QueueCollection.js @@ -20,34 +20,26 @@ var QueueCollection = PageableCollection.extend({ mode : 'client', - findEpisode : function(episodeId) { + findEpisode : function(albumId) { return _.find(this.fullCollection.models, function(queueModel) { - return queueModel.get('episode').id === episodeId; + return queueModel.get('album').id === albumId; }); }, sortMappings : { - series : { + artist : { sortValue : function(model, attr) { - var series = model.get(attr); + var artist = model.get(attr); - return series.get('sortTitle'); + return artist.get('sortName'); } }, - episode : { + albumTitle : { sortValue : function(model, attr) { - var episode = model.get('episode'); + var album = model.get('album'); - return FormatHelpers.pad(episode.get('seasonNumber'), 4) + FormatHelpers.pad(episode.get('episodeNumber'), 4); - } - }, - - episodeTitle : { - sortValue : function(model, attr) { - var episode = model.get('episode'); - - return episode.get('title'); + return album.get('title'); } }, diff --git a/src/UI/Activity/Queue/QueueLayout.js b/src/UI/Activity/Queue/QueueLayout.js index 462c6a568..028bc40bc 100644 --- a/src/UI/Activity/Queue/QueueLayout.js +++ b/src/UI/Activity/Queue/QueueLayout.js @@ -1,9 +1,8 @@ var Marionette = require('marionette'); var Backgrid = require('backgrid'); var QueueCollection = require('./QueueCollection'); -var SeriesTitleCell = require('../../Cells/SeriesTitleCell'); -var EpisodeNumberCell = require('../../Cells/EpisodeNumberCell'); -var EpisodeTitleCell = require('../../Cells/EpisodeTitleCell'); +var ArtistTitleCell = require('../../Cells/ArtistTitleCell'); +var AlbumTitleCell = require('../../Cells/AlbumTitleCell'); var QualityCell = require('../../Cells/QualityCell'); var QueueStatusCell = require('./QueueStatusCell'); var QueueActionsCell = require('./QueueActionsCell'); @@ -28,20 +27,15 @@ module.exports = Marionette.Layout.extend({ cellValue : 'this' }, { - name : 'series', - label : 'Series', - cell : SeriesTitleCell + name : 'artist', + label : 'Artist', + cell : ArtistTitleCell }, { - name : 'episode', - label : 'Episode', - cell : EpisodeNumberCell - }, - { - name : 'episodeTitle', - label : 'Episode Title', - cell : EpisodeTitleCell, - cellValue : 'episode' + name : 'albumTitle', + label : 'Album Title', + cell : AlbumTitleCell, + cellValue : 'album' }, { name : 'quality', diff --git a/src/UI/Activity/Queue/QueueModel.js b/src/UI/Activity/Queue/QueueModel.js index f8ec8c538..e37fbedd5 100644 --- a/src/UI/Activity/Queue/QueueModel.js +++ b/src/UI/Activity/Queue/QueueModel.js @@ -1,12 +1,12 @@ var Backbone = require('backbone'); -var SeriesModel = require('../../Series/SeriesModel'); -var EpisodeModel = require('../../Series/EpisodeModel'); +var ArtistModel = require('../../Artist/ArtistModel'); +var AlbumModel = require('../../Artist/AlbumModel'); module.exports = Backbone.Model.extend({ parse : function(model) { - model.series = new SeriesModel(model.series); - model.episode = new EpisodeModel(model.episode); - model.episode.set('series', model.series); + model.artist = new ArtistModel(model.artist); + model.album = new AlbumModel(model.album); + model.album.set('artist', model.artist); return model; } }); \ No newline at end of file diff --git a/src/UI/Artist/ArtistCollection.js b/src/UI/Artist/ArtistCollection.js index ed9df3168..8f3822e9c 100644 --- a/src/UI/Artist/ArtistCollection.js +++ b/src/UI/Artist/ArtistCollection.js @@ -15,10 +15,10 @@ var Collection = PageableCollection.extend({ tableName : 'artist', state : { - sortKey : 'sortTitle', + sortKey : 'sortName', order : -1, pageSize : 100000, - secondarySortKey : 'sortTitle', + secondarySortKey : 'sortName', secondarySortOrder : -1 }, @@ -73,7 +73,7 @@ var Collection = PageableCollection.extend({ sortMappings : { title : { - sortKey : 'sortTitle' + sortKey : 'sortName' }, artistName: { diff --git a/src/UI/Artist/Details/AlbumInfoView.js b/src/UI/Artist/Details/AlbumInfoView.js index ea32386d4..0ecbe5d29 100644 --- a/src/UI/Artist/Details/AlbumInfoView.js +++ b/src/UI/Artist/Details/AlbumInfoView.js @@ -1,4 +1,5 @@ var Marionette = require('marionette'); +var FormatHelpers = require('../../Shared/FormatHelpers'); module.exports = Marionette.ItemView.extend({ template : 'Artist/Details/AlbumInfoViewTemplate', @@ -8,4 +9,10 @@ module.exports = Marionette.ItemView.extend({ this.listenTo(this.model, 'change', this.render); }, + templateHelpers : function() { + return { + durationMin : FormatHelpers.timeMinSec(this.model.get('duration')) + }; + } + }); \ No newline at end of file diff --git a/src/UI/Artist/Details/AlbumInfoViewTemplate.hbs b/src/UI/Artist/Details/AlbumInfoViewTemplate.hbs index 4e7409474..2f8aebd67 100644 --- a/src/UI/Artist/Details/AlbumInfoViewTemplate.hbs +++ b/src/UI/Artist/Details/AlbumInfoViewTemplate.hbs @@ -12,6 +12,7 @@ {{ratings.value}} {{/if}} + {{durationMin}} minutes
diff --git a/src/UI/Artist/Details/AlbumLayout.js b/src/UI/Artist/Details/AlbumLayout.js index 3015e9d6b..2b0b99a1b 100644 --- a/src/UI/Artist/Details/AlbumLayout.js +++ b/src/UI/Artist/Details/AlbumLayout.js @@ -10,6 +10,7 @@ var TrackActionsCell = require('../../Cells/TrackActionsCell'); var TrackNumberCell = require('./TrackNumberCell'); var TrackWarningCell = require('./TrackWarningCell'); var TrackRatingCell = require('./TrackRatingCell'); +var TrackDurationCell = require('../../Cells/TrackDurationCell'); var AlbumInfoView = require('./AlbumInfoView'); var CommandController = require('../../Commands/CommandController'); //var TrackFileEditorLayout = require('../../TrackFile/Editor/TrackFileEditorLayout'); @@ -87,12 +88,18 @@ module.exports = Marionette.Layout.extend({ // label : 'Air Date', // cell : RelativeDateCell //}, - { - name : 'status', - label : 'Status', - cell : TrackStatusCell, - sortable : false - }, + { + name : 'duration', + label : 'Duration', + cell : TrackDurationCell, + sortable : false + }, + { + name : 'status', + label : 'Status', + cell : TrackStatusCell, + sortable : false + }, //{ // name : 'this', // label : '', diff --git a/src/UI/Artist/Details/InfoViewTemplate.hbs b/src/UI/Artist/Details/InfoViewTemplate.hbs index 04bd11d8e..2075d3d8f 100644 --- a/src/UI/Artist/Details/InfoViewTemplate.hbs +++ b/src/UI/Artist/Details/InfoViewTemplate.hbs @@ -6,7 +6,6 @@ {{network}} {{/if}} - {{runtime}} minutes {{path}} {{#if ratings}} diff --git a/src/UI/Artist/Index/ArtistIndexLayout.js b/src/UI/Artist/Index/ArtistIndexLayout.js index 3af442537..19769e564 100644 --- a/src/UI/Artist/Index/ArtistIndexLayout.js +++ b/src/UI/Artist/Index/ArtistIndexLayout.js @@ -39,7 +39,7 @@ module.exports = Marionette.Layout.extend({ label : 'Title', cell : ArtistTitleCell, cellValue : 'this', - sortValue : 'sortTitle' + sortValue : 'sortName' }, { name : 'albumCount', diff --git a/src/UI/Cells/TrackDurationCell.js b/src/UI/Cells/TrackDurationCell.js new file mode 100644 index 000000000..d3a9d42ec --- /dev/null +++ b/src/UI/Cells/TrackDurationCell.js @@ -0,0 +1,13 @@ +var Backgrid = require('backgrid'); +var FormatHelpers = require('../Shared/FormatHelpers'); + +module.exports = Backgrid.Cell.extend({ + className : 'track-duration-cell', + + render : function() { + var duration = this.model.get(this.column.get('name')); + this.$el.html(FormatHelpers.timeMinSec(duration,'ms')); + this.delegateEvents(); + return this; + } +}); \ No newline at end of file diff --git a/src/UI/Handlebars/Helpers/Series.js b/src/UI/Handlebars/Helpers/Series.js index 4003a7e5b..dc9af4c97 100644 --- a/src/UI/Handlebars/Helpers/Series.js +++ b/src/UI/Handlebars/Helpers/Series.js @@ -83,16 +83,6 @@ Handlebars.registerHelper ('truncate', function (str, len) { return str; }); -Handlebars.registerHelper('albumCountHelper', function() { - var albumCount = this.albumCount; - - if (albumCount === 1) { - return new Handlebars.SafeString('{0} Albums'.format(albumCount)); - } - - return new Handlebars.SafeString('{0} Albums'.format(albumCount)); -}); - /*Handlebars.registerHelper('titleWithYear', function() { if (this.title.endsWith(' ({0})'.format(this.year))) { return this.title; diff --git a/src/UI/Settings/Profile/Edit/EditProfileLayout.js b/src/UI/Settings/Profile/Edit/EditProfileLayout.js index 0eb0789d5..721b04479 100644 --- a/src/UI/Settings/Profile/Edit/EditProfileLayout.js +++ b/src/UI/Settings/Profile/Edit/EditProfileLayout.js @@ -7,7 +7,7 @@ var EditProfileItemView = require('./EditProfileItemView'); var QualitySortableCollectionView = require('./QualitySortableCollectionView'); var EditProfileView = require('./EditProfileView'); var DeleteView = require('../DeleteProfileView'); -var SeriesCollection = require('../../../Series/SeriesCollection'); +var SeriesCollection = require('../../../Artist/ArtistCollection'); var Config = require('../../../Config'); var AsEditModalView = require('../../../Mixins/AsEditModalView'); @@ -104,7 +104,7 @@ var view = Marionette.Layout.extend({ _updateDisableStatus : function() { if (this._isQualityInUse()) { this.ui.deleteButton.addClass('disabled'); - this.ui.deleteButton.attr('title', 'Can\'t delete a profile that is attached to a series.'); + this.ui.deleteButton.attr('title', 'Can\'t delete a profile that is attached to a artist.'); } else { this.ui.deleteButton.removeClass('disabled'); } diff --git a/src/UI/Settings/Quality/Definition/QualityDefinitionItemView.js b/src/UI/Settings/Quality/Definition/QualityDefinitionItemView.js index b663cf310..d7531ab8d 100644 --- a/src/UI/Settings/Quality/Definition/QualityDefinitionItemView.js +++ b/src/UI/Settings/Quality/Definition/QualityDefinitionItemView.js @@ -9,8 +9,8 @@ var view = Marionette.ItemView.extend({ slider : { min : 0, - max : 200, - step : 0.1 + max : 10, + step : 0.01 }, ui : { diff --git a/src/UI/Settings/Quality/Definition/QualityDefinitionItemViewTemplate.hbs b/src/UI/Settings/Quality/Definition/QualityDefinitionItemViewTemplate.hbs index 39b94b650..a0eaac784 100644 --- a/src/UI/Settings/Quality/Definition/QualityDefinitionItemViewTemplate.hbs +++ b/src/UI/Settings/Quality/Definition/QualityDefinitionItemViewTemplate.hbs @@ -10,21 +10,21 @@
+ title="Minimum size for a 30 minute album"> + title="Minimum size for a 60 minute album">
+ title="Maximum size for a 30 minute album"> + title="Maximum size for a 60 minute album">
diff --git a/src/UI/Shared/FormatHelpers.js b/src/UI/Shared/FormatHelpers.js index 303f60ff6..cdd9b5865 100644 --- a/src/UI/Shared/FormatHelpers.js +++ b/src/UI/Shared/FormatHelpers.js @@ -67,5 +67,27 @@ module.exports = { } return unit + 's'; - } + }, + + timeMinSec : function (s, format) { + + function pad(n, z) { + z = z || 2; + return ('00' + n).slice(-z); + } + + var ms = s % 1000; + s = (s - ms) / 1000; + var secs = s % 60; + s = (s - secs) / 60; + var mins = s; + + if (format === 'ms') { + return pad(mins) + ':' + pad(secs) + '.' + pad(ms,3); + } else { + return pad(mins); + } + }, + + }; \ No newline at end of file