1
0
Fork 0
mirror of https://github.com/Jackett/Jackett synced 2024-12-26 09:48:37 +00:00

add t=indexers for meta indexers

This commit is contained in:
kaso17 2018-04-06 17:43:18 +02:00
parent 66289cb3f3
commit b26e287a62
4 changed files with 51 additions and 2 deletions

View file

@ -193,7 +193,7 @@ namespace Jackett.Common.Indexers
return filteredResults;
}
public bool CanHandleQuery(TorznabQuery query)
public virtual bool CanHandleQuery(TorznabQuery query)
{
if (query == null)
return false;

View file

@ -22,6 +22,15 @@ namespace Jackett.Common.Indexers.Meta
this.resultFilterProvider = resultFilterProvider;
}
public override bool CanHandleQuery(TorznabQuery query)
{
if (query == null)
return false;
if (query.QueryType == "indexers")
return true;
return base.CanHandleQuery(query);
}
public override Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
return Task.FromResult(IndexerConfigurationStatus.Completed);

View file

@ -93,7 +93,7 @@ namespace Jackett.Common.Models
return supportsCategory;
}
public string ToXml()
public XDocument GetXDocument()
{
var xdoc = new XDocument(
new XDeclaration("1.0", "UTF-8", null),
@ -144,6 +144,12 @@ namespace Jackett.Common.Models
)
)
);
return xdoc;
}
public string ToXml()
{
var xdoc = GetXDocument();
return xdoc.Declaration.ToString() + Environment.NewLine + xdoc.ToString();
}

View file

@ -12,6 +12,7 @@ using System.Web.Http.Filters;
using System.Xml.Linq;
using Jackett.Common;
using Jackett.Common.Indexers;
using Jackett.Common.Indexers.Meta;
using Jackett.Common.Models;
using Jackett.Common.Models.DTO;
using Jackett.Common.Services.Interfaces;
@ -248,6 +249,39 @@ namespace Jackett.Controllers
});
}
// indexers - returns a list of all included indexers (meta indexers only)
if (string.Equals(CurrentQuery.QueryType, "indexers", StringComparison.InvariantCultureIgnoreCase))
{
if (!(CurrentIndexer is BaseMetaIndexer)) // shouldn't be needed because CanHandleQuery should return false
{
logger.Warn($"A search request with t=indexers from {Request.GetOwinContext().Request.RemoteIpAddress} was made but the indexer {CurrentIndexer.DisplayName} isn't a meta indexer.");
return GetErrorXML(203, "Function Not Available: this isn't a meta indexer");
}
var CurrentBaseMetaIndexer = (BaseMetaIndexer)CurrentIndexer;
var xdoc = new XDocument(
new XDeclaration("1.0", "UTF-8", null),
new XElement("indexers",
from i in CurrentBaseMetaIndexer.Indexers
select new XElement("indexer",
new XAttribute("id", i.ID),
new XAttribute("configured", i.IsConfigured),
new XElement("title", i.DisplayName),
new XElement("description", i.DisplayDescription),
new XElement("link", i.SiteLink),
new XElement("language", i.Language),
new XElement("type", i.Type),
i.TorznabCaps.GetXDocument().FirstNode
)
)
);
return ResponseMessage(new HttpResponseMessage()
{
Content = new StringContent(xdoc.Declaration.ToString() + Environment.NewLine + xdoc.ToString(), Encoding.UTF8, "application/xml")
});
}
if (CurrentQuery.ImdbID != null)
{
if (!string.IsNullOrEmpty(CurrentQuery.SearchTerm))