From 09b4752387734a7687999b7aa58f7bc0e1447d70 Mon Sep 17 00:00:00 2001 From: ilike2burnthing <59480337+ilike2burnthing@users.noreply.github.com> Date: Mon, 26 Sep 2022 23:32:31 +0100 Subject: [PATCH] bjshare: add useragent. resolves #13564 (#13575) --- src/Jackett.Common/Indexers/BJShare.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Jackett.Common/Indexers/BJShare.cs b/src/Jackett.Common/Indexers/BJShare.cs index 0b564114a..2c17a9853 100644 --- a/src/Jackett.Common/Indexers/BJShare.cs +++ b/src/Jackett.Common/Indexers/BJShare.cs @@ -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 headers = null; + + if (!string.IsNullOrEmpty(configData.UserAgent.Value)) + { + headers = new Dictionary(); + 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 " +