mirror of https://github.com/Jackett/Jackett
Add LastError to indexer API (#802)
This commit is contained in:
parent
82ae611c81
commit
bb6f56bfa6
|
@ -233,6 +233,7 @@ namespace Jackett.Controllers
|
|||
item["configured"] = indexer.IsConfigured;
|
||||
item["site_link"] = indexer.SiteLink;
|
||||
item["language"] = indexer.Language;
|
||||
item["last_error"] = indexer.LastError;
|
||||
item["potatoenabled"] = indexer.TorznabCaps.Categories.Select(c => c.ID).Any(i => PotatoController.MOVIE_CATS.Contains(i));
|
||||
|
||||
var caps = new JObject();
|
||||
|
@ -257,19 +258,24 @@ namespace Jackett.Controllers
|
|||
public async Task<IHttpActionResult> Test()
|
||||
{
|
||||
JToken jsonReply = new JObject();
|
||||
IIndexer indexer = null;
|
||||
try
|
||||
{
|
||||
var postData = await ReadPostDataJson();
|
||||
string indexerString = (string)postData["indexer"];
|
||||
indexer = indexerService.GetIndexer(indexerString);
|
||||
await indexerService.TestIndexer(indexerString);
|
||||
jsonReply["name"] = indexerService.GetIndexer(indexerString).DisplayName;
|
||||
jsonReply["name"] = indexer.DisplayName;
|
||||
jsonReply["result"] = "success";
|
||||
indexer.LastError = null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, "Exception in test_indexer");
|
||||
jsonReply["result"] = "error";
|
||||
jsonReply["error"] = ex.Message;
|
||||
if (indexer != null)
|
||||
indexer.LastError = ex.Message;
|
||||
}
|
||||
return Json(jsonReply);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,17 @@ namespace Jackett.Indexers
|
|||
set { configData.CookieHeader.Value = value; }
|
||||
}
|
||||
|
||||
|
||||
public string LastError
|
||||
{
|
||||
get { return configData.LastError.Value; }
|
||||
set
|
||||
{
|
||||
bool SaveNeeded = configData.LastError.Value != value && IsConfigured;
|
||||
configData.LastError.Value = value;
|
||||
if (SaveNeeded)
|
||||
SaveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
protected ConfigurationData configData;
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace Jackett.Indexers
|
|||
string DisplayName { get; }
|
||||
string DisplayDescription { get; }
|
||||
string Language { get; }
|
||||
string LastError { get; set; }
|
||||
string ID { get; }
|
||||
|
||||
TorznabCapabilities TorznabCaps { get; }
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace Jackett.Models.IndexerConfig
|
|||
}
|
||||
|
||||
public HiddenItem CookieHeader { get; private set; } = new HiddenItem { Name = "CookieHeader" };
|
||||
public HiddenItem LastError { get; private set; } = new HiddenItem { Name = "LastError" };
|
||||
|
||||
public ConfigurationData()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue