mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-22 07:42:28 +00:00
fixup! New: Plugin support
This commit is contained in:
parent
ea9a1d7e1a
commit
c8713a73b3
1 changed files with 21 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentValidation;
|
||||
|
@ -5,6 +6,7 @@
|
|||
using Lidarr.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Composition;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
|
@ -22,6 +24,7 @@ public class ReleasePushController : ReleaseControllerBase
|
|||
private readonly IProcessDownloadDecisions _downloadDecisionProcessor;
|
||||
private readonly IIndexerFactory _indexerFactory;
|
||||
private readonly IDownloadClientFactory _downloadClientFactory;
|
||||
private readonly KnownTypes _knownTypes;
|
||||
private readonly Logger _logger;
|
||||
|
||||
private static readonly object PushLock = new object();
|
||||
|
@ -31,6 +34,7 @@ public ReleasePushController(IMakeDownloadDecision downloadDecisionMaker,
|
|||
IIndexerFactory indexerFactory,
|
||||
IDownloadClientFactory downloadClientFactory,
|
||||
IQualityProfileService qualityProfileService,
|
||||
KnownTypes knownTypes,
|
||||
Logger logger)
|
||||
: base(qualityProfileService)
|
||||
{
|
||||
|
@ -38,6 +42,7 @@ public ReleasePushController(IMakeDownloadDecision downloadDecisionMaker,
|
|||
_downloadDecisionProcessor = downloadDecisionProcessor;
|
||||
_indexerFactory = indexerFactory;
|
||||
_downloadClientFactory = downloadClientFactory;
|
||||
_knownTypes = knownTypes;
|
||||
_logger = logger;
|
||||
|
||||
PostValidator.RuleFor(s => s.Title).NotEmpty();
|
||||
|
@ -59,6 +64,7 @@ public ActionResult<ReleaseResource> Create(ReleaseResource release)
|
|||
|
||||
info.Guid = "PUSH-" + info.DownloadUrl;
|
||||
|
||||
ResolveDownloadProtocol(info);
|
||||
ResolveIndexer(info);
|
||||
|
||||
var downloadClientId = ResolveDownloadClientId(release);
|
||||
|
@ -138,5 +144,20 @@ private void ResolveIndexer(ReleaseInfo release)
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue