mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 02:37:08 -07:00
Able to create new Newznab indexers
This commit is contained in:
parent
5660b5086c
commit
e4410d8cb7
8 changed files with 117 additions and 13 deletions
|
@ -1,4 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Api.ClientSchema;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using Omu.ValueInjecter;
|
||||
|
@ -13,6 +15,7 @@ namespace NzbDrone.Api.Indexers
|
|||
{
|
||||
_indexerService = indexerService;
|
||||
GetResourceAll = GetAll;
|
||||
CreateResource = Create;
|
||||
}
|
||||
|
||||
private List<IndexerResource> GetAll()
|
||||
|
@ -32,5 +35,28 @@ namespace NzbDrone.Api.Indexers
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
private IndexerResource Create(IndexerResource indexerResource)
|
||||
{
|
||||
var indexer = _indexerService.Schema()
|
||||
.SingleOrDefault(i =>
|
||||
i.Implementation.Equals(indexerResource.Implementation,
|
||||
StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
//TODO: How should be handle this error?
|
||||
if (indexer == null)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
indexer.Name = indexerResource.Name;
|
||||
indexer.Enable = indexerResource.Enable;
|
||||
indexer.Settings = (IIndexerSetting)SchemaDeserializer.DeserializeSchema(indexer.Settings, indexerResource.Fields);
|
||||
|
||||
indexer = _indexerService.Create(indexer);
|
||||
indexerResource.Id = indexer.Id;
|
||||
|
||||
return indexerResource;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue