mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-27 12:33:00 +02:00
cleaned up parsing logic and structure.
This commit is contained in:
@@ -6,13 +6,15 @@ using NzbDrone.Common.Eventing;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Download
|
||||
{
|
||||
public interface IDownloadService
|
||||
{
|
||||
bool DownloadReport(IndexerParseResult parseResult);
|
||||
bool DownloadReport(RemoteEpisode episode);
|
||||
}
|
||||
|
||||
public class DownloadService : IDownloadService
|
||||
@@ -32,31 +34,31 @@ namespace NzbDrone.Core.Download
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public bool DownloadReport(IndexerParseResult parseResult)
|
||||
public bool DownloadReport(RemoteEpisode episode)
|
||||
{
|
||||
var downloadTitle = parseResult.OriginalString;
|
||||
var downloadTitle = episode.Report.Title;
|
||||
if (!_configService.DownloadClientUseSceneName)
|
||||
{
|
||||
downloadTitle = parseResult.GetDownloadTitle();
|
||||
downloadTitle = episode.GetDownloadTitle();
|
||||
}
|
||||
|
||||
var provider = _downloadClientProvider.GetDownloadClient();
|
||||
var recentEpisode = ContainsRecentEpisode(parseResult);
|
||||
var recentEpisode = ContainsRecentEpisode(episode);
|
||||
|
||||
bool success = provider.DownloadNzb(parseResult.NzbUrl, downloadTitle, recentEpisode);
|
||||
bool success = provider.DownloadNzb(episode.Report.NzbUrl, downloadTitle, recentEpisode);
|
||||
|
||||
if (success)
|
||||
{
|
||||
_logger.Info("Report sent to download client. {0}", downloadTitle);
|
||||
_eventAggregator.Publish(new EpisodeGrabbedEvent(parseResult));
|
||||
_eventAggregator.Publish(new EpisodeGrabbedEvent(episode));
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
private static bool ContainsRecentEpisode(IndexerParseResult parseResult)
|
||||
private static bool ContainsRecentEpisode(RemoteEpisode episode)
|
||||
{
|
||||
return parseResult.Episodes.Any(e => e.AirDate >= DateTime.Today.AddDays(-7));
|
||||
return episode.Episodes.Any(e => e.AirDate >= DateTime.Today.AddDays(-7));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user