mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Cleanup Search UI, Newznab Caps API
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Nancy;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using Prowlarr.Http.REST;
|
||||
|
||||
namespace Prowlarr.Api.V1.Indexers
|
||||
{
|
||||
@@ -6,9 +8,14 @@ namespace Prowlarr.Api.V1.Indexers
|
||||
{
|
||||
public static readonly IndexerResourceMapper ResourceMapper = new IndexerResourceMapper();
|
||||
|
||||
private IIndexerFactory _indexerFactory { get; set; }
|
||||
|
||||
public IndexerModule(IndexerFactory indexerFactory)
|
||||
: base(indexerFactory, "indexer", ResourceMapper)
|
||||
{
|
||||
_indexerFactory = indexerFactory;
|
||||
|
||||
Get("{id}/newznab", x => GetNewznabResponse(x.id));
|
||||
}
|
||||
|
||||
protected override void Validate(IndexerDefinition definition, bool includeWarnings)
|
||||
@@ -20,5 +27,27 @@ namespace Prowlarr.Api.V1.Indexers
|
||||
|
||||
base.Validate(definition, includeWarnings);
|
||||
}
|
||||
|
||||
private object GetNewznabResponse(int id)
|
||||
{
|
||||
var requestType = Request.Query.t;
|
||||
|
||||
if (!requestType.HasValue)
|
||||
{
|
||||
throw new BadRequestException("Missing Function Parameter");
|
||||
}
|
||||
|
||||
if (requestType.Value == "caps")
|
||||
{
|
||||
var indexer = _indexerFactory.GetInstance(_indexerFactory.Get(id));
|
||||
Response response = indexer.Capabilities.ToXml();
|
||||
response.ContentType = "application/rss+xml";
|
||||
return response;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BadRequestException("Function Not Available");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user