mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-23 22:25:09 -04:00
New: Release Profiles, Frontend updates (#580)
* New: Release Profiles - UI Updates * New: Release Profiles - API Changes * New: Release Profiles - Test Updates * New: Release Profiles - Backend Updates * New: Interactive Artist Search * New: Change Montiored on Album Details Page * New: Show Duration on Album Details Page * Fixed: Manual Import not working if no albums are Missing * Fixed: Sort search input by sortTitle * Fixed: Queue columnLabel throwing JS error
This commit is contained in:
@@ -3,8 +3,10 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.Crypto;
|
||||
using NzbDrone.Core.Download.TrackedDownloads;
|
||||
using NzbDrone.Core.Languages;
|
||||
using NzbDrone.Core.History;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Queue
|
||||
@@ -44,30 +46,22 @@ namespace NzbDrone.Core.Queue
|
||||
_queue.Remove(Find(id));
|
||||
}
|
||||
|
||||
public void Handle(TrackedDownloadRefreshedEvent message)
|
||||
{
|
||||
_queue = message.TrackedDownloads.OrderBy(c => c.DownloadItem.RemainingTime).SelectMany(MapQueue)
|
||||
.ToList();
|
||||
|
||||
_eventAggregator.PublishEvent(new QueueUpdatedEvent());
|
||||
}
|
||||
|
||||
private IEnumerable<Queue> MapQueue(TrackedDownload trackedDownload)
|
||||
{
|
||||
if (trackedDownload.RemoteAlbum.Albums != null && trackedDownload.RemoteAlbum.Albums.Any())
|
||||
if (trackedDownload.RemoteAlbum?.Albums != null && trackedDownload.RemoteAlbum.Albums.Any())
|
||||
{
|
||||
foreach (var album in trackedDownload.RemoteAlbum.Albums)
|
||||
{
|
||||
yield return MapAlbum(trackedDownload, album);
|
||||
yield return MapQueueItem(trackedDownload, album);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: Present queue items with unknown series/episodes
|
||||
yield return MapQueueItem(trackedDownload, null);
|
||||
}
|
||||
}
|
||||
|
||||
private Queue MapAlbum(TrackedDownload trackedDownload, Album album)
|
||||
private Queue MapQueueItem(TrackedDownload trackedDownload, Album album)
|
||||
{
|
||||
bool downloadForced = false;
|
||||
var history = _historyService.Find(trackedDownload.DownloadItem.DownloadId, HistoryEventType.Grabbed).FirstOrDefault();
|
||||
@@ -78,11 +72,11 @@ namespace NzbDrone.Core.Queue
|
||||
|
||||
var queue = new Queue
|
||||
{
|
||||
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,
|
||||
Language = trackedDownload.RemoteAlbum?.ParsedAlbumInfo.Language ?? Language.Unknown,
|
||||
Quality = trackedDownload.RemoteAlbum?.ParsedAlbumInfo.Quality ?? new QualityModel(Quality.Unknown),
|
||||
Title = Parser.Parser.RemoveFileExtension(trackedDownload.DownloadItem.Title),
|
||||
Size = trackedDownload.DownloadItem.TotalSize,
|
||||
Sizeleft = trackedDownload.DownloadItem.RemainingSize,
|
||||
Timeleft = trackedDownload.DownloadItem.RemainingTime,
|
||||
@@ -98,6 +92,16 @@ namespace NzbDrone.Core.Queue
|
||||
DownloadForced = downloadForced
|
||||
};
|
||||
|
||||
if (album != null)
|
||||
{
|
||||
queue.Id = HashConverter.GetHashInt31(string.Format("trackedDownload-{0}-album{1}", trackedDownload.DownloadItem.DownloadId, album.Id));
|
||||
}
|
||||
else
|
||||
{
|
||||
queue.Id = HashConverter.GetHashInt31(string.Format("trackedDownload-{0}", trackedDownload.DownloadItem.DownloadId));
|
||||
}
|
||||
|
||||
|
||||
if (queue.Timeleft.HasValue)
|
||||
{
|
||||
queue.EstimatedCompletionTime = DateTime.UtcNow.Add(queue.Timeleft.Value);
|
||||
@@ -105,5 +109,14 @@ namespace NzbDrone.Core.Queue
|
||||
|
||||
return queue;
|
||||
}
|
||||
|
||||
public void Handle(TrackedDownloadRefreshedEvent message)
|
||||
{
|
||||
_queue = message.TrackedDownloads.OrderBy(c => c.DownloadItem.RemainingTime).SelectMany(MapQueue)
|
||||
.ToList();
|
||||
|
||||
_eventAggregator.PublishEvent(new QueueUpdatedEvent());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user