From c8225db4fe09ff16ae42032b26becf9335de6f07 Mon Sep 17 00:00:00 2001 From: glax Date: Sun, 16 Jul 2023 17:47:00 +0200 Subject: [PATCH] #30 #31 --- Tranga/Connector.cs | 8 ++++++-- Tranga/Publication.cs | 18 ++++-------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/Tranga/Connector.cs b/Tranga/Connector.cs index 85613d3..1b9b157 100644 --- a/Tranga/Connector.cs +++ b/Tranga/Connector.cs @@ -1,4 +1,5 @@ -using System.IO.Compression; +using System.Globalization; +using System.IO.Compression; using System.Net; using System.Runtime.InteropServices; using System.Text.RegularExpressions; @@ -66,8 +67,11 @@ public abstract class Connector { Chapter[] newChapters = this.GetChapters(publication, language); collection.Add(publication); + NumberFormatInfo decimalPoint = new (){ NumberDecimalSeparator = "." }; logger?.WriteLine(this.GetType().ToString(), "Checking for duplicates"); - List newChaptersList = newChapters.Where(nChapter => !nChapter.CheckChapterIsDownloaded(settings.downloadLocation)).ToList(); + List newChaptersList = newChapters.Where(nChapter => + float.Parse(nChapter.chapterNumber, decimalPoint) > publication.ignoreChaptersBelow && + !nChapter.CheckChapterIsDownloaded(settings.downloadLocation)).ToList(); logger?.WriteLine(this.GetType().ToString(), $"{newChaptersList.Count} new chapters."); return newChaptersList; diff --git a/Tranga/Publication.cs b/Tranga/Publication.cs index 03ef85c..860c58d 100644 --- a/Tranga/Publication.cs +++ b/Tranga/Publication.cs @@ -26,22 +26,11 @@ public readonly struct Publication public string folderName { get; } public string publicationId { get; } public string internalId { get; } + public uint ignoreChaptersBelow { get; } private static readonly Regex LegalCharacters = new Regex(@"[A-Z]*[a-z]*[0-9]* *\.*-*,*'*\'*\)*\(*~*!*"); - [JsonConstructor] //Legacy - public Publication(string sortName, string? author, string? description, Dictionary altTitles, - string[] tags, string? posterUrl, string? coverFileNameInCache, Dictionary? links, int? year, - string? originalLanguage, string status, string publicationId) - { - List pAuthors = new(); - if(author is not null) - pAuthors.Add(author); - this = new Publication(sortName, pAuthors, description, altTitles, tags, posterUrl, - coverFileNameInCache, links, year, originalLanguage, status, publicationId); - } - - public Publication(string sortName, List authors, string? description, Dictionary altTitles, string[] tags, string? posterUrl, string? coverFileNameInCache, Dictionary? links, int? year, string? originalLanguage, string status, string publicationId) + public Publication(string sortName, List authors, string? description, Dictionary altTitles, string[] tags, string? posterUrl, string? coverFileNameInCache, Dictionary? links, int? year, string? originalLanguage, string status, string publicationId, string? folderName = null, uint ignoreChaptersBelow = 0) { this.sortName = sortName; this.authors = authors; @@ -55,11 +44,12 @@ public readonly struct Publication this.originalLanguage = originalLanguage; this.status = status; this.publicationId = publicationId; - this.folderName = string.Concat(LegalCharacters.Matches(sortName)); + this.folderName = folderName ?? string.Concat(LegalCharacters.Matches(sortName)); while (this.folderName.EndsWith('.')) this.folderName = this.folderName.Substring(0, this.folderName.Length - 1); string onlyLowerLetters = string.Concat(this.sortName.ToLower().Where(Char.IsLetter)); this.internalId = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{onlyLowerLetters}{this.year}")); + this.ignoreChaptersBelow = ignoreChaptersBelow; } public string CreatePublicationFolder(string downloadDirectory)