Rarbg: improve app_id handling

This commit is contained in:
kaso17 2018-03-23 06:26:08 +01:00
parent 2d900d1734
commit 65ce4f54a1
1 changed files with 9 additions and 4 deletions

View File

@ -26,7 +26,7 @@ namespace Jackett.Common.Indexers
set { configData.Url.Value = value.ToString(); }
}
private string ApiEndpoint { get { return BaseUri + "pubapi_v2.php?app_id=Jackett"; } }
private string ApiEndpoint { get { return BaseUri + "pubapi_v2.php"; } }
private new ConfigurationDataUrl configData
{
@ -36,6 +36,7 @@ namespace Jackett.Common.Indexers
private DateTime lastTokenFetch;
private string token;
private string app_id;
private readonly TimeSpan TOKEN_DURATION = TimeSpan.FromMinutes(10);
@ -84,6 +85,8 @@ namespace Jackett.Common.Indexers
AddCategoryMapping(32, TorznabCatType.ConsoleXbox360, "Games/XBOX-360");
AddCategoryMapping(33, TorznabCatType.PCISO, "Software/PC ISO");
AddCategoryMapping(35, TorznabCatType.BooksEbook, "e-Books");
app_id = "jackett_v" + EnvironmentUtil.JackettVersion;
}
private async Task CheckToken()
@ -92,8 +95,10 @@ namespace Jackett.Common.Indexers
{
var queryCollection = new NameValueCollection();
queryCollection.Add("get_token", "get_token");
queryCollection.Add("app_id", app_id);
var tokenUrl = ApiEndpoint + "&" + queryCollection.GetQueryString();
var tokenUrl = ApiEndpoint + "?" + queryCollection.GetQueryString();
var result = await RequestStringWithCookiesAndRetry(tokenUrl);
var json = JObject.Parse(result.Content);
@ -129,7 +134,7 @@ namespace Jackett.Common.Indexers
var queryCollection = new NameValueCollection();
queryCollection.Add("token", token);
queryCollection.Add("format", "json_extended");
queryCollection.Add("app_id", "jackett_v" + EnvironmentUtil.JackettVersion);
queryCollection.Add("app_id", app_id);
queryCollection.Add("limit", "100");
queryCollection.Add("ranked", "0");
@ -165,7 +170,7 @@ namespace Jackett.Common.Indexers
queryCollection.Add("category", cats);
}
var searchUrl = ApiEndpoint + "&" + queryCollection.GetQueryString();
var searchUrl = ApiEndpoint + "?" + queryCollection.GetQueryString();
var response = await RequestStringWithCookiesAndRetry(searchUrl, string.Empty);
try