From 0cf3a95f58ef936efbcf3b053c33f8d3b34f4848 Mon Sep 17 00:00:00 2001 From: glax Date: Sat, 26 Aug 2023 02:42:57 +0200 Subject: [PATCH] cachedPublications --- Tranga/GlobalBase.cs | 7 +++++-- Tranga/MangaConnectors/MangaDex.cs | 3 ++- Tranga/MangaConnectors/MangaKatana.cs | 3 ++- Tranga/MangaConnectors/Manganato.cs | 3 ++- Tranga/MangaConnectors/Mangasee.cs | 5 ++++- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Tranga/GlobalBase.cs b/Tranga/GlobalBase.cs index cf2b365..1208f9a 100644 --- a/Tranga/GlobalBase.cs +++ b/Tranga/GlobalBase.cs @@ -9,8 +9,9 @@ public abstract class GlobalBase { protected Logger? logger { get; init; } protected TrangaSettings settings { get; init; } - private HashSet notificationConnectors { get; init; } - private HashSet libraryConnectors { get; init; } + protected HashSet notificationConnectors { get; init; } + protected HashSet libraryConnectors { get; init; } + protected List cachedPublications { get; init; } protected GlobalBase(GlobalBase clone) { @@ -18,6 +19,7 @@ public abstract class GlobalBase this.settings = clone.settings; this.notificationConnectors = clone.notificationConnectors; this.libraryConnectors = clone.libraryConnectors; + this.cachedPublications = clone.cachedPublications; } protected GlobalBase(Logger? logger, TrangaSettings settings) @@ -26,6 +28,7 @@ public abstract class GlobalBase this.settings = settings; this.notificationConnectors = settings.LoadNotificationConnectors(); this.libraryConnectors = settings.LoadLibraryConnectors(); + this.cachedPublications = new(); } protected void Log(string message) diff --git a/Tranga/MangaConnectors/MangaDex.cs b/Tranga/MangaConnectors/MangaDex.cs index edd362f..25c43ea 100644 --- a/Tranga/MangaConnectors/MangaDex.cs +++ b/Tranga/MangaConnectors/MangaDex.cs @@ -146,7 +146,8 @@ public class MangaDex : MangaConnector } } - Log($"Retrieved {publications.Count} publications."); + cachedPublications.AddRange(publications); + Log($"Retrieved {publications.Count} publications. Term=\"{publicationTitle}\""); return publications.ToArray(); } diff --git a/Tranga/MangaConnectors/MangaKatana.cs b/Tranga/MangaConnectors/MangaKatana.cs index f702953..70baee9 100644 --- a/Tranga/MangaConnectors/MangaKatana.cs +++ b/Tranga/MangaConnectors/MangaKatana.cs @@ -39,7 +39,8 @@ public class MangaKatana : MangaConnector } Publication[] publications = ParsePublicationsFromHtml(requestResult.result); - Log($"Retrieved {publications.Length} publications."); + cachedPublications.AddRange(publications); + Log($"Retrieved {publications.Length} publications. Term=\"{publicationTitle}\""); return publications; } diff --git a/Tranga/MangaConnectors/Manganato.cs b/Tranga/MangaConnectors/Manganato.cs index 3f0e9df..8467933 100644 --- a/Tranga/MangaConnectors/Manganato.cs +++ b/Tranga/MangaConnectors/Manganato.cs @@ -30,7 +30,8 @@ public class Manganato : MangaConnector return Array.Empty(); Publication[] publications = ParsePublicationsFromHtml(requestResult.result); - Log($"Retrieved {publications.Length} publications."); + cachedPublications.AddRange(publications); + Log($"Retrieved {publications.Length} publications. Term=\"{publicationTitle}\""); return publications; } diff --git a/Tranga/MangaConnectors/Mangasee.cs b/Tranga/MangaConnectors/Mangasee.cs index 5c528ab..fe89a0c 100644 --- a/Tranga/MangaConnectors/Mangasee.cs +++ b/Tranga/MangaConnectors/Mangasee.cs @@ -78,7 +78,10 @@ public class Mangasee : MangaConnector if ((int)requestResult.statusCode < 200 || (int)requestResult.statusCode >= 300) return Array.Empty(); - return ParsePublicationsFromHtml(requestResult.result, publicationTitle); + Publication[] publications = ParsePublicationsFromHtml(requestResult.result, publicationTitle); + cachedPublications.AddRange(publications); + Log($"Retrieved {publications.Length} publications. Term=\"{publicationTitle}\""); + return publications; } private Publication[] ParsePublicationsFromHtml(Stream html, string publicationTitle)