diff --git a/src/NzbDrone.Api/Queue/QueueResource.cs b/src/NzbDrone.Api/Queue/QueueResource.cs index cf1356c49..e90a9bace 100644 --- a/src/NzbDrone.Api/Queue/QueueResource.cs +++ b/src/NzbDrone.Api/Queue/QueueResource.cs @@ -4,6 +4,7 @@ using NzbDrone.Core.Qualities; using NzbDrone.Api.Series; using NzbDrone.Api.Episodes; +using NzbDrone.Api.Movie; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.Indexers; using System.Linq; @@ -14,6 +15,7 @@ public class QueueResource : RestResource { public SeriesResource Series { get; set; } public EpisodeResource Episode { get; set; } + public MovieResource Movie { get; set; } public QualityModel Quality { get; set; } public decimal Size { get; set; } public string Title { get; set; } @@ -49,7 +51,8 @@ public static QueueResource ToResource(this Core.Queue.Queue model) TrackedDownloadStatus = model.TrackedDownloadStatus, StatusMessages = model.StatusMessages, DownloadId = model.DownloadId, - Protocol = model.Protocol + Protocol = model.Protocol, + Movie = model.Movie.ToResource() }; } diff --git a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs index 8585a1704..d5fbff7d8 100644 --- a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs +++ b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs @@ -33,6 +33,7 @@ public interface IPendingReleaseService public class PendingReleaseService : IPendingReleaseService, IHandle, IHandle, + IHandle, IHandle { private readonly IIndexerStatusService _indexerStatusService; @@ -341,6 +342,11 @@ public void Handle(EpisodeGrabbedEvent message) RemoveGrabbed(message.Episode); } + public void Handle(MovieGrabbedEvent message) + { + + } + public void Handle(RssSyncCompleteEvent message) { RemoveRejected(message.ProcessedDecisions.Rejected); diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs index be012d57b..57ce35578 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs @@ -10,6 +10,7 @@ public class TrackedDownload public TrackedDownloadStage State { get; set; } public TrackedDownloadStatus Status { get; private set; } public RemoteEpisode RemoteEpisode { get; set; } + public RemoteMovie RemoteMovie { 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..c7ba36cbc 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs @@ -62,6 +62,7 @@ public TrackedDownload TrackDownload(DownloadClientDefinition downloadClient, Do if (parsedEpisodeInfo != null) { trackedDownload.RemoteEpisode = _parsingService.Map(parsedEpisodeInfo, 0, 0); + trackedDownload.RemoteMovie = _parsingService.Map(parsedEpisodeInfo, "", null); } if (historyItems.Any()) @@ -69,10 +70,10 @@ public TrackedDownload TrackDownload(DownloadClientDefinition downloadClient, Do var firstHistoryItem = historyItems.OrderByDescending(h => h.Date).First(); trackedDownload.State = GetStateFromHistory(firstHistoryItem.EventType); - if (parsedEpisodeInfo == null || + if ((parsedEpisodeInfo == null || trackedDownload.RemoteEpisode == null || trackedDownload.RemoteEpisode.Series == null || - trackedDownload.RemoteEpisode.Episodes.Empty()) + trackedDownload.RemoteEpisode.Episodes.Empty()) && trackedDownload.RemoteMovie == null) { // 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 @@ -85,7 +86,7 @@ public TrackedDownload TrackDownload(DownloadClientDefinition downloadClient, Do } } - if (trackedDownload.RemoteEpisode == null) + if (trackedDownload.RemoteEpisode == null && trackedDownload.RemoteMovie == null) { return null; } diff --git a/src/NzbDrone.Core/Queue/Queue.cs b/src/NzbDrone.Core/Queue/Queue.cs index 7164a17ae..851c404e2 100644 --- a/src/NzbDrone.Core/Queue/Queue.cs +++ b/src/NzbDrone.Core/Queue/Queue.cs @@ -13,6 +13,7 @@ public class Queue : ModelBase { public Series Series { get; set; } public Episode Episode { get; set; } + public Movie Movie { get; set; } public QualityModel Quality { get; set; } public decimal Size { get; set; } public string Title { get; set; } @@ -24,6 +25,7 @@ public class Queue : ModelBase public List StatusMessages { get; set; } public string DownloadId { get; set; } public RemoteEpisode RemoteEpisode { get; set; } + public RemoteMovie RemoteMovie { 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..d867b4ddb 100644 --- a/src/NzbDrone.Core/Queue/QueueService.cs +++ b/src/NzbDrone.Core/Queue/QueueService.cs @@ -51,12 +51,42 @@ private IEnumerable MapQueue(TrackedDownload trackedDownload) yield return MapEpisode(trackedDownload, episode); } } - else + else if (trackedDownload.RemoteMovie.Movie != null) { - // FIXME: Present queue items with unknown series/episodes + yield return MapMovie(trackedDownload, trackedDownload.RemoteMovie.Movie); } } + private Queue MapMovie(TrackedDownload trackedDownload, Movie movie) + { + var queue = new Queue + { + Id = HashConverter.GetHashInt31(string.Format("trackedDownload-{0}", trackedDownload.DownloadItem.DownloadId)), + Series = null, + Episode = null, + Quality = trackedDownload.RemoteMovie.ParsedEpisodeInfo.Quality, + Title = trackedDownload.DownloadItem.Title, + Size = trackedDownload.DownloadItem.TotalSize, + Sizeleft = trackedDownload.DownloadItem.RemainingSize, + Timeleft = trackedDownload.DownloadItem.RemainingTime, + Status = trackedDownload.DownloadItem.Status.ToString(), + TrackedDownloadStatus = trackedDownload.Status.ToString(), + StatusMessages = trackedDownload.StatusMessages.ToList(), + RemoteEpisode = trackedDownload.RemoteEpisode, + RemoteMovie = trackedDownload.RemoteMovie, + DownloadId = trackedDownload.DownloadItem.DownloadId, + Protocol = trackedDownload.Protocol, + Movie = movie + }; + + if (queue.Timeleft.HasValue) + { + queue.EstimatedCompletionTime = DateTime.UtcNow.Add(queue.Timeleft.Value); + } + + return queue; + } + private Queue MapEpisode(TrackedDownload trackedDownload, Episode episode) { var queue = new Queue diff --git a/src/UI/Activity/Queue/QueueCollection.js b/src/UI/Activity/Queue/QueueCollection.js index 474cafe6b..bd3aa065e 100644 --- a/src/UI/Activity/Queue/QueueCollection.js +++ b/src/UI/Activity/Queue/QueueCollection.js @@ -35,6 +35,14 @@ var QueueCollection = PageableCollection.extend({ } }, + movie : { + sortValue : function(model, attr) { + var movie = model.get(attr); + + return movie.get('sortTitle'); + } + }, + episode : { sortValue : function(model, attr) { var episode = model.get('episode'); @@ -84,4 +92,4 @@ QueueCollection = AsPageableCollection.call(QueueCollection); var collection = new QueueCollection().bindSignalR(); collection.fetch(); -module.exports = collection; \ No newline at end of file +module.exports = collection; diff --git a/src/UI/Activity/Queue/QueueLayout.js b/src/UI/Activity/Queue/QueueLayout.js index 462c6a568..4416cb07b 100644 --- a/src/UI/Activity/Queue/QueueLayout.js +++ b/src/UI/Activity/Queue/QueueLayout.js @@ -1,7 +1,7 @@ var Marionette = require('marionette'); var Backgrid = require('backgrid'); var QueueCollection = require('./QueueCollection'); -var SeriesTitleCell = require('../../Cells/SeriesTitleCell'); +var SeriesTitleCell = require('../../Cells/MovieTitleCell'); var EpisodeNumberCell = require('../../Cells/EpisodeNumberCell'); var EpisodeTitleCell = require('../../Cells/EpisodeTitleCell'); var QualityCell = require('../../Cells/QualityCell'); @@ -28,11 +28,11 @@ module.exports = Marionette.Layout.extend({ cellValue : 'this' }, { - name : 'series', - label : 'Series', + name : 'movie', + label : 'Movie', cell : SeriesTitleCell }, - { + /*{ name : 'episode', label : 'Episode', cell : EpisodeNumberCell @@ -42,7 +42,7 @@ module.exports = Marionette.Layout.extend({ label : 'Episode Title', cell : EpisodeTitleCell, cellValue : 'episode' - }, + },*/ { name : 'quality', label : 'Quality', diff --git a/src/UI/Activity/Queue/QueueModel.js b/src/UI/Activity/Queue/QueueModel.js index f8ec8c538..e9b3fb045 100644 --- a/src/UI/Activity/Queue/QueueModel.js +++ b/src/UI/Activity/Queue/QueueModel.js @@ -1,12 +1,14 @@ var Backbone = require('backbone'); var SeriesModel = require('../../Series/SeriesModel'); var EpisodeModel = require('../../Series/EpisodeModel'); +var MovieModel = require('../../Movies/MovieModel'); 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.movie = new MovieModel(model.movie); return model; } -}); \ No newline at end of file +});