core: code cleanup

This commit is contained in:
ngosang
2020-10-01 20:27:01 +02:00
parent f705f8247a
commit 64788e23f6
2 changed files with 14 additions and 23 deletions

View File

@@ -84,29 +84,25 @@ namespace Jackett.Common.Indexers
var imdbId = ParseUtil.GetImdbID(query.ImdbID); var imdbId = ParseUtil.GetImdbID(query.ImdbID);
if (imdbId != null) if (imdbId != null)
requestData["imdb"] = new JObject
{ {
requestData["imdb"] = new JObject(); ["id"] = imdbId
requestData["imdb"]["id"] = imdbId; };
}
else if (query.TvdbID != null) else if (query.TvdbID != null)
{ {
requestData["tvdb"] = new JObject(); requestData["tvdb"] = new JObject
requestData["tvdb"]["id"] = query.TvdbID; {
["id"] = query.TvdbID
};
if (query.Season != 0) if (query.Season != 0)
{
requestData["tvdb"]["season"] = query.Season; requestData["tvdb"]["season"] = query.Season;
}
if (!string.IsNullOrEmpty(query.Episode)) if (!string.IsNullOrEmpty(query.Episode))
{
requestData["tvdb"]["episode"] = query.Episode; requestData["tvdb"]["episode"] = query.Episode;
} }
}
else if (!string.IsNullOrWhiteSpace(queryString)) else if (!string.IsNullOrWhiteSpace(queryString))
{
requestData["search"] = queryString; requestData["search"] = queryString;
}
var categories = MapTorznabCapsToTrackers(query); var categories = MapTorznabCapsToTrackers(query);
@@ -152,14 +148,10 @@ namespace Jackett.Common.Indexers
}; };
if (r.ContainsKey("imdb")) if (r.ContainsKey("imdb"))
{
release.Imdb = ParseUtil.GetImdbID((string)r["imdb"]["id"]); release.Imdb = ParseUtil.GetImdbID((string)r["imdb"]["id"]);
}
if (r.ContainsKey("tvdb")) if (r.ContainsKey("tvdb"))
{
release.TVDBId = (long)r["tvdb"]["id"]; release.TVDBId = (long)r["tvdb"]["id"];
}
releases.Add(release); releases.Add(release);
} }
@@ -191,7 +183,7 @@ namespace Jackett.Common.Indexers
{ {
requestData["username"] = configData.Username.Value; requestData["username"] = configData.Username.Value;
requestData["passkey"] = configData.Passkey.Value; requestData["passkey"] = configData.Passkey.Value;
JObject json = null;
var response = await RequestWithCookiesAndRetryAsync( var response = await RequestWithCookiesAndRetryAsync(
APIUrl + url, null, RequestType.POST, null, null, APIUrl + url, null, RequestType.POST, null, null,
new Dictionary<string, string> new Dictionary<string, string>
@@ -201,6 +193,7 @@ namespace Jackett.Common.Indexers
}, requestData.ToString(), false); }, requestData.ToString(), false);
CheckSiteDown(response); CheckSiteDown(response);
JObject json;
try try
{ {
json = JObject.Parse(response.ContentString); json = JObject.Parse(response.ContentString);
@@ -211,9 +204,7 @@ namespace Jackett.Common.Indexers
} }
if ((int)json["status"] != 0) if ((int)json["status"] != 0)
{
throw new Exception("HDBits returned an error with status code " + (int)json["status"] + ": " + (string)json["message"]); throw new Exception("HDBits returned an error with status code " + (int)json["status"] + ": " + (string)json["message"]);
}
return json; return json;
} }

View File

@@ -8,7 +8,7 @@ namespace Jackett.Common.Models.IndexerConfig.Bespoke
public CheckboxItem Mediums { get; private set; } public CheckboxItem Mediums { get; private set; }
public CheckboxItem Origins { get; private set; } public CheckboxItem Origins { get; private set; }
public ConfigurationDataHDBitsApi() : base() public ConfigurationDataHDBitsApi()
{ {
Codecs = new CheckboxItem(new Dictionary<string, string>() Codecs = new CheckboxItem(new Dictionary<string, string>()
{ {
@@ -20,7 +20,7 @@ namespace Jackett.Common.Models.IndexerConfig.Bespoke
{"6", "VP9"}, {"6", "VP9"},
{"4", "XviD"} {"4", "XviD"}
}) })
{ Name = "Codec", Values = new string[] { "0", "1", "5", "2", "3", "6", "4" } }; { Name = "Codec", Values = new [] { "0", "1", "5", "2", "3", "6", "4" } };
Mediums = new CheckboxItem(new Dictionary<string, string>() Mediums = new CheckboxItem(new Dictionary<string, string>()
{ {
@@ -31,14 +31,14 @@ namespace Jackett.Common.Models.IndexerConfig.Bespoke
{"5", "Remux"}, {"5", "Remux"},
{"6", "WEB-DL"} {"6", "WEB-DL"}
}) })
{ Name = "Medium", Values = new string[] { "0", "1", "4", "3", "5", "6" } }; { Name = "Medium", Values = new [] { "0", "1", "4", "3", "5", "6" } };
Origins = new CheckboxItem(new Dictionary<string, string>() Origins = new CheckboxItem(new Dictionary<string, string>()
{ {
{"0", "Undefined"}, {"0", "Undefined"},
{"1", "Internal"} {"1", "Internal"}
}) })
{ Name = "Origin", Values = new string[] { "0", "1" } }; { Name = "Origin", Values = new [] { "0", "1" } };
} }
} }
} }