bjshare: add useragent. resolves #13564 (#13575)

This commit is contained in:
ilike2burnthing 2022-09-26 23:32:31 +01:00 committed by GitHub
parent 6132054f35
commit 09b4752387
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 4 deletions

View File

@ -31,7 +31,7 @@ namespace Jackett.Common.Indexers
"https://bj-share.me/"
};
private new ConfigurationDataCookie configData => (ConfigurationDataCookie)base.configData;
private new ConfigurationDataCookieUA configData => (ConfigurationDataCookieUA)base.configData;
@ -89,7 +89,7 @@ namespace Jackett.Common.Indexers
logger: l,
p: ps,
cacheService: cs,
configData: new ConfigurationDataCookie())
configData: new ConfigurationDataCookieUA())
{
Encoding = Encoding.UTF8;
Language = "pt-BR";
@ -136,7 +136,7 @@ namespace Jackett.Common.Indexers
catch (Exception e)
{
IsConfigured = false;
throw new Exception("Your cookie did not work: " + e.Message);
throw new Exception("Your cookie did not work, make sure the user agent matches your computer: " + e.Message);
}
}
@ -262,13 +262,22 @@ namespace Jackett.Common.Indexers
{"action", "basic"},
{"searchsubmit", "1"}
};
Dictionary<string, string> headers = null;
if (!string.IsNullOrEmpty(configData.UserAgent.Value))
{
headers = new Dictionary<string, string>();
headers.Add("User-Agent", configData.UserAgent.Value);
}
foreach (var cat in MapTorznabCapsToTrackers(query))
{
queryCollection.Add("filter_cat[" + cat + "]", "1");
}
searchUrl += "?" + queryCollection.GetQueryString();
var results = await RequestWithCookiesAsync(searchUrl);
var results = await RequestWithCookiesAsync(searchUrl, headers: headers);
if (IsSessionIsClosed(results))
{
throw new Exception("The user is not logged in. It is possible that the cookie has expired or you " +