Fix custom formats with indexer flags in queue

This commit is contained in:
Bogdan 2023-09-10 22:47:31 +03:00
parent 18f22d7ada
commit f0fcd23248
1 changed files with 10 additions and 4 deletions

View File

@ -13,6 +13,7 @@ using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Movies; using NzbDrone.Core.Movies;
using NzbDrone.Core.Movies.Events; using NzbDrone.Core.Movies.Events;
using NzbDrone.Core.Parser; using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.Download.TrackedDownloads namespace NzbDrone.Core.Download.TrackedDownloads
{ {
@ -114,11 +115,9 @@ namespace NzbDrone.Core.Download.TrackedDownloads
try try
{ {
var historyItems = _historyService.FindByDownloadId(downloadItem.DownloadId) var historyItems = _historyService.FindByDownloadId(downloadItem.DownloadId)
.OrderByDescending(h => h.Date) .OrderByDescending(h => h.Date)
.ToList(); .ToList();
var grabbedHistoryItem = historyItems.FirstOrDefault(h => h.EventType == MovieHistoryEventType.Grabbed);
// TODO: Create release info from history and use that here, so we don't loose indexer flags!
var parsedMovieInfo = Parser.Parser.ParseMovieTitle(trackedDownload.DownloadItem.Title); var parsedMovieInfo = Parser.Parser.ParseMovieTitle(trackedDownload.DownloadItem.Title);
if (parsedMovieInfo != null) if (parsedMovieInfo != null)
@ -155,6 +154,13 @@ namespace NzbDrone.Core.Download.TrackedDownloads
firstHistoryItem.MovieId); firstHistoryItem.MovieId);
} }
} }
if (trackedDownload.RemoteMovie != null &&
Enum.TryParse(grabbedEvent?.Data?.GetValueOrDefault("indexerFlags"), true, out IndexerFlags flags))
{
trackedDownload.RemoteMovie.Release ??= new ReleaseInfo();
trackedDownload.RemoteMovie.Release.IndexerFlags = flags;
}
} }
// Calculate custom formats // Calculate custom formats