From bbd716383a93db3a60ab3a85b34926419997a4e2 Mon Sep 17 00:00:00 2001 From: glax Date: Sun, 27 Aug 2023 01:21:23 +0200 Subject: [PATCH] Added ToString overrides --- Tranga/Chapter.cs | 8 ++++++-- Tranga/Jobs/DownloadChapter.cs | 5 +++++ Tranga/Jobs/DownloadNewChapters.cs | 5 +++++ Tranga/LibraryConnectors/Kavita.cs | 5 +++++ Tranga/LibraryConnectors/Komga.cs | 5 +++++ Tranga/NotificationConnectors/Gotify.cs | 7 ++++++- Tranga/NotificationConnectors/LunaSea.cs | 5 +++++ Tranga/Publication.cs | 5 +++++ 8 files changed, 42 insertions(+), 3 deletions(-) diff --git a/Tranga/Chapter.cs b/Tranga/Chapter.cs index 0559f40..b5ddf32 100644 --- a/Tranga/Chapter.cs +++ b/Tranga/Chapter.cs @@ -35,8 +35,12 @@ public readonly struct Chapter chNameStr = IllegalStrings.Replace(chNameStr, ""); this.fileName = $"{volStr}{chNumberStr}{chNameStr}"; } - - + + public override string ToString() + { + return $"Chapter {parentPublication.sortName} {parentPublication.internalId} {chapterNumber} {name}"; + } + /// /// Checks if a chapter-archive is already present /// diff --git a/Tranga/Jobs/DownloadChapter.cs b/Tranga/Jobs/DownloadChapter.cs index c9674b6..2bab2ec 100644 --- a/Tranga/Jobs/DownloadChapter.cs +++ b/Tranga/Jobs/DownloadChapter.cs @@ -17,6 +17,11 @@ public class DownloadChapter : Job return Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Concat(this.GetType().ToString(), chapter.parentPublication.internalId, chapter.chapterNumber))); } + public override string ToString() + { + return $"DownloadChapter {id} {chapter}"; + } + protected override IEnumerable ExecuteReturnSubTasksInternal() { Task downloadTask = new(delegate diff --git a/Tranga/Jobs/DownloadNewChapters.cs b/Tranga/Jobs/DownloadNewChapters.cs index 9944267..13381e3 100644 --- a/Tranga/Jobs/DownloadNewChapters.cs +++ b/Tranga/Jobs/DownloadNewChapters.cs @@ -16,6 +16,11 @@ public class DownloadNewChapters : Job { return Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Concat(this.GetType().ToString(), publication.internalId))); } + + public override string ToString() + { + return $"DownloadChapter {id} {publication}"; + } protected override IEnumerable ExecuteReturnSubTasksInternal() { diff --git a/Tranga/LibraryConnectors/Kavita.cs b/Tranga/LibraryConnectors/Kavita.cs index 9ac2269..a42f691 100644 --- a/Tranga/LibraryConnectors/Kavita.cs +++ b/Tranga/LibraryConnectors/Kavita.cs @@ -17,6 +17,11 @@ public class Kavita : LibraryConnector { } + public override string ToString() + { + return $"Kavita {baseUrl}"; + } + private static string GetToken(string baseUrl, string username, string password) { HttpClient client = new() diff --git a/Tranga/LibraryConnectors/Komga.cs b/Tranga/LibraryConnectors/Komga.cs index cc3f4d1..7a0c485 100644 --- a/Tranga/LibraryConnectors/Komga.cs +++ b/Tranga/LibraryConnectors/Komga.cs @@ -20,6 +20,11 @@ public class Komga : LibraryConnector { } + public override string ToString() + { + return $"Komga {baseUrl}"; + } + public override void UpdateLibrary() { Log("Updating libraries."); diff --git a/Tranga/NotificationConnectors/Gotify.cs b/Tranga/NotificationConnectors/Gotify.cs index 1cdcc8e..53996a5 100644 --- a/Tranga/NotificationConnectors/Gotify.cs +++ b/Tranga/NotificationConnectors/Gotify.cs @@ -16,7 +16,12 @@ public class Gotify : NotificationConnector this.endpoint = endpoint; this.appToken = appToken; } - + + public override string ToString() + { + return $"Gotify {endpoint}"; + } + public override void SendNotification(string title, string notificationText) { Log($"Sending notification: {title} - {notificationText}"); diff --git a/Tranga/NotificationConnectors/LunaSea.cs b/Tranga/NotificationConnectors/LunaSea.cs index 65a5097..e6be280 100644 --- a/Tranga/NotificationConnectors/LunaSea.cs +++ b/Tranga/NotificationConnectors/LunaSea.cs @@ -15,6 +15,11 @@ public class LunaSea : NotificationConnector this.id = id; } + public override string ToString() + { + return $"LunaSea {id}"; + } + public override void SendNotification(string title, string notificationText) { Log($"Sending notification: {title} - {notificationText}"); diff --git a/Tranga/Publication.cs b/Tranga/Publication.cs index 05eb213..aceaee5 100644 --- a/Tranga/Publication.cs +++ b/Tranga/Publication.cs @@ -58,6 +58,11 @@ public struct Publication this.ignoreChaptersBelow = ignoreChaptersBelow ?? 0f; } + public override string ToString() + { + return $"Publication {sortName} {internalId}"; + } + public string CreatePublicationFolder(string downloadDirectory) { string publicationFolder = Path.Join(downloadDirectory, this.folderName);