diff --git a/Tranga/GlobalBase.cs b/Tranga/GlobalBase.cs index 36125fc..34b3cd7 100644 --- a/Tranga/GlobalBase.cs +++ b/Tranga/GlobalBase.cs @@ -1,4 +1,5 @@ -using Logging; +using System.Globalization; +using Logging; using Newtonsoft.Json; using Tranga.LibraryConnectors; using Tranga.NotificationConnectors; @@ -12,6 +13,7 @@ public abstract class GlobalBase protected HashSet notificationConnectors { get; init; } protected HashSet libraryConnectors { get; init; } protected List cachedPublications { get; init; } + protected static readonly NumberFormatInfo numberFormatDecimalPoint = new (){ NumberDecimalSeparator = "." }; protected GlobalBase(GlobalBase clone) { diff --git a/Tranga/MangaConnectors/MangaConnector.cs b/Tranga/MangaConnectors/MangaConnector.cs index 0fe756d..927dd03 100644 --- a/Tranga/MangaConnectors/MangaConnector.cs +++ b/Tranga/MangaConnectors/MangaConnector.cs @@ -52,10 +52,9 @@ public abstract class MangaConnector : GlobalBase { Log($"Getting new Chapters for {manga}"); Chapter[] newChapters = this.GetChapters(manga, language); - NumberFormatInfo decimalPoint = new (){ NumberDecimalSeparator = "." }; Log($"Checking for duplicates {manga}"); List newChaptersList = newChapters.Where(nChapter => - float.Parse(nChapter.chapterNumber, decimalPoint) > manga.ignoreChaptersBelow && + float.Parse(nChapter.chapterNumber, numberFormatDecimalPoint) > manga.ignoreChaptersBelow && !nChapter.CheckChapterIsDownloaded(settings.downloadLocation)).ToList(); Log($"{newChaptersList.Count} new chapters. {manga}"); diff --git a/Tranga/MangaConnectors/MangaDex.cs b/Tranga/MangaConnectors/MangaDex.cs index a3073b5..92ac155 100644 --- a/Tranga/MangaConnectors/MangaDex.cs +++ b/Tranga/MangaConnectors/MangaDex.cs @@ -221,9 +221,8 @@ public class MangaDex : MangaConnector } //Return Chapters ordered by Chapter-Number - NumberFormatInfo chapterNumberFormatInfo = new() { NumberDecimalSeparator = "." }; Log($"Got {chapters.Count} chapters. {manga}"); - return chapters.OrderBy(chapter => Convert.ToSingle(chapter.chapterNumber, chapterNumberFormatInfo)).ToArray(); + return chapters.OrderBy(chapter => Convert.ToSingle(chapter.chapterNumber, numberFormatDecimalPoint)).ToArray(); } public override HttpStatusCode DownloadChapter(Chapter chapter, ProgressToken? progressToken = null) diff --git a/Tranga/MangaConnectors/MangaKatana.cs b/Tranga/MangaConnectors/MangaKatana.cs index 3000ea8..992fb2f 100644 --- a/Tranga/MangaConnectors/MangaKatana.cs +++ b/Tranga/MangaConnectors/MangaKatana.cs @@ -156,13 +156,9 @@ public class MangaKatana : MangaConnector return Array.Empty(); //Return Chapters ordered by Chapter-Number - NumberFormatInfo chapterNumberFormatInfo = new() - { - NumberDecimalSeparator = "." - }; List chapters = ParseChaptersFromHtml(manga, requestUrl); Log($"Got {chapters.Count} chapters. {manga}"); - return chapters.OrderBy(chapter => Convert.ToSingle(chapter.chapterNumber, chapterNumberFormatInfo)).ToArray(); + return chapters.OrderBy(chapter => Convert.ToSingle(chapter.chapterNumber, numberFormatDecimalPoint)).ToArray(); } private List ParseChaptersFromHtml(Manga manga, string mangaUrl) diff --git a/Tranga/MangaConnectors/Manganato.cs b/Tranga/MangaConnectors/Manganato.cs index fedd909..38ec2b4 100644 --- a/Tranga/MangaConnectors/Manganato.cs +++ b/Tranga/MangaConnectors/Manganato.cs @@ -144,13 +144,9 @@ public class Manganato : MangaConnector return Array.Empty(); //Return Chapters ordered by Chapter-Number - NumberFormatInfo chapterNumberFormatInfo = new() - { - NumberDecimalSeparator = "." - }; List chapters = ParseChaptersFromHtml(manga, requestResult.result); Log($"Got {chapters.Count} chapters. {manga}"); - return chapters.OrderBy(chapter => Convert.ToSingle(chapter.chapterNumber, chapterNumberFormatInfo)).ToArray(); + return chapters.OrderBy(chapter => Convert.ToSingle(chapter.chapterNumber, numberFormatDecimalPoint)).ToArray(); } private List ParseChaptersFromHtml(Manga manga, Stream html) diff --git a/Tranga/MangaConnectors/Mangasee.cs b/Tranga/MangaConnectors/Mangasee.cs index b9072b7..4bbbcae 100644 --- a/Tranga/MangaConnectors/Mangasee.cs +++ b/Tranga/MangaConnectors/Mangasee.cs @@ -235,12 +235,8 @@ public class Mangasee : MangaConnector } //Return Chapters ordered by Chapter-Number - NumberFormatInfo chapterNumberFormatInfo = new() - { - NumberDecimalSeparator = "." - }; Log($"Got {chapters.Count} chapters. {manga}"); - return chapters.OrderBy(chapter => Convert.ToSingle(chapter.chapterNumber, chapterNumberFormatInfo)).ToArray(); + return chapters.OrderBy(chapter => Convert.ToSingle(chapter.chapterNumber, numberFormatDecimalPoint)).ToArray(); } public override HttpStatusCode DownloadChapter(Chapter chapter, ProgressToken? progressToken = null)