diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DelaySpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DelaySpecificationFixture.cs index 2bbe1ae24..22871eb53 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DelaySpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DelaySpecificationFixture.cs @@ -26,7 +26,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync { private Profile _profile; private DelayProfile _delayProfile; - private RemoteEpisode _remoteEpisode; + private RemoteMovie _remoteEpisode; [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 series = Builder.CreateNew() .With(s => s.Profile = _profile) .Build(); - _remoteEpisode = Builder.CreateNew() - .With(r => r.Series = series) + _remoteEpisode = Builder.CreateNew() + .With(r => r.Movie = series) .Build(); _profile.Items = new List(); @@ -53,30 +53,30 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync _profile.Cutoff = Quality.WEBDL720p; - _remoteEpisode.ParsedEpisodeInfo = new ParsedEpisodeInfo(); + _remoteEpisode.ParsedMovieInfo = new ParsedMovieInfo(); _remoteEpisode.Release = new ReleaseInfo(); _remoteEpisode.Release.DownloadProtocol = DownloadProtocol.Usenet; - _remoteEpisode.Episodes = Builder.CreateListOfSize(1).Build().ToList(); - _remoteEpisode.Episodes.First().EpisodeFileId = 0; + //_remoteEpisode.Episodes = Builder.CreateListOfSize(1).Build().ToList(); + //_remoteEpisode.Episodes.First().EpisodeFileId = 0; - Mocker.GetMock() - .Setup(s => s.BestForTags(It.IsAny>())) - .Returns(_delayProfile); + //Mocker.GetMock() + // .Setup(s => s.BestForTags(It.IsAny>())) + // .Returns(_delayProfile); - Mocker.GetMock() - .Setup(s => s.GetPendingRemoteEpisodes(It.IsAny())) - .Returns(new List()); + //Mocker.GetMock() + // .Setup(s => s.GetPendingRemoteEpisodes(It.IsAny())) + // .Returns(new List()); } private void GivenExistingFile(QualityModel quality) { - _remoteEpisode.Episodes.First().EpisodeFileId = 1; + //_remoteEpisode.Episodes.First().EpisodeFileId = 1; - _remoteEpisode.Episodes.First().EpisodeFile = new LazyLoaded(new EpisodeFile - { - Quality = quality - }); + //_remoteEpisode.Episodes.First().EpisodeFile = new LazyLoaded(new EpisodeFile + // { + // Quality = quality + // }); } private void GivenUpgradeForExistingFile() diff --git a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveGrabbedFixture.cs b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveGrabbedFixture.cs index b70f24fdc..a4af21cac 100644 --- a/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveGrabbedFixture.cs +++ b/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemoveGrabbedFixture.cs @@ -20,22 +20,19 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests public class RemoveGrabbedFixture : CoreTest { private DownloadDecision _temporarilyRejected; - private Series _series; + private Movie _series; private Episode _episode; private Profile _profile; private ReleaseInfo _release; - private ParsedEpisodeInfo _parsedEpisodeInfo; - private RemoteEpisode _remoteEpisode; + private ParsedMovieInfo _parsedEpisodeInfo; + private RemoteMovie _remoteEpisode; [SetUp] public void Setup() { - _series = Builder.CreateNew() + _series = Builder.CreateNew() .Build(); - _episode = Builder.CreateNew() - .Build(); - _profile = new Profile { Name = "Test", @@ -52,13 +49,13 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests _release = Builder.CreateNew().Build(); - _parsedEpisodeInfo = Builder.CreateNew().Build(); + _parsedEpisodeInfo = Builder.CreateNew().Build(); _parsedEpisodeInfo.Quality = new QualityModel(Quality.HDTV720p); - _remoteEpisode = new RemoteEpisode(); - _remoteEpisode.Episodes = new List{ _episode }; - _remoteEpisode.Series = _series; - _remoteEpisode.ParsedEpisodeInfo = _parsedEpisodeInfo; + _remoteEpisode = new RemoteMovie(); + //_remoteEpisode.Episodes = new List{ _episode }; + _remoteEpisode.Movie = _series; + _remoteEpisode.ParsedMovieInfo = _parsedEpisodeInfo; _remoteEpisode.Release = _release; _temporarilyRejected = new DownloadDecision(_remoteEpisode, new Rejection("Temp Rejected", RejectionType.Temporary)); @@ -67,13 +64,13 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests .Setup(s => s.All()) .Returns(new List()); - Mocker.GetMock() - .Setup(s => s.GetSeries(It.IsAny())) + Mocker.GetMock() + .Setup(s => s.GetMovie(It.IsAny())) .Returns(_series); - Mocker.GetMock() - .Setup(s => s.GetEpisodes(It.IsAny(), _series, true, null)) - .Returns(new List {_episode}); + //Mocker.GetMock() + // .Setup(s => s.GetMovie(It.IsAny(), _series.Title)) + // .Returns(_episode); Mocker.GetMock() .Setup(s => s.PrioritizeDecisions(It.IsAny>())) @@ -89,7 +86,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests .All() .With(h => h.SeriesId = _series.Id) .With(h => h.Release = _release.JsonClone()) - .With(h => h.ParsedEpisodeInfo = parsedEpisodeInfo) + .With(h => h.ParsedMovieInfo = _parsedEpisodeInfo) .Build(); Mocker.GetMock() @@ -102,7 +99,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests { GivenHeldRelease(_parsedEpisodeInfo.Quality); - Subject.Handle(new EpisodeGrabbedEvent(_remoteEpisode)); + Subject.Handle(new MovieGrabbedEvent(_remoteEpisode)); VerifyDelete(); } @@ -112,7 +109,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests { GivenHeldRelease(new QualityModel(Quality.SDTV)); - Subject.Handle(new EpisodeGrabbedEvent(_remoteEpisode)); + Subject.Handle(new MovieGrabbedEvent(_remoteEpisode)); VerifyDelete(); } @@ -122,7 +119,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests { GivenHeldRelease(new QualityModel(Quality.Bluray720p)); - Subject.Handle(new EpisodeGrabbedEvent(_remoteEpisode)); + Subject.Handle(new MovieGrabbedEvent(_remoteEpisode)); VerifyNoDelete(); } diff --git a/src/NzbDrone.Core/Datastore/Migration/129_add_parsed_movie_info_to_pending_release.cs b/src/NzbDrone.Core/Datastore/Migration/129_add_parsed_movie_info_to_pending_release.cs new file mode 100644 index 000000000..c2ea6e8f3 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/129_add_parsed_movie_info_to_pending_release.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; +using System.Data; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(129)] + public class add_parsed_movie_info_to_pending_release : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Alter.Table("PendingReleases").AddColumn("ParsedMovieInfo").AsString().Nullable(); + } + } +} diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DelaySpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DelaySpecification.cs index b3d8cf7e2..2c3192fd8 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DelaySpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DelaySpecification.cs @@ -91,19 +91,19 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync return Decision.Accept(); } - /* - var oldest = _pendingReleaseService.OldestPendingRelease(subject.Series.Id, episodeIds); + + var oldest = _pendingReleaseService.OldestPendingRelease(subject.Movie.Id); if (oldest != null && oldest.Release.AgeMinutes > delay) { return Decision.Accept(); - }*/ + } if (subject.Release.AgeMinutes < delay) { _logger.Debug("Waiting for better quality release, There is a {0} minute delay on {1}", delay, subject.Release.DownloadProtocol); return Decision.Reject("Waiting for better quality release"); - } //TODO: Update for movies! + } return Decision.Accept(); } @@ -158,14 +158,14 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync return Decision.Accept(); } - var episodeIds = subject.Episodes.Select(e => e.Id); + // var episodeIds = subject.Episodes.Select(e => e.Id); - var oldest = _pendingReleaseService.OldestPendingRelease(subject.Series.Id, episodeIds); + //var oldest = _pendingReleaseService.OldestPendingRelease(subject.Series.Id, episodeIds); - if (oldest != null && oldest.Release.AgeMinutes > delay) - { - return Decision.Accept(); - } + //if (oldest != null && oldest.Release.AgeMinutes > delay) + //{ + // return Decision.Accept(); + //} if (subject.Release.AgeMinutes < delay) { diff --git a/src/NzbDrone.Core/Download/Pending/PendingRelease.cs b/src/NzbDrone.Core/Download/Pending/PendingRelease.cs index 504db7e36..4994a3cfe 100644 --- a/src/NzbDrone.Core/Download/Pending/PendingRelease.cs +++ b/src/NzbDrone.Core/Download/Pending/PendingRelease.cs @@ -11,6 +11,7 @@ namespace NzbDrone.Core.Download.Pending public string Title { get; set; } public DateTime Added { get; set; } public ParsedEpisodeInfo ParsedEpisodeInfo { get; set; } + public ParsedMovieInfo ParsedMovieInfo { get; set; } public ReleaseInfo Release { get; set; } //Not persisted diff --git a/src/NzbDrone.Core/Download/Pending/PendingReleaseRepository.cs b/src/NzbDrone.Core/Download/Pending/PendingReleaseRepository.cs index b98334978..162aa76c4 100644 --- a/src/NzbDrone.Core/Download/Pending/PendingReleaseRepository.cs +++ b/src/NzbDrone.Core/Download/Pending/PendingReleaseRepository.cs @@ -8,6 +8,8 @@ namespace NzbDrone.Core.Download.Pending { void DeleteBySeriesId(int seriesId); List AllBySeriesId(int seriesId); + void DeleteByMovieId(int movieId); + List AllByMovieId(int movieId); } public class PendingReleaseRepository : BasicRepository, IPendingReleaseRepository @@ -26,5 +28,15 @@ namespace NzbDrone.Core.Download.Pending { return Query.Where(p => p.SeriesId == seriesId); } + + public void DeleteByMovieId(int movieId) + { + Delete(r => r.MovieId == movieId); + } + + public List AllByMovieId(int movieId) + { + return Query.Where(p => p.MovieId == movieId); + } } } \ 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 5a53e2d18..b88af6c61 100644 --- a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs +++ b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs @@ -23,22 +23,21 @@ namespace NzbDrone.Core.Download.Pending void Add(DownloadDecision decision); List GetPending(); - List GetPendingRemoteEpisodes(int seriesId); + List GetPendingRemoteMovies(int movieId); List GetPendingQueue(); Queue.Queue FindPendingQueueItem(int queueId); void RemovePendingQueueItems(int queueId); - RemoteEpisode OldestPendingRelease(int seriesId, IEnumerable episodeIds); + RemoteMovie OldestPendingRelease(int movieId); } public class PendingReleaseService : IPendingReleaseService, - IHandle, - IHandle, IHandle, + IHandle, IHandle { private readonly IIndexerStatusService _indexerStatusService; private readonly IPendingReleaseRepository _repository; - private readonly ISeriesService _seriesService; + private readonly IMovieService _movieService; private readonly IParsingService _parsingService; private readonly IDelayProfileService _delayProfileService; private readonly ITaskManager _taskManager; @@ -48,7 +47,7 @@ namespace NzbDrone.Core.Download.Pending public PendingReleaseService(IIndexerStatusService indexerStatusService, IPendingReleaseRepository repository, - ISeriesService seriesService, + IMovieService movieService, IParsingService parsingService, IDelayProfileService delayProfileService, ITaskManager taskManager, @@ -58,7 +57,7 @@ namespace NzbDrone.Core.Download.Pending { _indexerStatusService = indexerStatusService; _repository = repository; - _seriesService = seriesService; + _movieService = movieService; _parsingService = parsingService; _delayProfileService = delayProfileService; _taskManager = taskManager; @@ -72,13 +71,11 @@ namespace NzbDrone.Core.Download.Pending { var alreadyPending = GetPendingReleases(); - var episodeIds = decision.RemoteEpisode.Episodes.Select(e => e.Id); + var movieId = decision.RemoteMovie.Movie.Id; - var existingReports = alreadyPending.Where(r => r.RemoteEpisode.Episodes.Select(e => e.Id) - .Intersect(episodeIds) - .Any()); + var existingReports = alreadyPending.Where(r => r.RemoteMovie.Movie.Id == movieId); - if (existingReports.Any(MatchingReleasePredicate(decision.RemoteEpisode.Release))) + if (existingReports.Any(MatchingReleasePredicate(decision.RemoteMovie.Release))) { _logger.Debug("This release is already pending, not adding again"); return; @@ -107,9 +104,9 @@ namespace NzbDrone.Core.Download.Pending return releases.Where(release => !blockedIndexers.Contains(release.IndexerId)).ToList(); } - public List GetPendingRemoteEpisodes(int seriesId) + public List GetPendingRemoteMovies(int movieId) { - return _repository.AllBySeriesId(seriesId).Select(GetRemoteEpisode).ToList(); + return _repository.AllByMovieId(movieId).Select(GetRemoteMovie).ToList(); } public List GetPendingQueue() @@ -120,9 +117,9 @@ namespace NzbDrone.Core.Download.Pending foreach (var pendingRelease in GetPendingReleases()) { - foreach (var episode in pendingRelease.RemoteEpisode.Episodes) - { - var ect = pendingRelease.Release.PublishDate.AddMinutes(GetDelay(pendingRelease.RemoteEpisode)); + //foreach (var episode in pendingRelease.RemoteEpisode.Episodes) + //{ + var ect = pendingRelease.Release.PublishDate.AddMinutes(GetDelay(pendingRelease.RemoteMovie)); if (ect < nextRssSync.Value) { @@ -135,21 +132,22 @@ 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, pendingRelease.RemoteMovie.Movie), + Series = null, + Episode = null, + Movie = pendingRelease.RemoteMovie.Movie, + Quality = pendingRelease.RemoteMovie.ParsedMovieInfo.Quality, Title = pendingRelease.Title, - Size = pendingRelease.RemoteEpisode.Release.Size, - Sizeleft = pendingRelease.RemoteEpisode.Release.Size, - RemoteEpisode = pendingRelease.RemoteEpisode, + Size = pendingRelease.RemoteMovie.Release.Size, + Sizeleft = pendingRelease.RemoteMovie.Release.Size, + RemoteMovie = pendingRelease.RemoteMovie, Timeleft = ect.Subtract(DateTime.UtcNow), EstimatedCompletionTime = ect, Status = "Pending", - Protocol = pendingRelease.RemoteEpisode.Release.DownloadProtocol + Protocol = pendingRelease.RemoteMovie.Release.DownloadProtocol }; queued.Add(queue); - } + //} } //Return best quality release for each episode @@ -158,7 +156,7 @@ namespace NzbDrone.Core.Download.Pending var series = g.First().Series; return g.OrderByDescending(e => e.Quality, new QualityModelComparer(series.Profile)) - .ThenBy(q => PrioritizeDownloadProtocol(q.Series, q.Protocol)) + .ThenBy(q => PrioritizeDownloadProtocol(q.Movie, q.Protocol)) .First(); }); @@ -173,20 +171,16 @@ namespace NzbDrone.Core.Download.Pending public void RemovePendingQueueItems(int queueId) { var targetItem = FindPendingRelease(queueId); - var seriesReleases = _repository.AllBySeriesId(targetItem.SeriesId); + var movieReleases = _repository.AllByMovieId(targetItem.MovieId); - var releasesToRemove = seriesReleases.Where( - c => c.ParsedEpisodeInfo.SeasonNumber == targetItem.ParsedEpisodeInfo.SeasonNumber && - c.ParsedEpisodeInfo.EpisodeNumbers.SequenceEqual(targetItem.ParsedEpisodeInfo.EpisodeNumbers)); + var releasesToRemove = movieReleases.Where(c => c.ParsedMovieInfo.MovieTitle == targetItem.ParsedMovieInfo.MovieTitle); _repository.DeleteMany(releasesToRemove.Select(c => c.Id)); } - public RemoteEpisode OldestPendingRelease(int seriesId, IEnumerable episodeIds) + public RemoteMovie OldestPendingRelease(int movieId) { - return GetPendingRemoteEpisodes(seriesId).Where(r => r.Episodes.Select(e => e.Id).Intersect(episodeIds).Any()) - .OrderByDescending(p => p.Release.AgeHours) - .FirstOrDefault(); + return GetPendingRemoteMovies(movieId).OrderByDescending(p => p.Release.AgeHours).FirstOrDefault(); } private List GetPendingReleases() @@ -195,11 +189,11 @@ namespace NzbDrone.Core.Download.Pending foreach (var release in _repository.All()) { - var remoteEpisode = GetRemoteEpisode(release); + var remoteMovie = GetRemoteMovie(release); - if (remoteEpisode == null) continue; + if (remoteMovie == null) continue; - release.RemoteEpisode = remoteEpisode; + release.RemoteMovie = remoteMovie; result.Add(release); } @@ -207,20 +201,19 @@ namespace NzbDrone.Core.Download.Pending return result; } - private RemoteEpisode GetRemoteEpisode(PendingRelease release) + private RemoteMovie GetRemoteMovie(PendingRelease release) { - var series = _seriesService.GetSeries(release.SeriesId); + var movie = _movieService.GetMovie(release.MovieId); //Just in case the series was removed, but wasn't cleaned up yet (housekeeper will clean it up) - if (series == null) return null; + if (movie == null) return null; - var episodes = _parsingService.GetEpisodes(release.ParsedEpisodeInfo, series, true); + // var episodes = _parsingService.GetMovie(release.ParsedMovieInfo.MovieTitle); - return new RemoteEpisode + return new RemoteMovie { - Series = series, - Episodes = episodes, - ParsedEpisodeInfo = release.ParsedEpisodeInfo, + Movie = movie, + ParsedMovieInfo = release.ParsedMovieInfo, Release = release.Release }; } @@ -229,10 +222,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, + MovieId = decision.RemoteMovie.Movie.Id, + ParsedMovieInfo = decision.RemoteMovie.ParsedMovieInfo, + Release = decision.RemoteMovie.Release, + Title = decision.RemoteMovie.Release.Title, Added = DateTime.UtcNow }); @@ -252,46 +245,46 @@ namespace NzbDrone.Core.Download.Pending p.Release.Indexer == release.Indexer; } - private int GetDelay(RemoteEpisode remoteEpisode) + private int GetDelay(RemoteMovie remoteMovie) { - var delayProfile = _delayProfileService.AllForTags(remoteEpisode.Series.Tags).OrderBy(d => d.Order).First(); - var delay = delayProfile.GetProtocolDelay(remoteEpisode.Release.DownloadProtocol); + var delayProfile = _delayProfileService.AllForTags(remoteMovie.Movie.Tags).OrderBy(d => d.Order).First(); + var delay = delayProfile.GetProtocolDelay(remoteMovie.Release.DownloadProtocol); var minimumAge = _configService.MinimumAge; return new[] { delay, minimumAge }.Max(); } - private void RemoveGrabbed(RemoteEpisode remoteEpisode) - { - var pendingReleases = GetPendingReleases(); - var episodeIds = remoteEpisode.Episodes.Select(e => e.Id); - - var existingReports = pendingReleases.Where(r => r.RemoteEpisode.Episodes.Select(e => e.Id) - .Intersect(episodeIds) - .Any()) - .ToList(); - - if (existingReports.Empty()) - { - return; - } - - var profile = remoteEpisode.Series.Profile.Value; - - foreach (var existingReport in existingReports) - { - var compare = new QualityModelComparer(profile).Compare(remoteEpisode.ParsedEpisodeInfo.Quality, - existingReport.RemoteEpisode.ParsedEpisodeInfo.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) - if (compare >= 0) - { - _logger.Debug("Removing previously pending release, as it was grabbed."); - Delete(existingReport); - } - } - } + //private void RemoveGrabbed(RemoteEpisode remoteEpisode) + //{ + // var pendingReleases = GetPendingReleases(); + // var episodeIds = remoteEpisode.Episodes.Select(e => e.Id); + + // var existingReports = pendingReleases.Where(r => r.RemoteEpisode.Episodes.Select(e => e.Id) + // .Intersect(episodeIds) + // .Any()) + // .ToList(); + + // if (existingReports.Empty()) + // { + // return; + // } + + // var profile = remoteEpisode.Series.Profile.Value; + + // foreach (var existingReport in existingReports) + // { + // var compare = new QualityModelComparer(profile).Compare(remoteEpisode.ParsedEpisodeInfo.Quality, + // existingReport.RemoteEpisode.ParsedEpisodeInfo.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) + // if (compare >= 0) + // { + // _logger.Debug("Removing previously pending release, as it was grabbed."); + // Delete(existingReport); + // } + // } + //} private void RemoveRejected(List rejected) { @@ -300,7 +293,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.RemoteMovie.Release)); foreach (var pendingRelease in matching) { @@ -312,17 +305,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 => queueId == GetQueueId(p, p.RemoteMovie.Movie)); } - private int GetQueueId(PendingRelease pendingRelease, Episode episode) + private int GetQueueId(PendingRelease pendingRelease, Movie movie) { - return HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", pendingRelease.Id, episode.Id)); + return HashConverter.GetHashInt31(string.Format("pending-{0}-movie{1}", pendingRelease.Id, movie.Id)); } - private int PrioritizeDownloadProtocol(Series series, DownloadProtocol downloadProtocol) + private int PrioritizeDownloadProtocol(Movie movie, DownloadProtocol downloadProtocol) { - var delayProfile = _delayProfileService.BestForTags(series.Tags); + var delayProfile = _delayProfileService.BestForTags(movie.Tags); if (downloadProtocol == delayProfile.PreferredProtocol) { @@ -332,14 +325,9 @@ namespace NzbDrone.Core.Download.Pending return 1; } - public void Handle(SeriesDeletedEvent message) - { - _repository.DeleteBySeriesId(message.Series.Id); - } - - public void Handle(EpisodeGrabbedEvent message) + public void Handle(MovieDeletedEvent message) { - RemoveGrabbed(message.Episode); + _repository.DeleteByMovieId(message.Movie.Id); } public void Handle(MovieGrabbedEvent message) diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedPendingReleases.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedPendingReleases.cs index 0366d7321..e993c9686 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 Movies + ON PendingReleases.MovieId = Movies.Id + WHERE Movies.Id IS NULL)"); } } } diff --git a/src/NzbDrone.Core/NetImport/RSSImport/RSSImport.cs b/src/NzbDrone.Core/NetImport/RSSImport/RSSImport.cs index a68b4190d..d7d9dde09 100644 --- a/src/NzbDrone.Core/NetImport/RSSImport/RSSImport.cs +++ b/src/NzbDrone.Core/NetImport/RSSImport/RSSImport.cs @@ -33,13 +33,22 @@ namespace NzbDrone.Core.NetImport.RSSImport } yield return new NetImportDefinition { - Name = "IMDb Watchlist", + Name = "IMDb List", Enabled = Enabled, EnableAuto = true, ProfileId = 1, Implementation = GetType().Name, Settings = new RSSImportSettings { Link = "http://rss.imdb.com/list/YOURLISTID" }, }; + yield return new NetImportDefinition + { + Name = "IMDb Watchlist", + Enabled = Enabled, + EnableAuto = true, + ProfileId = 1, + Implementation = GetType().Name, + Settings = new RSSImportSettings { Link = "http://rss.imdb.com/user/IMDBUSERID/watchlist" }, + }; } } diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 37bfae84f..11d686eea 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -124,6 +124,7 @@ +