|
|
@ -1,3 +1,4 @@
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
using FluentValidation;
|
|
|
|
using FluentValidation;
|
|
|
@ -5,6 +6,7 @@ using FluentValidation.Results;
|
|
|
|
using Lidarr.Http;
|
|
|
|
using Lidarr.Http;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using NLog;
|
|
|
|
using NLog;
|
|
|
|
|
|
|
|
using NzbDrone.Common.Composition;
|
|
|
|
using NzbDrone.Common.Extensions;
|
|
|
|
using NzbDrone.Common.Extensions;
|
|
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
using NzbDrone.Core.DecisionEngine;
|
|
|
|
using NzbDrone.Core.DecisionEngine;
|
|
|
@ -22,6 +24,7 @@ namespace Lidarr.Api.V1.Indexers
|
|
|
|
private readonly IProcessDownloadDecisions _downloadDecisionProcessor;
|
|
|
|
private readonly IProcessDownloadDecisions _downloadDecisionProcessor;
|
|
|
|
private readonly IIndexerFactory _indexerFactory;
|
|
|
|
private readonly IIndexerFactory _indexerFactory;
|
|
|
|
private readonly IDownloadClientFactory _downloadClientFactory;
|
|
|
|
private readonly IDownloadClientFactory _downloadClientFactory;
|
|
|
|
|
|
|
|
private readonly KnownTypes _knownTypes;
|
|
|
|
private readonly Logger _logger;
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
|
|
|
|
private static readonly object PushLock = new object();
|
|
|
|
private static readonly object PushLock = new object();
|
|
|
@ -31,6 +34,7 @@ namespace Lidarr.Api.V1.Indexers
|
|
|
|
IIndexerFactory indexerFactory,
|
|
|
|
IIndexerFactory indexerFactory,
|
|
|
|
IDownloadClientFactory downloadClientFactory,
|
|
|
|
IDownloadClientFactory downloadClientFactory,
|
|
|
|
IQualityProfileService qualityProfileService,
|
|
|
|
IQualityProfileService qualityProfileService,
|
|
|
|
|
|
|
|
KnownTypes knownTypes,
|
|
|
|
Logger logger)
|
|
|
|
Logger logger)
|
|
|
|
: base(qualityProfileService)
|
|
|
|
: base(qualityProfileService)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -38,6 +42,7 @@ namespace Lidarr.Api.V1.Indexers
|
|
|
|
_downloadDecisionProcessor = downloadDecisionProcessor;
|
|
|
|
_downloadDecisionProcessor = downloadDecisionProcessor;
|
|
|
|
_indexerFactory = indexerFactory;
|
|
|
|
_indexerFactory = indexerFactory;
|
|
|
|
_downloadClientFactory = downloadClientFactory;
|
|
|
|
_downloadClientFactory = downloadClientFactory;
|
|
|
|
|
|
|
|
_knownTypes = knownTypes;
|
|
|
|
_logger = logger;
|
|
|
|
_logger = logger;
|
|
|
|
|
|
|
|
|
|
|
|
PostValidator.RuleFor(s => s.Title).NotEmpty();
|
|
|
|
PostValidator.RuleFor(s => s.Title).NotEmpty();
|
|
|
@ -59,6 +64,7 @@ namespace Lidarr.Api.V1.Indexers
|
|
|
|
|
|
|
|
|
|
|
|
info.Guid = "PUSH-" + info.DownloadUrl;
|
|
|
|
info.Guid = "PUSH-" + info.DownloadUrl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ResolveDownloadProtocol(info);
|
|
|
|
ResolveIndexer(info);
|
|
|
|
ResolveIndexer(info);
|
|
|
|
|
|
|
|
|
|
|
|
var downloadClientId = ResolveDownloadClientId(release);
|
|
|
|
var downloadClientId = ResolveDownloadClientId(release);
|
|
|
@ -138,5 +144,20 @@ namespace Lidarr.Api.V1.Indexers
|
|
|
|
|
|
|
|
|
|
|
|
return release.DownloadClientId;
|
|
|
|
return release.DownloadClientId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void ResolveDownloadProtocol(ReleaseInfo release)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var knownDownloadProtocols = _knownTypes.GetImplementations(typeof(IDownloadProtocol)).ToArray();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (knownDownloadProtocols.Any(downloadProtocol => downloadProtocol.Name == release.DownloadProtocol))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var downloadProtocol = knownDownloadProtocols
|
|
|
|
|
|
|
|
.Single(c => c.Name.Replace("DownloadProtocol", "").Equals(release.DownloadProtocol, StringComparison.InvariantCultureIgnoreCase));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
release.DownloadProtocol = downloadProtocol.Name;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|