From 1d6980c0e8dca6ed6f2e8f8c99438a392622cc30 Mon Sep 17 00:00:00 2001 From: Diego Heras Date: Mon, 19 Oct 2020 22:50:19 +0200 Subject: [PATCH] core: code cleanup (#9908) --- src/Jackett.Common/Indexers/Abnormal.cs | 6 +++--- src/Jackett.Common/Indexers/Anidex.cs | 7 +++---- src/Jackett.Common/Indexers/AnimeBytes.cs | 1 - src/Jackett.Common/Indexers/BakaBT.cs | 1 - src/Jackett.Common/Indexers/BaseIndexer.cs | 2 +- src/Jackett.Common/Indexers/BroadcasTheNet.cs | 1 - src/Jackett.Common/Indexers/DigitalCore.cs | 2 +- src/Jackett.Common/Indexers/EpubLibre.cs | 1 - src/Jackett.Common/Indexers/Fuzer.cs | 2 +- src/Jackett.Common/Indexers/ImmortalSeed.cs | 1 - src/Jackett.Common/Indexers/Libble.cs | 1 - src/Jackett.Common/Indexers/NorBits.cs | 16 ++++++++-------- src/Jackett.Common/Indexers/PassThePopcorn.cs | 1 - src/Jackett.Common/Indexers/RarBG.cs | 1 - src/Jackett.Common/Indexers/ShowRSS.cs | 1 - src/Jackett.Common/Indexers/SuperBits.cs | 2 +- src/Jackett.Common/Indexers/TorrentLeech.cs | 1 - src/Jackett.Common/Indexers/TorrentMafya.cs | 1 - src/Jackett.Common/Indexers/TorrentSyndikat.cs | 10 ++++------ src/Jackett.Common/Indexers/Xthor.cs | 2 +- 20 files changed, 23 insertions(+), 37 deletions(-) diff --git a/src/Jackett.Common/Indexers/Abnormal.cs b/src/Jackett.Common/Indexers/Abnormal.cs index 8d2bd7d90..287ef09ba 100644 --- a/src/Jackett.Common/Indexers/Abnormal.cs +++ b/src/Jackett.Common/Indexers/Abnormal.cs @@ -21,7 +21,7 @@ using Jackett.Common.Utils.Clients; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using NLog; -using WebRequest = Jackett.Common.Utils.Clients.WebRequest; +using WebClient = Jackett.Common.Utils.Clients.WebClient; namespace Jackett.Common.Indexers { @@ -48,10 +48,10 @@ namespace Jackett.Common.Indexers private ConfigurationDataAbnormal ConfigData { get => (ConfigurationDataAbnormal)configData; - set => base.configData = value; + set => configData = value; } - public Abnormal(IIndexerConfigurationService configService, Utils.Clients.WebClient w, Logger l, IProtectionService ps) + public Abnormal(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps) : base(id: "abnormal", name: "Abnormal", description: "General French Private Tracker", diff --git a/src/Jackett.Common/Indexers/Anidex.cs b/src/Jackett.Common/Indexers/Anidex.cs index 3b5cdf99c..c6e58b6f0 100644 --- a/src/Jackett.Common/Indexers/Anidex.cs +++ b/src/Jackett.Common/Indexers/Anidex.cs @@ -14,7 +14,6 @@ using Jackett.Common.Models; using Jackett.Common.Models.IndexerConfig; using Jackett.Common.Services.Interfaces; using Jackett.Common.Utils; -using Jackett.Common.Utils.Clients; using Newtonsoft.Json.Linq; using NLog; using static Jackett.Common.Models.IndexerConfig.ConfigurationData; @@ -162,13 +161,13 @@ namespace Jackett.Common.Indexers var response = await RequestWithCookiesAndRetryAsync(searchUri.AbsoluteUri); // Check for DDOS Guard - if (response.Status == System.Net.HttpStatusCode.Forbidden) + if (response.Status == HttpStatusCode.Forbidden) { await ConfigureDDoSGuardCookie(); response = await RequestWithCookiesAndRetryAsync(searchUri.AbsoluteUri); } - if (response.Status != System.Net.HttpStatusCode.OK) + if (response.Status != HttpStatusCode.OK) throw new WebException($"Anidex search returned unexpected result. Expected 200 OK but got {response.Status}.", WebExceptionStatus.ProtocolError); // Search seems to have been a success so parse it @@ -224,7 +223,7 @@ namespace Jackett.Common.Indexers { const string ddosPostUrl = "https://check.ddos-guard.net/check.js"; var response = await RequestWithCookiesAsync(ddosPostUrl, string.Empty); - if (response.Status != System.Net.HttpStatusCode.OK) + if (response.Status != HttpStatusCode.OK) throw new WebException($"Unexpected DDOS Guard response: Status: {response.Status}", WebExceptionStatus.ProtocolError); if (response.IsRedirect) throw new WebException($"Unexpected DDOS Guard response: Redirect: {response.RedirectingTo}", WebExceptionStatus.UnknownError); diff --git a/src/Jackett.Common/Indexers/AnimeBytes.cs b/src/Jackett.Common/Indexers/AnimeBytes.cs index 742cb4c5c..ae839455d 100644 --- a/src/Jackett.Common/Indexers/AnimeBytes.cs +++ b/src/Jackett.Common/Indexers/AnimeBytes.cs @@ -12,7 +12,6 @@ using Jackett.Common.Models; using Jackett.Common.Models.IndexerConfig.Bespoke; using Jackett.Common.Services.Interfaces; using Jackett.Common.Utils; -using Jackett.Common.Utils.Clients; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using NLog; diff --git a/src/Jackett.Common/Indexers/BakaBT.cs b/src/Jackett.Common/Indexers/BakaBT.cs index 592ea5934..6db5d4ed1 100644 --- a/src/Jackett.Common/Indexers/BakaBT.cs +++ b/src/Jackett.Common/Indexers/BakaBT.cs @@ -10,7 +10,6 @@ using System.Threading.Tasks; using AngleSharp.Dom; using AngleSharp.Html.Parser; using Jackett.Common.Models; -using Jackett.Common.Models.IndexerConfig; using Jackett.Common.Models.IndexerConfig.Bespoke; using Jackett.Common.Services.Interfaces; using Jackett.Common.Utils.Clients; diff --git a/src/Jackett.Common/Indexers/BaseIndexer.cs b/src/Jackett.Common/Indexers/BaseIndexer.cs index a0c075a13..65cf9e7af 100644 --- a/src/Jackett.Common/Indexers/BaseIndexer.cs +++ b/src/Jackett.Common/Indexers/BaseIndexer.cs @@ -459,7 +459,7 @@ namespace Jackett.Common.Indexers protected async Task RequestLoginAndFollowRedirect(string url, IEnumerable> data, string cookies, bool returnCookiesFromFirstCall, string redirectUrlOverride = null, string referer = null, bool accumulateCookies = false) { - var request = new Utils.Clients.WebRequest() + var request = new WebRequest() { Url = url, Type = RequestType.POST, diff --git a/src/Jackett.Common/Indexers/BroadcasTheNet.cs b/src/Jackett.Common/Indexers/BroadcasTheNet.cs index e1afeb7c3..205d8dc1e 100644 --- a/src/Jackett.Common/Indexers/BroadcasTheNet.cs +++ b/src/Jackett.Common/Indexers/BroadcasTheNet.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Text; -using System.Text.RegularExpressions; using System.Threading.Tasks; using Jackett.Common.Models; using Jackett.Common.Models.IndexerConfig; diff --git a/src/Jackett.Common/Indexers/DigitalCore.cs b/src/Jackett.Common/Indexers/DigitalCore.cs index dff41bc4a..ce63a8144 100644 --- a/src/Jackett.Common/Indexers/DigitalCore.cs +++ b/src/Jackett.Common/Indexers/DigitalCore.cs @@ -150,7 +150,7 @@ namespace Jackett.Common.Indexers { //var json = JArray.Parse(results.Content); dynamic json = JsonConvert.DeserializeObject(results.ContentString); - foreach (var row in json ?? System.Linq.Enumerable.Empty()) + foreach (var row in json ?? Enumerable.Empty()) { var release = new ReleaseInfo(); var descriptions = new List(); diff --git a/src/Jackett.Common/Indexers/EpubLibre.cs b/src/Jackett.Common/Indexers/EpubLibre.cs index 3c617906c..381b4e39c 100644 --- a/src/Jackett.Common/Indexers/EpubLibre.cs +++ b/src/Jackett.Common/Indexers/EpubLibre.cs @@ -9,7 +9,6 @@ using AngleSharp.Html.Parser; using Jackett.Common.Models; using Jackett.Common.Models.IndexerConfig; using Jackett.Common.Services.Interfaces; -using Jackett.Common.Utils.Clients; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using NLog; diff --git a/src/Jackett.Common/Indexers/Fuzer.cs b/src/Jackett.Common/Indexers/Fuzer.cs index 8d50a8093..aed4c42d1 100644 --- a/src/Jackett.Common/Indexers/Fuzer.cs +++ b/src/Jackett.Common/Indexers/Fuzer.cs @@ -36,7 +36,7 @@ namespace Jackett.Common.Indexers set => base.configData = value; } - public Fuzer(IIndexerConfigurationService configService, Utils.Clients.WebClient w, Logger l, IProtectionService ps) + public Fuzer(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps) : base(id: "fuzer", name: "Fuzer", description: "Fuzer is a private torrent website with israeli torrents.", diff --git a/src/Jackett.Common/Indexers/ImmortalSeed.cs b/src/Jackett.Common/Indexers/ImmortalSeed.cs index c436b44ac..82086f1e4 100644 --- a/src/Jackett.Common/Indexers/ImmortalSeed.cs +++ b/src/Jackett.Common/Indexers/ImmortalSeed.cs @@ -11,7 +11,6 @@ using Jackett.Common.Models; using Jackett.Common.Models.IndexerConfig; using Jackett.Common.Services.Interfaces; using Jackett.Common.Utils; -using Jackett.Common.Utils.Clients; using Newtonsoft.Json.Linq; using NLog; diff --git a/src/Jackett.Common/Indexers/Libble.cs b/src/Jackett.Common/Indexers/Libble.cs index 127733d54..037c38c96 100644 --- a/src/Jackett.Common/Indexers/Libble.cs +++ b/src/Jackett.Common/Indexers/Libble.cs @@ -15,7 +15,6 @@ using Jackett.Common.Utils; using Jackett.Common.Utils.Clients; using Newtonsoft.Json.Linq; using NLog; -using static Jackett.Common.Models.IndexerConfig.ConfigurationData; namespace Jackett.Common.Indexers { diff --git a/src/Jackett.Common/Indexers/NorBits.cs b/src/Jackett.Common/Indexers/NorBits.cs index dd04d6311..4a0638afb 100644 --- a/src/Jackett.Common/Indexers/NorBits.cs +++ b/src/Jackett.Common/Indexers/NorBits.cs @@ -42,7 +42,7 @@ namespace Jackett.Common.Indexers private ConfigurationDataNorbits ConfigData => (ConfigurationDataNorbits)configData; - public NorBits(IIndexerConfigurationService configService, Utils.Clients.WebClient w, Logger l, IProtectionService ps) + public NorBits(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps) : base(id: "norbits", name: "NorBits", description: "NorBits is a Norwegian Private site for MOVIES / TV / GENERAL", @@ -134,7 +134,7 @@ namespace Jackett.Common.Indexers private async Task DoLogin() { // Build WebRequest for index - var myIndexRequest = new Utils.Clients.WebRequest() + var myIndexRequest = new WebRequest() { Type = RequestType.GET, Url = SiteLink, @@ -153,7 +153,7 @@ namespace Jackett.Common.Indexers }; // Build WebRequest for login - var myRequestLogin = new Utils.Clients.WebRequest() + var myRequestLogin = new WebRequest() { Type = RequestType.GET, Url = LoginUrl, @@ -169,7 +169,7 @@ namespace Jackett.Common.Indexers await webclient.GetResultAsync(myRequestLogin); // Build WebRequest for submitting authentification - var request = new Utils.Clients.WebRequest() + var request = new WebRequest() { PostData = pairs, Referer = LoginUrl, @@ -504,11 +504,11 @@ namespace Jackett.Common.Indexers var file = Directory + request.GetHashCode() + ".json"; // Checking modes states - if (System.IO.File.Exists(file)) + if (File.Exists(file)) { // File exist... loading it right now ! Output("Loading results from hard drive cache ..." + request.GetHashCode() + ".json"); - results = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(file)); + results = JsonConvert.DeserializeObject(File.ReadAllText(file)); } else { @@ -517,7 +517,7 @@ namespace Jackett.Common.Indexers // Cached file didn't exist for our query, writing it right now ! Output("Writing results to hard drive cache ..." + request.GetHashCode() + ".json"); - System.IO.File.WriteAllText(file, JsonConvert.SerializeObject(results)); + File.WriteAllText(file, JsonConvert.SerializeObject(results)); } return results; } @@ -571,7 +571,7 @@ namespace Jackett.Common.Indexers // Check if there is file older than ... and delete them Output("\nCleaning Provider Storage folder... in progress."); System.IO.Directory.GetFiles(Directory) - .Select(f => new System.IO.FileInfo(f)) + .Select(f => new FileInfo(f)) .Where(f => f.LastAccessTime < DateTime.Now.AddMilliseconds(-Convert.ToInt32(ConfigData.HardDriveCacheKeepTime.Value))) .ToList() .ForEach(f => diff --git a/src/Jackett.Common/Indexers/PassThePopcorn.cs b/src/Jackett.Common/Indexers/PassThePopcorn.cs index 8e1a45755..9aff2dec2 100644 --- a/src/Jackett.Common/Indexers/PassThePopcorn.cs +++ b/src/Jackett.Common/Indexers/PassThePopcorn.cs @@ -11,7 +11,6 @@ using Jackett.Common.Models; using Jackett.Common.Models.IndexerConfig; using Jackett.Common.Services.Interfaces; using Jackett.Common.Utils; -using Jackett.Common.Utils.Clients; using Newtonsoft.Json.Linq; using NLog; diff --git a/src/Jackett.Common/Indexers/RarBG.cs b/src/Jackett.Common/Indexers/RarBG.cs index fdf7eb264..bc357e6c6 100644 --- a/src/Jackett.Common/Indexers/RarBG.cs +++ b/src/Jackett.Common/Indexers/RarBG.cs @@ -11,7 +11,6 @@ using Jackett.Common.Models; using Jackett.Common.Models.IndexerConfig; using Jackett.Common.Services.Interfaces; using Jackett.Common.Utils; -using Jackett.Common.Utils.Clients; using Newtonsoft.Json.Linq; using NLog; using static Jackett.Common.Models.IndexerConfig.ConfigurationData; diff --git a/src/Jackett.Common/Indexers/ShowRSS.cs b/src/Jackett.Common/Indexers/ShowRSS.cs index 4b7461a47..d96e8c584 100644 --- a/src/Jackett.Common/Indexers/ShowRSS.cs +++ b/src/Jackett.Common/Indexers/ShowRSS.cs @@ -9,7 +9,6 @@ using System.Xml; using Jackett.Common.Models; using Jackett.Common.Models.IndexerConfig; using Jackett.Common.Services.Interfaces; -using Jackett.Common.Utils; using Jackett.Common.Utils.Clients; using Newtonsoft.Json.Linq; using NLog; diff --git a/src/Jackett.Common/Indexers/SuperBits.cs b/src/Jackett.Common/Indexers/SuperBits.cs index 0245900b8..37c74da89 100644 --- a/src/Jackett.Common/Indexers/SuperBits.cs +++ b/src/Jackett.Common/Indexers/SuperBits.cs @@ -142,7 +142,7 @@ namespace Jackett.Common.Indexers { //var json = JArray.Parse(results.Content); dynamic json = JsonConvert.DeserializeObject(results.ContentString); - foreach (var row in json ?? System.Linq.Enumerable.Empty()) + foreach (var row in json ?? Enumerable.Empty()) { var release = new ReleaseInfo(); var descriptions = new List(); diff --git a/src/Jackett.Common/Indexers/TorrentLeech.cs b/src/Jackett.Common/Indexers/TorrentLeech.cs index 1bd77ca0e..29e4092ed 100644 --- a/src/Jackett.Common/Indexers/TorrentLeech.cs +++ b/src/Jackett.Common/Indexers/TorrentLeech.cs @@ -12,7 +12,6 @@ using Jackett.Common.Models; using Jackett.Common.Models.IndexerConfig; using Jackett.Common.Services.Interfaces; using Jackett.Common.Utils; -using Jackett.Common.Utils.Clients; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using NLog; diff --git a/src/Jackett.Common/Indexers/TorrentMafya.cs b/src/Jackett.Common/Indexers/TorrentMafya.cs index 42defe80c..7450c7349 100644 --- a/src/Jackett.Common/Indexers/TorrentMafya.cs +++ b/src/Jackett.Common/Indexers/TorrentMafya.cs @@ -9,7 +9,6 @@ using AngleSharp.Html.Parser; using Jackett.Common.Models; using Jackett.Common.Models.IndexerConfig; using Jackett.Common.Services.Interfaces; -using Jackett.Common.Utils; using Jackett.Common.Utils.Clients; using Newtonsoft.Json; using Newtonsoft.Json.Linq; diff --git a/src/Jackett.Common/Indexers/TorrentSyndikat.cs b/src/Jackett.Common/Indexers/TorrentSyndikat.cs index e86704873..b330bfa87 100644 --- a/src/Jackett.Common/Indexers/TorrentSyndikat.cs +++ b/src/Jackett.Common/Indexers/TorrentSyndikat.cs @@ -7,12 +7,10 @@ using System.Net; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; -using AngleSharp.Html.Parser; using Jackett.Common.Models; using Jackett.Common.Models.IndexerConfig; using Jackett.Common.Services.Interfaces; using Jackett.Common.Utils; -using Jackett.Common.Utils.Clients; using Newtonsoft.Json.Linq; using NLog; using WebClient = Jackett.Common.Utils.Clients.WebClient; @@ -26,8 +24,8 @@ namespace Jackett.Common.Indexers private ConfigurationDataAPIKey ConfigData { - get => (ConfigurationDataAPIKey)base.configData; - set => base.configData = value; + get => (ConfigurationDataAPIKey)configData; + set => configData = value; } public TorrentSyndikat(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps) @@ -155,7 +153,7 @@ namespace Jackett.Common.Indexers foreach (var row in jsonContent.Value("rows")) { - var dateTime = new DateTime(1970,1,1,0,0,0,0,System.DateTimeKind.Utc); + var dateTime = new DateTime(1970,1,1,0,0,0,0,DateTimeKind.Utc); var id = row.Value("id"); var comments = new Uri(SiteLink + "details.php?id=" + id); @@ -250,7 +248,7 @@ namespace Jackett.Common.Indexers return response.ContentBytes; } - private static void CheckResponseStatus(System.Net.HttpStatusCode status, string scope) + private static void CheckResponseStatus(HttpStatusCode status, string scope) { switch (status) { diff --git a/src/Jackett.Common/Indexers/Xthor.cs b/src/Jackett.Common/Indexers/Xthor.cs index 5cb81f5a9..9fd1f16a2 100644 --- a/src/Jackett.Common/Indexers/Xthor.cs +++ b/src/Jackett.Common/Indexers/Xthor.cs @@ -490,7 +490,7 @@ namespace Jackett.Common.Indexers Output("\nQuerying tracker for results...."); // Build WebRequest for index - var myIndexRequest = new Utils.Clients.WebRequest() + var myIndexRequest = new WebRequest() { Type = RequestType.GET, Url = request,