From c8831b157e2da6bc1f82f2423499c1eadc5e3a4b Mon Sep 17 00:00:00 2001 From: kaso17 Date: Sun, 6 Nov 2016 17:41:22 +0100 Subject: [PATCH] TorrentBytes: Login again if the cookies became invalid (#651) --- src/Jackett/Indexers/TorrentBytes.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Jackett/Indexers/TorrentBytes.cs b/src/Jackett/Indexers/TorrentBytes.cs index 045f44327..cb0a6aca6 100644 --- a/src/Jackett/Indexers/TorrentBytes.cs +++ b/src/Jackett/Indexers/TorrentBytes.cs @@ -73,7 +73,8 @@ namespace Jackett.Indexers public async Task ApplyConfiguration(JToken configJson) { - configData.LoadValuesFromJson(configJson); + if(configJson != null) + configData.LoadValuesFromJson(configJson); var pairs = new Dictionary { { "username", configData.Username.Value }, { "password", configData.Password.Value }, @@ -130,6 +131,13 @@ namespace Jackett.Indexers private async Task ProcessPage(List releases, string searchUrl) { var response = await RequestStringWithCookiesAndRetry(searchUrl, null, BrowseUrl); + // On IP change the cookies become invalid, login again and retry + if (response.IsRedirect) + { + await ApplyConfiguration(null); + response = await RequestStringWithCookiesAndRetry(searchUrl, null, BrowseUrl); + } + var results = response.Content; try {