diff --git a/src/DateTimeRoutines/DateTimeRoutines.csproj b/src/DateTimeRoutines/DateTimeRoutines.csproj index b67128d3c..19c517c26 100644 --- a/src/DateTimeRoutines/DateTimeRoutines.csproj +++ b/src/DateTimeRoutines/DateTimeRoutines.csproj @@ -2,7 +2,7 @@ netstandard2.0 - 8 + 9 false diff --git a/src/Jackett.Common/Indexers/Definitions/Abstract/AvistazTracker.cs b/src/Jackett.Common/Indexers/Definitions/Abstract/AvistazTracker.cs index cc3cad01f..d7fa9484b 100644 --- a/src/Jackett.Common/Indexers/Definitions/Abstract/AvistazTracker.cs +++ b/src/Jackett.Common/Indexers/Definitions/Abstract/AvistazTracker.cs @@ -225,13 +225,13 @@ namespace Jackett.Common.Indexers.Definitions.Abstract var description = ""; var jAudio = row.Value("audio"); - if (jAudio != null && jAudio.HasValues) + if (jAudio is { HasValues: true }) { var audioList = jAudio.Select(tag => tag.Value("language")).ToList(); description += $"Audio: {string.Join(", ", audioList)}"; } var jSubtitle = row.Value("subtitle"); - if (jSubtitle != null && jSubtitle.HasValues) + if (jSubtitle is { HasValues: true }) { var subtitleList = jSubtitle.Select(tag => tag.Value("language")).ToList(); description += $"
Subtitles: {string.Join(", ", subtitleList)}"; @@ -260,7 +260,7 @@ namespace Jackett.Common.Indexers.Definitions.Abstract Subs = row.Value("subtitle")?.Select(x => x.Value("language")).ToList() ?? new List(), }; - if (release.Size.HasValue && release.Size > 0) + if (release.Size is > 0) { var sizeGigabytes = release.Size.Value / Math.Pow(1024, 3); @@ -270,7 +270,7 @@ namespace Jackett.Common.Indexers.Definitions.Abstract } var jMovieTv = row.Value("movie_tv"); - if (jMovieTv != null && jMovieTv.HasValues) + if (jMovieTv is { HasValues: true }) { release.Imdb = ParseUtil.GetImdbId(jMovieTv.Value("imdb")); diff --git a/src/Jackett.Common/Indexers/Definitions/Abstract/GazelleTracker.cs b/src/Jackett.Common/Indexers/Definitions/Abstract/GazelleTracker.cs index 7dd9eeb8e..6a44e17ff 100644 --- a/src/Jackett.Common/Indexers/Definitions/Abstract/GazelleTracker.cs +++ b/src/Jackett.Common/Indexers/Definitions/Abstract/GazelleTracker.cs @@ -234,11 +234,11 @@ namespace Jackett.Common.Indexers.Definitions.Abstract queryCollection.Set("filter_cat[" + cat + "]", "1"); } - if (configData.FreeleechOnly != null && configData.FreeleechOnly.Value) + if (configData.FreeleechOnly is { Value: true }) { queryCollection.Set("freetorrent", "1"); } - else if (configData.FreeloadOnly != null && configData.FreeloadOnly.Value) + else if (configData.FreeloadOnly is { Value: true }) { queryCollection.Set("freetorrent", "4"); } @@ -397,7 +397,7 @@ namespace Jackett.Common.Indexers.Definitions.Abstract var isFreeleech = bool.TryParse((string)torrent["isFreeleech"], out var freeleech) && freeleech; // skip non-freeleech results when freeleech only is set - return configData.FreeleechOnly != null && configData.FreeleechOnly.Value && !isFreeleech; + return configData.FreeleechOnly is { Value: true } && !isFreeleech; } protected void FillReleaseInfoFromJson(ReleaseInfo release, JObject torrent) @@ -522,7 +522,7 @@ namespace Jackett.Common.Indexers.Definitions.Abstract } var isPersonalFreeleech = (bool?)torrent["isPersonalFreeleech"]; - if (isPersonalFreeleech != null && isPersonalFreeleech == true) + if (isPersonalFreeleech is true) { release.DownloadVolumeFactor = 0; } diff --git a/src/Jackett.Common/Indexers/Definitions/AnimeBytes.cs b/src/Jackett.Common/Indexers/Definitions/AnimeBytes.cs index bff3d31d2..4773942ff 100644 --- a/src/Jackett.Common/Indexers/Definitions/AnimeBytes.cs +++ b/src/Jackett.Common/Indexers/Definitions/AnimeBytes.cs @@ -33,7 +33,7 @@ namespace Jackett.Common.Indexers.Definitions private string ScrapeUrl => SiteLink + "scrape.php"; private bool AllowRaws => ConfigData.IncludeRaw.Value; - private bool PadEpisode => ConfigData.PadEpisode != null && ConfigData.PadEpisode.Value; + private bool PadEpisode => ConfigData.PadEpisode is { Value: true }; private bool AddJapaneseTitle => ConfigData.AddJapaneseTitle.Value; private bool AddRomajiTitle => ConfigData.AddRomajiTitle.Value; private bool AddAlternativeTitles => ConfigData.AddAlternativeTitles.Value; @@ -455,7 +455,7 @@ namespace Jackett.Common.Indexers.Definitions if (FilterSeasonEpisode) { - if (query.Season.HasValue && query.Season > 0 && season != null && season != query.Season) // skip if season doesn't match + if (query.Season is > 0 && season != null && season != query.Season) // skip if season doesn't match { continue; } diff --git a/src/Jackett.Common/Indexers/Definitions/CardigannIndexer.cs b/src/Jackett.Common/Indexers/Definitions/CardigannIndexer.cs index 33e82d21d..1bfb12b10 100644 --- a/src/Jackett.Common/Indexers/Definitions/CardigannIndexer.cs +++ b/src/Jackett.Common/Indexers/Definitions/CardigannIndexer.cs @@ -98,7 +98,7 @@ namespace Jackett.Common.Indexers.Definitions if (Definition.RequestDelay != null) webclient.requestDelay = Definition.RequestDelay.Value; - if (Definition.Login != null && Definition.Login.Method == null) + if (Definition.Login is { Method: null }) Definition.Login.Method = "form"; if (Definition.Search.Paths == null) @@ -146,7 +146,7 @@ namespace Jackett.Common.Indexers.Definitions case "checkbox": item = new BoolConfigurationItem(itemName) { Value = false }; - if (Setting.Default != null && Setting.Default == "true") + if (Setting.Default is "true") { ((BoolConfigurationItem)item).Value = true; } @@ -1557,7 +1557,7 @@ namespace Jackett.Common.Indexers.Definitions var results = response.ContentString; - if (SearchPath.Response != null && SearchPath.Response.Type.Equals("json")) + if (SearchPath.Response is { Type: "json" }) { // check if we need to login again var loginNeeded = CheckIfLoginIsNeeded(response); @@ -1591,8 +1591,7 @@ namespace Jackett.Common.Indexers.Definitions } if (response.Status == HttpStatusCode.OK - && SearchPath.Response != null - && SearchPath.Response.NoResultsMessage != null + && SearchPath.Response is { NoResultsMessage: not null } && (SearchPath.Response.NoResultsMessage != string.Empty && results.Contains(SearchPath.Response.NoResultsMessage) || (SearchPath.Response.NoResultsMessage == string.Empty && results == string.Empty))) { continue; @@ -1733,7 +1732,7 @@ namespace Jackett.Common.Indexers.Definitions { IHtmlCollection rowsDom; - if (SearchPath.Response != null && SearchPath.Response.Type.Equals("xml")) + if (SearchPath.Response is { Type: "xml" }) { var SearchResultParser = new XmlParser(); var SearchResultDocument = SearchResultParser.ParseDocument(results); diff --git a/src/Jackett.Common/Indexers/Definitions/GreatPosterWall.cs b/src/Jackett.Common/Indexers/Definitions/GreatPosterWall.cs index a39132e48..552f9b6ce 100644 --- a/src/Jackett.Common/Indexers/Definitions/GreatPosterWall.cs +++ b/src/Jackett.Common/Indexers/Definitions/GreatPosterWall.cs @@ -145,7 +145,7 @@ namespace Jackett.Common.Indexers.Definitions } var isPersonalFreeleech = (bool?)torrent["isPersonalFreeleech"]; - if (isPersonalFreeleech != null && isPersonalFreeleech == true) + if (isPersonalFreeleech is true) release.DownloadVolumeFactor = 0; var imdbID = (string)result["imdbId"]; diff --git a/src/Jackett.Common/Indexers/Definitions/LostFilm.cs b/src/Jackett.Common/Indexers/Definitions/LostFilm.cs index d95e53c0f..2320c2a6c 100644 --- a/src/Jackett.Common/Indexers/Definitions/LostFilm.cs +++ b/src/Jackett.Common/Indexers/Definitions/LostFilm.cs @@ -385,7 +385,7 @@ namespace Jackett.Common.Indexers.Definitions foreach (var serie in series) { var link = serie["link"].ToString(); - var season = query.Season.HasValue && query.Season > 0 ? $"/season_{query.Season}" : "/seasons"; + var season = query.Season is > 0 ? $"/season_{query.Season}" : "/seasons"; var url = SiteLink + link.TrimStart('/') + season; if (!string.IsNullOrEmpty(query.Episode)) // Fetch single episode releases diff --git a/src/Jackett.Common/Indexers/Definitions/MejorTorrent.cs b/src/Jackett.Common/Indexers/Definitions/MejorTorrent.cs index f392c9cac..801d4a50e 100644 --- a/src/Jackett.Common/Indexers/Definitions/MejorTorrent.cs +++ b/src/Jackett.Common/Indexers/Definitions/MejorTorrent.cs @@ -222,7 +222,7 @@ namespace Jackett.Common.Indexers.Definitions { // check there are results var rows = table.Children; - if (rows != null && rows.Length > 0) + if (rows is { Length: > 0 }) foreach (var row in rows) { var rowQuality = row.Children[0].Children[0].Children[0].TextContent; diff --git a/src/Jackett.Common/Indexers/Definitions/Redacted.cs b/src/Jackett.Common/Indexers/Definitions/Redacted.cs index 04d4082dd..2b59b682f 100644 --- a/src/Jackett.Common/Indexers/Definitions/Redacted.cs +++ b/src/Jackett.Common/Indexers/Definitions/Redacted.cs @@ -87,7 +87,7 @@ namespace Jackett.Common.Indexers.Definitions { var isFreeload = bool.TryParse((string)torrent["isFreeload"], out var freeload) && freeload; - if (configData.FreeloadOnly != null && configData.FreeloadOnly.Value && !isFreeload) + if (configData.FreeloadOnly is { Value: true } && !isFreeload) { return true; } diff --git a/src/Jackett.Common/Indexers/Definitions/RuTracker.cs b/src/Jackett.Common/Indexers/Definitions/RuTracker.cs index b5eaa4c1e..d6b79c267 100644 --- a/src/Jackett.Common/Indexers/Definitions/RuTracker.cs +++ b/src/Jackett.Common/Indexers/Definitions/RuTracker.cs @@ -1535,7 +1535,7 @@ namespace Jackett.Common.Indexers.Definitions { searchString = searchString.Replace("-", " "); - if (query.Season.HasValue && query.Season > 0) + if (query.Season is > 0) { searchString += " Сезон: " + query.Season; } diff --git a/src/Jackett.Common/Indexers/Definitions/Shazbat.cs b/src/Jackett.Common/Indexers/Definitions/Shazbat.cs index 1f8ca3485..bd0e6a9ed 100644 --- a/src/Jackett.Common/Indexers/Definitions/Shazbat.cs +++ b/src/Jackett.Common/Indexers/Definitions/Shazbat.cs @@ -64,7 +64,7 @@ namespace Jackett.Common.Indexers.Definitions return caps; } - private int ShowPagesFetchLimit => int.TryParse(configData.ShowPagesFetchLimit.Value, out var limit) && limit > 0 && limit <= 5 ? limit : 2; + private int ShowPagesFetchLimit => int.TryParse(configData.ShowPagesFetchLimit.Value, out var limit) && limit is > 0 and <= 5 ? limit : 2; public override async Task ApplyConfiguration(JToken configJson) { diff --git a/src/Jackett.Common/Indexers/Definitions/SubsPlease.cs b/src/Jackett.Common/Indexers/Definitions/SubsPlease.cs index 84000d176..861671abb 100644 --- a/src/Jackett.Common/Indexers/Definitions/SubsPlease.cs +++ b/src/Jackett.Common/Indexers/Definitions/SubsPlease.cs @@ -145,7 +145,7 @@ namespace Jackett.Common.Indexers.Definitions } // Only include season > 1 in searchTerm, format as S2 rather than S02 - if (query.Season.HasValue && query.Season.Value > 1) + if (query.Season is > 1) { searchTerm += $" S{query.Season}"; query.Season = 0; diff --git a/src/Jackett.Common/Indexers/Definitions/TVStore.cs b/src/Jackett.Common/Indexers/Definitions/TVStore.cs index 197b10721..afc3f48b2 100644 --- a/src/Jackett.Common/Indexers/Definitions/TVStore.cs +++ b/src/Jackett.Common/Indexers/Definitions/TVStore.cs @@ -303,7 +303,7 @@ namespace Jackett.Common.Indexers.Definitions queryParams.Add("c", Convert.ToBase64String(plainTextBytes)); } - if (query.Season.HasValue && query.Season > 0) + if (query.Season is > 0) { queryParams.Add("s", query.Season.ToString()); diff --git a/src/Jackett.Common/Indexers/Definitions/Toloka.cs b/src/Jackett.Common/Indexers/Definitions/Toloka.cs index 7d489b1eb..dfc2a42c8 100644 --- a/src/Jackett.Common/Indexers/Definitions/Toloka.cs +++ b/src/Jackett.Common/Indexers/Definitions/Toloka.cs @@ -272,7 +272,7 @@ namespace Jackett.Common.Indexers.Definitions { searchString = searchString.Replace("-", " "); - if (query.Season.HasValue && query.Season > 0) + if (query.Season is > 0) { searchString += " Сезон " + query.Season; } diff --git a/src/Jackett.Common/Jackett.Common.csproj b/src/Jackett.Common/Jackett.Common.csproj index 438ee365f..14a3b391b 100644 --- a/src/Jackett.Common/Jackett.Common.csproj +++ b/src/Jackett.Common/Jackett.Common.csproj @@ -3,7 +3,7 @@ netstandard2.0 0.0.0 - 8 + 9 false diff --git a/src/Jackett.Common/Models/TorznabQuery.cs b/src/Jackett.Common/Models/TorznabQuery.cs index 10c692fb7..863d66b34 100644 --- a/src/Jackett.Common/Models/TorznabQuery.cs +++ b/src/Jackett.Common/Models/TorznabQuery.cs @@ -102,7 +102,7 @@ namespace Jackett.Common.Models Publisher.IsNotNullOrWhiteSpace() || Year.HasValue; - public bool HasSpecifiedCategories => (Categories != null && Categories.Length > 0); + public bool HasSpecifiedCategories => Categories is { Length: > 0 }; public string SanitizedSearchTerm { @@ -224,7 +224,7 @@ namespace Jackett.Common.Models { var queryString = !string.IsNullOrWhiteSpace(queryStringOverride) ? queryStringOverride : GetQueryString(); - if (limit != null && limit > 0) + if (limit is > 0) { if (limit > queryString.Length) { diff --git a/src/Jackett.Common/Utils/Clients/WebClient.cs b/src/Jackett.Common/Utils/Clients/WebClient.cs index 9af7e4089..c0efb373a 100644 --- a/src/Jackett.Common/Utils/Clients/WebClient.cs +++ b/src/Jackett.Common/Utils/Clients/WebClient.cs @@ -192,7 +192,7 @@ namespace Jackett.Common.Utils.Clients var body = ""; var bodySize = 0; var isBinary = false; - if (result.ContentBytes != null && result.ContentBytes.Length > 0) + if (result.ContentBytes is { Length: > 0 }) { bodySize = result.ContentBytes.Length; var contentString = result.ContentString.Trim(); diff --git a/src/Jackett.Service/Service.cs b/src/Jackett.Service/Service.cs index 8d5f8baad..06a79ab45 100644 --- a/src/Jackett.Service/Service.cs +++ b/src/Jackett.Service/Service.cs @@ -82,11 +82,11 @@ namespace Jackett.Service private void StopConsoleApplication() { - if (consoleProcess != null && !consoleProcess.HasExited) + if (consoleProcess is { HasExited: false }) { consoleProcess.StandardInput.Close(); consoleProcess.WaitForExit(2000); - if (consoleProcess != null && !consoleProcess.HasExited) + if (consoleProcess is { HasExited: false }) { consoleProcess.Kill(); }