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

View File

@@ -31,7 +31,7 @@ namespace Jackett.Common.Indexers
"https://bj-share.me/" "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, logger: l,
p: ps, p: ps,
cacheService: cs, cacheService: cs,
configData: new ConfigurationDataCookie()) configData: new ConfigurationDataCookieUA())
{ {
Encoding = Encoding.UTF8; Encoding = Encoding.UTF8;
Language = "pt-BR"; Language = "pt-BR";
@@ -136,7 +136,7 @@ namespace Jackett.Common.Indexers
catch (Exception e) catch (Exception e)
{ {
IsConfigured = false; 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"}, {"action", "basic"},
{"searchsubmit", "1"} {"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)) foreach (var cat in MapTorznabCapsToTrackers(query))
{ {
queryCollection.Add("filter_cat[" + cat + "]", "1"); queryCollection.Add("filter_cat[" + cat + "]", "1");
} }
searchUrl += "?" + queryCollection.GetQueryString(); searchUrl += "?" + queryCollection.GetQueryString();
var results = await RequestWithCookiesAsync(searchUrl); var results = await RequestWithCookiesAsync(searchUrl, headers: headers);
if (IsSessionIsClosed(results)) if (IsSessionIsClosed(results))
{ {
throw new Exception("The user is not logged in. It is possible that the cookie has expired or you " + throw new Exception("The user is not logged in. It is possible that the cookie has expired or you " +