mirror of https://github.com/Radarr/Radarr
Download client will return queue with remoteEpsiode
Fixed: In Queue check is more accurate
This commit is contained in:
parent
883d0c815e
commit
6d46819972
|
@ -1,9 +1,10 @@
|
||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||||
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
@ -17,6 +18,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
private Series _series;
|
private Series _series;
|
||||||
private Episode _episode;
|
private Episode _episode;
|
||||||
private RemoteEpisode _remoteEpisode;
|
private RemoteEpisode _remoteEpisode;
|
||||||
|
private Mock<IDownloadClient> _downloadClient;
|
||||||
|
|
||||||
private Series _otherSeries;
|
private Series _otherSeries;
|
||||||
private Episode _otherEpisode;
|
private Episode _otherEpisode;
|
||||||
|
@ -46,27 +48,60 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
.With(r => r.Episodes = new List<Episode> { _episode })
|
.With(r => r.Episodes = new List<Episode> { _episode })
|
||||||
.With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD)})
|
.With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD)})
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
_downloadClient = Mocker.GetMock<IDownloadClient>();
|
||||||
|
|
||||||
|
Mocker.GetMock<IProvideDownloadClient>()
|
||||||
|
.Setup(s => s.GetDownloadClient())
|
||||||
|
.Returns(_downloadClient.Object);
|
||||||
|
|
||||||
|
_downloadClient.SetupGet(s => s.IsConfigured)
|
||||||
|
.Returns(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
private void GivenEmptyQueue()
|
||||||
public void should_return_false_when_queue_is_empty()
|
|
||||||
{
|
{
|
||||||
Subject.IsInQueue(_remoteEpisode, new List<RemoteEpisode>()).Should().BeFalse();
|
_downloadClient.Setup(s => s.GetQueue())
|
||||||
|
.Returns(new List<QueueItem>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GivenQueue(IEnumerable<RemoteEpisode> remoteEpisodes)
|
||||||
|
{
|
||||||
|
var queue = new List<QueueItem>();
|
||||||
|
|
||||||
|
foreach (var remoteEpisode in remoteEpisodes)
|
||||||
|
{
|
||||||
|
queue.Add(new QueueItem
|
||||||
|
{
|
||||||
|
RemoteEpisode = remoteEpisode
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_downloadClient.Setup(s => s.GetQueue())
|
||||||
|
.Returns(queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_false_when_series_doesnt_match()
|
public void should_return_true_when_queue_is_empty()
|
||||||
|
{
|
||||||
|
GivenEmptyQueue();
|
||||||
|
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_true_when_series_doesnt_match()
|
||||||
{
|
{
|
||||||
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||||
.With(r => r.Series = _otherSeries)
|
.With(r => r.Series = _otherSeries)
|
||||||
.With(r => r.Episodes = new List<Episode> { _episode })
|
.With(r => r.Episodes = new List<Episode> { _episode })
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
Subject.IsInQueue(_remoteEpisode, new List<RemoteEpisode> { remoteEpisode }).Should().BeFalse();
|
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||||
|
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_false_when_quality_in_queue_is_lower()
|
public void should_return_true_when_quality_in_queue_is_lower()
|
||||||
{
|
{
|
||||||
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||||
.With(r => r.Series = _series)
|
.With(r => r.Series = _series)
|
||||||
|
@ -77,11 +112,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
})
|
})
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
Subject.IsInQueue(_remoteEpisode, new List<RemoteEpisode> { remoteEpisode }).Should().BeFalse();
|
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||||
|
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_false_when_episode_doesnt_match()
|
public void should_return_true_when_episode_doesnt_match()
|
||||||
{
|
{
|
||||||
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||||
.With(r => r.Series = _series)
|
.With(r => r.Series = _series)
|
||||||
|
@ -92,11 +128,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
})
|
})
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
Subject.IsInQueue(_remoteEpisode, new List<RemoteEpisode> { remoteEpisode }).Should().BeFalse();
|
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||||
|
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_true_when_qualities_are_the_same()
|
public void should_return_false_when_qualities_are_the_same()
|
||||||
{
|
{
|
||||||
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||||
.With(r => r.Series = _series)
|
.With(r => r.Series = _series)
|
||||||
|
@ -107,11 +144,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
})
|
})
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
Subject.IsInQueue(_remoteEpisode, new List<RemoteEpisode> { remoteEpisode }).Should().BeTrue();
|
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||||
|
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_true_when_quality_in_queue_is_better()
|
public void should_return_false_when_quality_in_queue_is_better()
|
||||||
{
|
{
|
||||||
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||||
.With(r => r.Series = _series)
|
.With(r => r.Series = _series)
|
||||||
|
@ -122,11 +160,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
})
|
})
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
Subject.IsInQueue(_remoteEpisode, new List<RemoteEpisode> { remoteEpisode }).Should().BeTrue();
|
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||||
|
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_true_if_matching_multi_episode_is_in_queue()
|
public void should_return_false_if_matching_multi_episode_is_in_queue()
|
||||||
{
|
{
|
||||||
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||||
.With(r => r.Series = _series)
|
.With(r => r.Series = _series)
|
||||||
|
@ -137,11 +176,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
})
|
})
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
Subject.IsInQueue(_remoteEpisode, new List<RemoteEpisode> { remoteEpisode }).Should().BeTrue();
|
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||||
|
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_true_if_multi_episode_has_one_episode_in_queue()
|
public void should_return_false_if_multi_episode_has_one_episode_in_queue()
|
||||||
{
|
{
|
||||||
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||||
.With(r => r.Series = _series)
|
.With(r => r.Series = _series)
|
||||||
|
@ -154,11 +194,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
|
|
||||||
_remoteEpisode.Episodes.Add(_otherEpisode);
|
_remoteEpisode.Episodes.Add(_otherEpisode);
|
||||||
|
|
||||||
Subject.IsInQueue(_remoteEpisode, new List<RemoteEpisode> { remoteEpisode }).Should().BeTrue();
|
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||||
|
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_true_if_multi_part_episode_is_already_in_queue()
|
public void should_return_false_if_multi_part_episode_is_already_in_queue()
|
||||||
{
|
{
|
||||||
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||||
.With(r => r.Series = _series)
|
.With(r => r.Series = _series)
|
||||||
|
@ -171,11 +212,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
|
|
||||||
_remoteEpisode.Episodes.Add(_otherEpisode);
|
_remoteEpisode.Episodes.Add(_otherEpisode);
|
||||||
|
|
||||||
Subject.IsInQueue(_remoteEpisode, new List<RemoteEpisode> { remoteEpisode }).Should().BeTrue();
|
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||||
|
Subject.IsSatisfiedBy(_remoteEpisode, null).Should().BeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_true_if_multi_part_episode_has_two_episodes_in_queue()
|
public void should_return_false_if_multi_part_episode_has_two_episodes_in_queue()
|
||||||
{
|
{
|
||||||
var remoteEpisodes = Builder<RemoteEpisode>.CreateListOfSize(2)
|
var remoteEpisodes = Builder<RemoteEpisode>.CreateListOfSize(2)
|
||||||
.All()
|
.All()
|
||||||
|
@ -193,8 +235,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
_remoteEpisode.Episodes.Add(_otherEpisode);
|
_remoteEpisode.Episodes.Add(_otherEpisode);
|
||||||
|
GivenQueue(remoteEpisodes);
|
||||||
Subject.IsInQueue(_remoteEpisode, remoteEpisodes ).Should().BeTrue();
|
Subject.IsSatisfiedBy(_remoteEpisode, null ).Should().BeFalse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -13,13 +13,11 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||||
public class NotInQueueSpecification : IDecisionEngineSpecification
|
public class NotInQueueSpecification : IDecisionEngineSpecification
|
||||||
{
|
{
|
||||||
private readonly IProvideDownloadClient _downloadClientProvider;
|
private readonly IProvideDownloadClient _downloadClientProvider;
|
||||||
private readonly IParsingService _parsingService;
|
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public NotInQueueSpecification(IProvideDownloadClient downloadClientProvider, IParsingService parsingService, Logger logger)
|
public NotInQueueSpecification(IProvideDownloadClient downloadClientProvider, Logger logger)
|
||||||
{
|
{
|
||||||
_downloadClientProvider = downloadClientProvider;
|
_downloadClientProvider = downloadClientProvider;
|
||||||
_parsingService = parsingService;
|
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,20 +39,17 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var queue = downloadClient.GetQueue().Select(queueItem => Parser.Parser.ParseTitle(queueItem.Title)).Where(episodeInfo => episodeInfo != null);
|
var queue = downloadClient.GetQueue().Select(q => q.RemoteEpisode);
|
||||||
|
|
||||||
var mappedQueue = queue.Select(queueItem => _parsingService.Map(queueItem, 0))
|
return !IsInQueue(subject, queue);
|
||||||
.Where(remoteEpisode => remoteEpisode.Series != null);
|
|
||||||
|
|
||||||
return !IsInQueue(subject, mappedQueue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsInQueue(RemoteEpisode newEpisode, IEnumerable<RemoteEpisode> queue)
|
private bool IsInQueue(RemoteEpisode newEpisode, IEnumerable<RemoteEpisode> queue)
|
||||||
{
|
{
|
||||||
var matchingSeries = queue.Where(q => q.Series.Id == newEpisode.Series.Id);
|
var matchingSeries = queue.Where(q => q.Series.Id == newEpisode.Series.Id);
|
||||||
var matchingTitleWithQuality = matchingSeries.Where(q => q.ParsedEpisodeInfo.Quality >= newEpisode.ParsedEpisodeInfo.Quality);
|
var matchingSeriesAndQuality = matchingSeries.Where(q => q.ParsedEpisodeInfo.Quality >= newEpisode.ParsedEpisodeInfo.Quality);
|
||||||
|
|
||||||
return matchingTitleWithQuality.Any(q => q.Episodes.Select(e => e.Id).Intersect(newEpisode.Episodes.Select(e => e.Id)).Any());
|
return matchingSeriesAndQuality.Any(q => q.Episodes.Select(e => e.Id).Intersect(newEpisode.Episodes.Select(e => e.Id)).Any());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ using NLog;
|
||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Common.Serializer;
|
using NzbDrone.Common.Serializer;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
|
using NzbDrone.Core.Parser;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Download.Clients.Nzbget
|
namespace NzbDrone.Core.Download.Clients.Nzbget
|
||||||
|
@ -12,12 +13,14 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
|
||||||
{
|
{
|
||||||
private readonly IConfigService _configService;
|
private readonly IConfigService _configService;
|
||||||
private readonly IHttpProvider _httpProvider;
|
private readonly IHttpProvider _httpProvider;
|
||||||
|
private readonly IParsingService _parsingService;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public NzbgetClient(IConfigService configService, IHttpProvider httpProvider, Logger logger)
|
public NzbgetClient(IConfigService configService, IHttpProvider httpProvider, IParsingService parsingService, Logger logger)
|
||||||
{
|
{
|
||||||
_configService = configService;
|
_configService = configService;
|
||||||
_httpProvider = httpProvider;
|
_httpProvider = httpProvider;
|
||||||
|
_parsingService = parsingService;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +78,14 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
|
||||||
queueItem.Size = nzbGetQueueItem.FileSizeMb;
|
queueItem.Size = nzbGetQueueItem.FileSizeMb;
|
||||||
queueItem.Sizeleft = nzbGetQueueItem.RemainingSizeMb;
|
queueItem.Sizeleft = nzbGetQueueItem.RemainingSizeMb;
|
||||||
|
|
||||||
|
var parsedEpisodeInfo = Parser.Parser.ParseTitle(queueItem.Title);
|
||||||
|
if (parsedEpisodeInfo == null) continue;
|
||||||
|
|
||||||
|
var remoteEpisode = _parsingService.Map(parsedEpisodeInfo, 0);
|
||||||
|
if (remoteEpisode.Series == null) continue;
|
||||||
|
|
||||||
|
queueItem.RemoteEpisode = remoteEpisode;
|
||||||
|
|
||||||
yield return queueItem;
|
yield return queueItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ using NzbDrone.Common;
|
||||||
using NzbDrone.Common.Cache;
|
using NzbDrone.Common.Cache;
|
||||||
using NzbDrone.Common.Serializer;
|
using NzbDrone.Common.Serializer;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
|
using NzbDrone.Core.Parser;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
using RestSharp;
|
using RestSharp;
|
||||||
|
|
||||||
|
@ -53,13 +54,19 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||||
{
|
{
|
||||||
private readonly IConfigService _configService;
|
private readonly IConfigService _configService;
|
||||||
private readonly IHttpProvider _httpProvider;
|
private readonly IHttpProvider _httpProvider;
|
||||||
|
private readonly IParsingService _parsingService;
|
||||||
private readonly ICached<IEnumerable<QueueItem>> _queueCache;
|
private readonly ICached<IEnumerable<QueueItem>> _queueCache;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public SabnzbdClient(IConfigService configService, IHttpProvider httpProvider, ICacheManger cacheManger, Logger logger)
|
public SabnzbdClient(IConfigService configService,
|
||||||
|
IHttpProvider httpProvider,
|
||||||
|
ICacheManger cacheManger,
|
||||||
|
IParsingService parsingService,
|
||||||
|
Logger logger)
|
||||||
{
|
{
|
||||||
_configService = configService;
|
_configService = configService;
|
||||||
_httpProvider = httpProvider;
|
_httpProvider = httpProvider;
|
||||||
|
_parsingService = parsingService;
|
||||||
_queueCache = cacheManger.GetCache<IEnumerable<QueueItem>>(GetType(), "queue");
|
_queueCache = cacheManger.GetCache<IEnumerable<QueueItem>>(GetType(), "queue");
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
@ -121,6 +128,14 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||||
queueItem.Timeleft = sabQueueItem.Timeleft;
|
queueItem.Timeleft = sabQueueItem.Timeleft;
|
||||||
queueItem.Status = sabQueueItem.Status;
|
queueItem.Status = sabQueueItem.Status;
|
||||||
|
|
||||||
|
var parsedEpisodeInfo = Parser.Parser.ParseTitle(queueItem.Title);
|
||||||
|
if (parsedEpisodeInfo == null) continue;
|
||||||
|
|
||||||
|
var remoteEpisode = _parsingService.Map(parsedEpisodeInfo, 0);
|
||||||
|
if (remoteEpisode.Series == null) continue;
|
||||||
|
|
||||||
|
queueItem.RemoteEpisode = remoteEpisode;
|
||||||
|
|
||||||
queueItems.Add(queueItem);
|
queueItems.Add(queueItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,5 +9,4 @@ namespace NzbDrone.Core.Download
|
||||||
bool IsConfigured { get; }
|
bool IsConfigured { get; }
|
||||||
IEnumerable<QueueItem> GetQueue();
|
IEnumerable<QueueItem> GetQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Download
|
namespace NzbDrone.Core.Download
|
||||||
{
|
{
|
||||||
|
@ -10,5 +11,6 @@ namespace NzbDrone.Core.Download
|
||||||
public decimal Sizeleft { get; set; }
|
public decimal Sizeleft { get; set; }
|
||||||
public TimeSpan Timeleft { get; set; }
|
public TimeSpan Timeleft { get; set; }
|
||||||
public String Status { get; set; }
|
public String Status { get; set; }
|
||||||
|
public RemoteEpisode RemoteEpisode { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,11 @@ namespace NzbDrone.Core.Queue
|
||||||
public class QueueService : IQueueService
|
public class QueueService : IQueueService
|
||||||
{
|
{
|
||||||
private readonly IProvideDownloadClient _downloadClientProvider;
|
private readonly IProvideDownloadClient _downloadClientProvider;
|
||||||
private readonly IParsingService _parsingService;
|
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public QueueService(IProvideDownloadClient downloadClientProvider, IParsingService parsingService, Logger logger)
|
public QueueService(IProvideDownloadClient downloadClientProvider, Logger logger)
|
||||||
{
|
{
|
||||||
_downloadClientProvider = downloadClientProvider;
|
_downloadClientProvider = downloadClientProvider;
|
||||||
_parsingService = parsingService;
|
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,24 +37,13 @@ namespace NzbDrone.Core.Queue
|
||||||
|
|
||||||
foreach (var queueItem in queueItems)
|
foreach (var queueItem in queueItems)
|
||||||
{
|
{
|
||||||
var parsedEpisodeInfo = Parser.Parser.ParseTitle(queueItem.Title);
|
foreach (var episode in queueItem.RemoteEpisode.Episodes)
|
||||||
|
|
||||||
if (parsedEpisodeInfo != null && !string.IsNullOrWhiteSpace(parsedEpisodeInfo.SeriesTitle))
|
|
||||||
{
|
|
||||||
var remoteEpisode = _parsingService.Map(parsedEpisodeInfo, 0);
|
|
||||||
|
|
||||||
if (remoteEpisode.Series == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var episode in remoteEpisode.Episodes)
|
|
||||||
{
|
{
|
||||||
var queue = new Queue();
|
var queue = new Queue();
|
||||||
queue.Id = queueItem.Id.GetHashCode();
|
queue.Id = queueItem.Id.GetHashCode();
|
||||||
queue.Series = remoteEpisode.Series;
|
queue.Series = queueItem.RemoteEpisode.Series;
|
||||||
queue.Episode = episode;
|
queue.Episode = episode;
|
||||||
queue.Quality = remoteEpisode.ParsedEpisodeInfo.Quality;
|
queue.Quality = queueItem.RemoteEpisode.ParsedEpisodeInfo.Quality;
|
||||||
queue.Title = queueItem.Title;
|
queue.Title = queueItem.Title;
|
||||||
queue.Size = queueItem.Size;
|
queue.Size = queueItem.Size;
|
||||||
queue.Sizeleft = queueItem.Sizeleft;
|
queue.Sizeleft = queueItem.Sizeleft;
|
||||||
|
@ -65,7 +52,6 @@ namespace NzbDrone.Core.Queue
|
||||||
queued.Add(queue);
|
queued.Add(queue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return queued;
|
return queued;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue