From 4da9c3027bf200648fe7208dad4f1c7c6a47ced0 Mon Sep 17 00:00:00 2001 From: MIRIMIRIM <59959583+MIRIMIRIM@users.noreply.github.com> Date: Tue, 13 Aug 2024 10:06:31 +0800 Subject: [PATCH] use Equals instead of ToLower --- OKP.Core/Interface/Acgnx/AcgnxAdapter.cs | 2 +- OKP.Core/Interface/Acgrip/AcgripAdapter.cs | 2 +- OKP.Core/Interface/Bangumi/BangumiAdapter.cs | 2 +- OKP.Core/Interface/Nyaa/NyaaAdapter.cs | 2 +- OKP.Core/Program.cs | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/OKP.Core/Interface/Acgnx/AcgnxAdapter.cs b/OKP.Core/Interface/Acgnx/AcgnxAdapter.cs index 5be8c1f..2433e55 100644 --- a/OKP.Core/Interface/Acgnx/AcgnxAdapter.cs +++ b/OKP.Core/Interface/Acgnx/AcgnxAdapter.cs @@ -42,7 +42,7 @@ public AcgnxAdapter(TorrentContent torrent, Template template, string siteType) httpClient.DefaultRequestHeaders.Add("user-agent", HttpHelper.GlobalUserAgent); this.template = template; this.torrent = torrent; - var cookieToken = HttpHelper.GlobalCookieContainer.GetCookies(httpClient.BaseAddress).ToList().Find(p => p.Name.ToLower() == "token"); + var cookieToken = HttpHelper.GlobalCookieContainer.GetCookies(httpClient.BaseAddress).ToList().Find(p => p.Name.AsSpan().Equals("token", StringComparison.OrdinalIgnoreCase)); if (cookieToken is null) { Log.Error("Cannot find token of {Site}", site); diff --git a/OKP.Core/Interface/Acgrip/AcgripAdapter.cs b/OKP.Core/Interface/Acgrip/AcgripAdapter.cs index 3fe0bc2..dfee098 100644 --- a/OKP.Core/Interface/Acgrip/AcgripAdapter.cs +++ b/OKP.Core/Interface/Acgrip/AcgripAdapter.cs @@ -148,7 +148,7 @@ private bool Valid() } foreach (var tracker in trackers) { - if (!torrent.Data.TorrentObject.Trackers.ToList().SelectMany(p => p).ToList().Exists(p => p.TrimEnd('/').ToLower() == tracker.TrimEnd('/').ToLower())) + if (!torrent.Data.TorrentObject.Trackers.SelectMany(p => p).Any(p => p.TrimEnd('/').Equals(tracker.TrimEnd('/'), StringComparison.OrdinalIgnoreCase))) { Log.Error("缺少Tracker:{0}", tracker); return false; diff --git a/OKP.Core/Interface/Bangumi/BangumiAdapter.cs b/OKP.Core/Interface/Bangumi/BangumiAdapter.cs index bc6995b..ab6743e 100644 --- a/OKP.Core/Interface/Bangumi/BangumiAdapter.cs +++ b/OKP.Core/Interface/Bangumi/BangumiAdapter.cs @@ -73,7 +73,7 @@ public override async Task PingAsync() } else { - foreach (var team in teamList.Where(team => team.name.ToLower() == template.Name.ToLower())) + foreach (var team in teamList.Where(team => team.name.Equals(template.Name, StringComparison.OrdinalIgnoreCase))) { teamID = team._id; tagID = team.tag_id; diff --git a/OKP.Core/Interface/Nyaa/NyaaAdapter.cs b/OKP.Core/Interface/Nyaa/NyaaAdapter.cs index b3f0f92..f10a90f 100644 --- a/OKP.Core/Interface/Nyaa/NyaaAdapter.cs +++ b/OKP.Core/Interface/Nyaa/NyaaAdapter.cs @@ -141,7 +141,7 @@ private bool Valid() } foreach (var tracker in trackers) { - if (!torrent.Data.TorrentObject.Trackers.ToList().SelectMany(p => p).ToList().Exists(p => p.TrimEnd('/').ToLower() == tracker.TrimEnd('/').ToLower())) + if (!torrent.Data.TorrentObject.Trackers.SelectMany(p => p).Any(p => p.TrimEnd('/').Equals(tracker.TrimEnd('/'), StringComparison.OrdinalIgnoreCase))) { Log.Error("缺少Tracker:{0}", tracker); return false; diff --git a/OKP.Core/Program.cs b/OKP.Core/Program.cs index 35a028c..3024fed 100644 --- a/OKP.Core/Program.cs +++ b/OKP.Core/Program.cs @@ -73,15 +73,15 @@ public static void Main(string[] args) Log.Error("文件{File}不存在", file); continue; } - var extension = (Path.GetExtension(file) ?? "").ToLower(); + var extension = (Path.GetExtension(file) ?? "").AsSpan(); - if (extension == ".torrent") + if (extension.Equals(".torrent", StringComparison.OrdinalIgnoreCase)) { Log.Information("正在发布 {File}", file); SinglePublish(file, o.SettingFile, o.Cookies,o.AllowSkip); continue; } - if (extension == ".txt") + if (extension.Equals(".torrent", StringComparison.OrdinalIgnoreCase)) { if (o.Cookies is null) {