2
0

cachedPublications

This commit is contained in:
glax 2023-08-26 02:42:57 +02:00
parent a89a526fda
commit 0cf3a95f58
5 changed files with 15 additions and 6 deletions

View File

@ -9,8 +9,9 @@ public abstract class GlobalBase
{
protected Logger? logger { get; init; }
protected TrangaSettings settings { get; init; }
private HashSet<NotificationConnector> notificationConnectors { get; init; }
private HashSet<LibraryConnector> libraryConnectors { get; init; }
protected HashSet<NotificationConnector> notificationConnectors { get; init; }
protected HashSet<LibraryConnector> libraryConnectors { get; init; }
protected List<Publication> 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)

View File

@ -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();
}

View File

@ -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;
}

View File

@ -30,7 +30,8 @@ public class Manganato : MangaConnector
return Array.Empty<Publication>();
Publication[] publications = ParsePublicationsFromHtml(requestResult.result);
Log($"Retrieved {publications.Length} publications.");
cachedPublications.AddRange(publications);
Log($"Retrieved {publications.Length} publications. Term=\"{publicationTitle}\"");
return publications;
}

View File

@ -78,7 +78,10 @@ public class Mangasee : MangaConnector
if ((int)requestResult.statusCode < 200 || (int)requestResult.statusCode >= 300)
return Array.Empty<Publication>();
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)