|
|
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using NzbDrone.Common.Extensions;
|
|
|
|
|
using NzbDrone.Core.Indexers;
|
|
|
|
|
using NzbDrone.Core.Indexers.Newznab;
|
|
|
|
|
using NzbDrone.Core.Localization;
|
|
|
|
|
using NzbDrone.Core.ThingiProvider.Events;
|
|
|
|
|
|
|
|
|
@ -12,11 +11,11 @@ namespace NzbDrone.Core.HealthCheck.Checks
|
|
|
|
|
[CheckOn(typeof(ProviderAddedEvent<IIndexer>))]
|
|
|
|
|
[CheckOn(typeof(ProviderUpdatedEvent<IIndexer>))]
|
|
|
|
|
[CheckOn(typeof(ProviderDeletedEvent<IIndexer>))]
|
|
|
|
|
public class NewznabVIPCheck : HealthCheckBase
|
|
|
|
|
public class IndexerVIPCheck : HealthCheckBase
|
|
|
|
|
{
|
|
|
|
|
private readonly IIndexerFactory _indexerFactory;
|
|
|
|
|
|
|
|
|
|
public NewznabVIPCheck(IIndexerFactory indexerFactory, ILocalizationService localizationService)
|
|
|
|
|
public IndexerVIPCheck(IIndexerFactory indexerFactory, ILocalizationService localizationService)
|
|
|
|
|
: base(localizationService)
|
|
|
|
|
{
|
|
|
|
|
_indexerFactory = indexerFactory;
|
|
|
|
@ -25,13 +24,20 @@ namespace NzbDrone.Core.HealthCheck.Checks
|
|
|
|
|
public override HealthCheck Check()
|
|
|
|
|
{
|
|
|
|
|
var enabled = _indexerFactory.Enabled(false);
|
|
|
|
|
var newznabProviders = enabled.Where(i => i.Definition.Implementation == typeof(Newznab).Name);
|
|
|
|
|
var expiringProviders = new List<IIndexer>();
|
|
|
|
|
var expiredProviders = new List<IIndexer>();
|
|
|
|
|
|
|
|
|
|
foreach (var provider in newznabProviders)
|
|
|
|
|
foreach (var provider in enabled)
|
|
|
|
|
{
|
|
|
|
|
var expiration = ((NewznabSettings)provider.Definition.Settings).VipExpiration;
|
|
|
|
|
var settingsType = provider.Definition.Settings.GetType();
|
|
|
|
|
var vipProp = settingsType.GetProperty("VipExpiration");
|
|
|
|
|
|
|
|
|
|
if (vipProp == null)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var expiration = (string)vipProp.GetValue(provider.Definition.Settings);
|
|
|
|
|
|
|
|
|
|
if (expiration.IsNullOrWhiteSpace())
|
|
|
|
|
{
|
|
|
|
@ -53,18 +59,18 @@ namespace NzbDrone.Core.HealthCheck.Checks
|
|
|
|
|
{
|
|
|
|
|
return new HealthCheck(GetType(),
|
|
|
|
|
HealthCheckResult.Warning,
|
|
|
|
|
string.Format(_localizationService.GetLocalizedString("NewznabVipCheckExpiringClientMessage"),
|
|
|
|
|
string.Format(_localizationService.GetLocalizedString("IndexerVipCheckExpiringClientMessage"),
|
|
|
|
|
string.Join(", ", expiringProviders.Select(v => v.Definition.Name))),
|
|
|
|
|
"#newznab-vip-expiring");
|
|
|
|
|
"#indexer-vip-expiring");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!expiredProviders.Empty())
|
|
|
|
|
{
|
|
|
|
|
return new HealthCheck(GetType(),
|
|
|
|
|
HealthCheckResult.Warning,
|
|
|
|
|
string.Format(_localizationService.GetLocalizedString("NewznabVipCheckExpiredClientMessage"),
|
|
|
|
|
string.Format(_localizationService.GetLocalizedString("IndexerVipCheckExpiredClientMessage"),
|
|
|
|
|
string.Join(", ", expiredProviders.Select(v => v.Definition.Name))),
|
|
|
|
|
"#newznab-vip-expired");
|
|
|
|
|
"#indexer-vip-expired");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new HealthCheck(GetType());
|