From 1afa3df3160ccdcb8761652ac45695cf131a1cde Mon Sep 17 00:00:00 2001 From: glax Date: Sun, 30 Jul 2023 17:25:04 +0200 Subject: [PATCH] Cleanup build warnings, ReShaper, Dictionary --- Tranga.sln.DotSettings | 3 ++ Tranga/Chapter.cs | 2 ++ Tranga/Connectors/Connector.cs | 3 +- Tranga/Connectors/MangaKatana.cs | 26 +++++++++-------- Tranga/Connectors/Manganato.cs | 15 +++++----- Tranga/Connectors/Mangasee.cs | 30 ++++++++++++-------- Tranga/DownloadClient.cs | 8 +++--- Tranga/LibraryManagers/Kavita.cs | 5 ++-- Tranga/LibraryManagers/Komga.cs | 3 +- Tranga/LibraryManagers/LibraryManager.cs | 3 +- Tranga/Migrate.cs | 3 +- Tranga/NotificationManagers/Gotify.cs | 3 ++ Tranga/NotificationManagers/LunaSea.cs | 6 +++- Tranga/Publication.cs | 9 ++++-- Tranga/TaskManager.cs | 7 ++--- Tranga/TrangaTasks/DownloadChapterTask.cs | 5 ++-- Tranga/TrangaTasks/MonitorPublicationTask.cs | 3 +- Tranga/TrangaTasks/TrangaTask.cs | 7 +++-- Tranga/TrangaTasks/UpdateLibrariesTask.cs | 1 - 19 files changed, 84 insertions(+), 58 deletions(-) diff --git a/Tranga.sln.DotSettings b/Tranga.sln.DotSettings index 37bbfaf..7f9a86f 100644 --- a/Tranga.sln.DotSettings +++ b/Tranga.sln.DotSettings @@ -1,6 +1,9 @@  + True + True True True + True True True True diff --git a/Tranga/Chapter.cs b/Tranga/Chapter.cs index cf1e2bc..0559f40 100644 --- a/Tranga/Chapter.cs +++ b/Tranga/Chapter.cs @@ -9,11 +9,13 @@ namespace Tranga; /// public readonly struct Chapter { + // ReSharper disable once MemberCanBePrivate.Global public Publication parentPublication { get; } public string? name { get; } public string? volumeNumber { get; } public string chapterNumber { get; } public string url { get; } + // ReSharper disable once MemberCanBePrivate.Global public string fileName { get; } private static readonly Regex LegalCharacters = new (@"([A-z]*[0-9]* *\.*-*,*\]*\[*'*\'*\)*\(*~*!*)*"); diff --git a/Tranga/Connectors/Connector.cs b/Tranga/Connectors/Connector.cs index f048133..9233409 100644 --- a/Tranga/Connectors/Connector.cs +++ b/Tranga/Connectors/Connector.cs @@ -159,8 +159,7 @@ public abstract class Connector /// Copies the already downloaded cover from cache to downloadLocation /// /// Publication to retrieve Cover for - /// TrangaSettings - public void CopyCoverFromCacheToDownloadLocation(Publication publication, TrangaSettings settings) + public void CopyCoverFromCacheToDownloadLocation(Publication publication) { settings.logger?.WriteLine(this.GetType().ToString(), $"Cloning cover {publication.sortName} -> {publication.internalId}"); //Check if Publication already has a Folder and cover diff --git a/Tranga/Connectors/MangaKatana.cs b/Tranga/Connectors/MangaKatana.cs index ffb6a84..93a0441 100644 --- a/Tranga/Connectors/MangaKatana.cs +++ b/Tranga/Connectors/MangaKatana.cs @@ -15,7 +15,7 @@ public class MangaKatana : Connector this.name = "MangaKatana"; this.downloadClient = new DownloadClient(new Dictionary() { - {(byte)1, 60} + {1, 60} }, settings.logger); } @@ -25,16 +25,17 @@ public class MangaKatana : Connector string sanitizedTitle = string.Concat(Regex.Matches(publicationTitle, "[A-z]* *")).ToLower().Replace(' ', '_'); string requestUrl = $"https://mangakatana.com/?search={sanitizedTitle}&search_by=book_name"; DownloadClient.RequestResult requestResult = - downloadClient.MakeRequest(requestUrl, (byte)1); + downloadClient.MakeRequest(requestUrl, 1); if ((int)requestResult.statusCode < 200 || (int)requestResult.statusCode >= 300) return Array.Empty(); + // ReSharper disable once MergeIntoPattern // If a single result is found, the user will be redirected to the results directly instead of a result page - if(requestResult.HasBeenRedirected - && requestResult.RedirectedToUrl is not null - && requestResult.RedirectedToUrl.Contains("mangakatana.com/manga")) + if(requestResult.hasBeenRedirected + && requestResult.redirectedToUrl is not null + && requestResult.redirectedToUrl.Contains("mangakatana.com/manga")) { - return new Publication[] { ParseSinglePublicationFromHtml(requestResult.result, requestResult.RedirectedToUrl.Split('/')[^1]) }; + return new [] { ParseSinglePublicationFromHtml(requestResult.result, requestResult.redirectedToUrl.Split('/')[^1]) }; } return ParsePublicationsFromHtml(requestResult.result); @@ -58,7 +59,7 @@ public class MangaKatana : Connector foreach (string url in urls) { DownloadClient.RequestResult requestResult = - downloadClient.MakeRequest(url, (byte)1); + downloadClient.MakeRequest(url, 1); if ((int)requestResult.statusCode < 200 || (int)requestResult.statusCode >= 300) return Array.Empty(); @@ -107,7 +108,6 @@ public class MangaKatana : Connector case "genres": tags = row.SelectNodes("div").Last().Descendants("a").Select(a => a.InnerText).ToHashSet(); break; - default: break; } } @@ -139,7 +139,7 @@ public class MangaKatana : Connector string requestUrl = $"https://mangakatana.com/manga/{publication.publicationId}"; // Leaving this in for verification if the page exists DownloadClient.RequestResult requestResult = - downloadClient.MakeRequest(requestUrl, (byte)1); + downloadClient.MakeRequest(requestUrl, 1); if ((int)requestResult.statusCode < 200 || (int)requestResult.statusCode >= 300) return Array.Empty(); @@ -168,7 +168,7 @@ public class MangaKatana : Connector string fullString = chapterInfo.Descendants("a").First().InnerText; string? volumeNumber = fullString.Contains("Vol.") ? fullString.Replace("Vol.", "").Split(' ')[0] : null; - string? chapterNumber = fullString.Split(':')[0].Split("Chapter ")[1].Split(" ")[0].Replace('-', '.'); + string chapterNumber = fullString.Split(':')[0].Split("Chapter ")[1].Split(" ")[0].Replace('-', '.'); string chapterName = string.Concat(fullString.Split(':')[1..]); string url = chapterInfo.Descendants("a").First() .GetAttributeValue("href", ""); @@ -186,7 +186,7 @@ public class MangaKatana : Connector string requestUrl = chapter.url; // Leaving this in to check if the page exists DownloadClient.RequestResult requestResult = - downloadClient.MakeRequest(requestUrl, (byte)1); + downloadClient.MakeRequest(requestUrl, 1); if ((int)requestResult.statusCode < 200 || (int)requestResult.statusCode >= 300) return requestResult.statusCode; @@ -195,7 +195,7 @@ public class MangaKatana : Connector string comicInfoPath = Path.GetTempFileName(); File.WriteAllText(comicInfoPath, chapter.GetComicInfoXmlString()); - return DownloadChapterImages(imageUrls, chapter.GetArchiveFilePath(settings.downloadLocation), (byte)1, parentTask, comicInfoPath, "https://mangakatana.com/", cancellationToken); + return DownloadChapterImages(imageUrls, chapter.GetArchiveFilePath(settings.downloadLocation), 1, parentTask, comicInfoPath, "https://mangakatana.com/", cancellationToken); } private string[] ParseImageUrlsFromHtml(string mangaUrl) @@ -208,6 +208,8 @@ public class MangaKatana : Connector .Replace("\r", "") .Replace("\n", "") .Replace("\t", ""); + + // ReSharper disable once StringLiteralTypo string regexPat = @"(var thzq=\[')(.*)(,];function)"; var group = Regex.Matches(js, regexPat).First().Groups[2].Value.Replace("'", ""); var urls = group.Split(','); diff --git a/Tranga/Connectors/Manganato.cs b/Tranga/Connectors/Manganato.cs index cc050bb..19baee7 100644 --- a/Tranga/Connectors/Manganato.cs +++ b/Tranga/Connectors/Manganato.cs @@ -15,7 +15,7 @@ public class Manganato : Connector this.name = "Manganato"; this.downloadClient = new DownloadClient(new Dictionary() { - {(byte)1, 60} + {1, 60} }, settings.logger); } @@ -25,7 +25,7 @@ public class Manganato : Connector string sanitizedTitle = string.Join('_', Regex.Matches(publicationTitle, "[A-z]*")).ToLower(); string requestUrl = $"https://manganato.com/search/story/{sanitizedTitle}"; DownloadClient.RequestResult requestResult = - downloadClient.MakeRequest(requestUrl, (byte)1); + downloadClient.MakeRequest(requestUrl, 1); if ((int)requestResult.statusCode < 200 || (int)requestResult.statusCode >= 300) return Array.Empty(); @@ -50,7 +50,7 @@ public class Manganato : Connector foreach (string url in urls) { DownloadClient.RequestResult requestResult = - downloadClient.MakeRequest(url, (byte)1); + downloadClient.MakeRequest(url, 1); if ((int)requestResult.statusCode < 200 || (int)requestResult.statusCode >= 300) return Array.Empty(); @@ -102,7 +102,6 @@ public class Manganato : Connector string[] genres = value.Split(" - "); tags = genres.ToHashSet(); break; - default: break; } } @@ -129,7 +128,7 @@ public class Manganato : Connector settings.logger?.WriteLine(this.GetType().ToString(), $"Getting Chapters for {publication.sortName} {publication.internalId} (language={language})"); string requestUrl = $"https://chapmanganato.com/{publication.publicationId}"; DownloadClient.RequestResult requestResult = - downloadClient.MakeRequest(requestUrl, (byte)1); + downloadClient.MakeRequest(requestUrl, 1); if ((int)requestResult.statusCode < 200 || (int)requestResult.statusCode >= 300) return Array.Empty(); @@ -158,7 +157,7 @@ public class Manganato : Connector string fullString = chapterInfo.Descendants("a").First(d => d.HasClass("chapter-name")).InnerText; string? volumeNumber = fullString.Contains("Vol.") ? fullString.Replace("Vol.", "").Split(' ')[0] : null; - string? chapterNumber = fullString.Split(':')[0].Split("Chapter ")[1].Replace('-','.'); + string chapterNumber = fullString.Split(':')[0].Split("Chapter ")[1].Replace('-','.'); string chapterName = string.Concat(fullString.Split(':')[1..]); string url = chapterInfo.Descendants("a").First(d => d.HasClass("chapter-name")) .GetAttributeValue("href", ""); @@ -175,7 +174,7 @@ public class Manganato : Connector settings.logger?.WriteLine(this.GetType().ToString(), $"Downloading Chapter-Info {publication.sortName} {publication.internalId} {chapter.volumeNumber}-{chapter.chapterNumber}"); string requestUrl = chapter.url; DownloadClient.RequestResult requestResult = - downloadClient.MakeRequest(requestUrl, (byte)1); + downloadClient.MakeRequest(requestUrl, 1); if ((int)requestResult.statusCode < 200 || (int)requestResult.statusCode >= 300) return requestResult.statusCode; @@ -184,7 +183,7 @@ public class Manganato : Connector string comicInfoPath = Path.GetTempFileName(); File.WriteAllText(comicInfoPath, chapter.GetComicInfoXmlString()); - return DownloadChapterImages(imageUrls, chapter.GetArchiveFilePath(settings.downloadLocation), (byte)1, parentTask, comicInfoPath, "https://chapmanganato.com/", cancellationToken); + return DownloadChapterImages(imageUrls, chapter.GetArchiveFilePath(settings.downloadLocation), 1, parentTask, comicInfoPath, "https://chapmanganato.com/", cancellationToken); } private string[] ParseImageUrlsFromHtml(Stream html) diff --git a/Tranga/Connectors/Mangasee.cs b/Tranga/Connectors/Mangasee.cs index 3bc6cb9..c82dd7b 100644 --- a/Tranga/Connectors/Mangasee.cs +++ b/Tranga/Connectors/Mangasee.cs @@ -12,7 +12,7 @@ namespace Tranga.Connectors; public class Mangasee : Connector { public override string name { get; } - private IBrowser? _browser = null; + private IBrowser? _browser; private const string ChromiumVersion = "1154303"; public Mangasee(TrangaSettings settings) : base(settings) @@ -20,7 +20,7 @@ public class Mangasee : Connector this.name = "Mangasee"; this.downloadClient = new DownloadClient(new Dictionary() { - { (byte)1, 60 } + { 1, 60 } }, settings.logger); Task d = new Task(DownloadBrowser); @@ -36,7 +36,7 @@ public class Mangasee : Connector { settings.logger?.WriteLine(this.GetType().ToString(), "Downloading headless browser"); DateTime last = DateTime.Now.Subtract(TimeSpan.FromSeconds(5)); - browserFetcher.DownloadProgressChanged += (sender, args) => + browserFetcher.DownloadProgressChanged += (_, args) => { double currentBytes = Convert.ToDouble(args.BytesReceived) / Convert.ToDouble(args.TotalBytesToReceive); if (args.TotalBytesToReceive == args.BytesReceived) @@ -76,7 +76,7 @@ public class Mangasee : Connector settings.logger?.WriteLine(this.GetType().ToString(), $"Getting Publications (title={publicationTitle})"); string requestUrl = $"https://mangasee123.com/_search.php"; DownloadClient.RequestResult requestResult = - downloadClient.MakeRequest(requestUrl, (byte)1); + downloadClient.MakeRequest(requestUrl, 1); if ((int)requestResult.statusCode < 200 || (int)requestResult.statusCode >= 300) return Array.Empty(); @@ -108,7 +108,7 @@ public class Mangasee : Connector foreach (SearchResultItem orderedItem in orderedFiltered) { DownloadClient.RequestResult requestResult = - downloadClient.MakeRequest($"https://mangasee123.com/manga/{orderedItem.i}", (byte)1); + downloadClient.MakeRequest($"https://mangasee123.com/manga/{orderedItem.i}", 1); if ((int)requestResult.statusCode >= 200 || (int)requestResult.statusCode < 300) { settings.logger?.WriteLine(this.GetType().ToString(), $"Retrieving Publication info: {orderedItem.s} {index++}/{orderedFiltered.Count}"); @@ -177,11 +177,17 @@ public class Mangasee : Connector // ReSharper disable once ClassNeverInstantiated.Local Will be instantiated during deserialization private class SearchResultItem { -#pragma warning disable CS8618 //Will always be set - public string i { get; set; } - public string s { get; set; } - public string[] a { get; set; } -#pragma warning restore CS8618 + public string i { get; init; } + public string s { get; init; } + public string[] a { get; init; } + + [JsonConstructor] + public SearchResultItem(string i, string s, string[] a) + { + this.i = i; + this.s = s; + this.a = a; + } public int GetMatches(string title) { @@ -215,7 +221,7 @@ public class Mangasee : Connector List ret = new(); foreach (XElement chapter in chapterItems) { - string? volumeNumber = "1"; + string volumeNumber = "1"; string chapterName = chapter.Descendants("title").First().Value; string chapterNumber = Regex.Matches(chapterName, "[0-9]+")[^1].ToString(); @@ -262,7 +268,7 @@ public class Mangasee : Connector string comicInfoPath = Path.GetTempFileName(); File.WriteAllText(comicInfoPath, chapter.GetComicInfoXmlString()); - return DownloadChapterImages(urls.ToArray(), chapter.GetArchiveFilePath(settings.downloadLocation), (byte)1, parentTask, comicInfoPath, cancellationToken:cancellationToken); + return DownloadChapterImages(urls.ToArray(), chapter.GetArchiveFilePath(settings.downloadLocation), 1, parentTask, comicInfoPath, cancellationToken:cancellationToken); } return response.Status; } diff --git a/Tranga/DownloadClient.cs b/Tranga/DownloadClient.cs index 585b15a..2951598 100644 --- a/Tranga/DownloadClient.cs +++ b/Tranga/DownloadClient.cs @@ -89,8 +89,8 @@ internal class DownloadClient { public HttpStatusCode statusCode { get; } public Stream result { get; } - public bool HasBeenRedirected { get; } - public string? RedirectedToUrl { get; } + public bool hasBeenRedirected { get; } + public string? redirectedToUrl { get; } public RequestResult(HttpStatusCode statusCode, Stream result) { @@ -101,8 +101,8 @@ internal class DownloadClient public RequestResult(HttpStatusCode statusCode, Stream result, bool hasBeenRedirected, string redirectedTo) : this(statusCode, result) { - this.HasBeenRedirected = hasBeenRedirected; - RedirectedToUrl = redirectedTo; + this.hasBeenRedirected = hasBeenRedirected; + redirectedToUrl = redirectedTo; } } } \ No newline at end of file diff --git a/Tranga/LibraryManagers/Kavita.cs b/Tranga/LibraryManagers/Kavita.cs index 9abc66d..04cbe67 100644 --- a/Tranga/LibraryManagers/Kavita.cs +++ b/Tranga/LibraryManagers/Kavita.cs @@ -36,7 +36,7 @@ public class Kavita : LibraryManager HttpResponseMessage response = client.Send(requestMessage); JsonObject? result = JsonSerializer.Deserialize(response.Content.ReadAsStream()); if (result is not null) - return result!["token"]!.GetValue(); + return result["token"]!.GetValue(); else return ""; } @@ -73,7 +73,7 @@ public class Kavita : LibraryManager { var jObject = (JsonObject?)jsonNode; int libraryId = jObject!["id"]!.GetValue(); - string libraryName = jObject!["name"]!.GetValue(); + string libraryName = jObject["name"]!.GetValue(); ret.Add(new KavitaLibrary(libraryId, libraryName)); } @@ -83,6 +83,7 @@ public class Kavita : LibraryManager private struct KavitaLibrary { public int id { get; } + // ReSharper disable once UnusedAutoPropertyAccessor.Local public string name { get; } public KavitaLibrary(int id, string name) diff --git a/Tranga/LibraryManagers/Komga.cs b/Tranga/LibraryManagers/Komga.cs index bacc2c6..545ec91 100644 --- a/Tranga/LibraryManagers/Komga.cs +++ b/Tranga/LibraryManagers/Komga.cs @@ -54,7 +54,7 @@ public class Komga : LibraryManager { var jObject = (JsonObject?)jsonNode; string libraryId = jObject!["id"]!.GetValue(); - string libraryName = jObject!["name"]!.GetValue(); + string libraryName = jObject["name"]!.GetValue(); ret.Add(new KomgaLibrary(libraryId, libraryName)); } @@ -64,6 +64,7 @@ public class Komga : LibraryManager private struct KomgaLibrary { public string id { get; } + // ReSharper disable once UnusedAutoPropertyAccessor.Local public string name { get; } public KomgaLibrary(string id, string name) diff --git a/Tranga/LibraryManagers/LibraryManager.cs b/Tranga/LibraryManagers/LibraryManager.cs index c2ead5f..88e7b98 100644 --- a/Tranga/LibraryManagers/LibraryManager.cs +++ b/Tranga/LibraryManagers/LibraryManager.cs @@ -3,7 +3,6 @@ using System.Net.Http.Headers; using Logging; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using Tranga.LibraryManagers; namespace Tranga.LibraryManagers; @@ -15,8 +14,10 @@ public abstract class LibraryManager Kavita = 1 } + // ReSharper disable once UnusedAutoPropertyAccessor.Global public LibraryType libraryType { get; } public string baseUrl { get; } + // ReSharper disable once MemberCanBeProtected.Global public string auth { get; } //Base64 encoded, if you use your password everywhere, you have problems protected Logger? logger; diff --git a/Tranga/Migrate.cs b/Tranga/Migrate.cs index 4db6f5c..02b4988 100644 --- a/Tranga/Migrate.cs +++ b/Tranga/Migrate.cs @@ -1,5 +1,4 @@ -using Logging; -using Newtonsoft.Json; +using Newtonsoft.Json; using Tranga.TrangaTasks; namespace Tranga; diff --git a/Tranga/NotificationManagers/Gotify.cs b/Tranga/NotificationManagers/Gotify.cs index 8dce233..a823665 100644 --- a/Tranga/NotificationManagers/Gotify.cs +++ b/Tranga/NotificationManagers/Gotify.cs @@ -7,9 +7,11 @@ namespace Tranga.NotificationManagers; public class Gotify : NotificationManager { public string endpoint { get; } + // ReSharper disable once MemberCanBePrivate.Global public string appToken { get; } private readonly HttpClient _client = new(); + [JsonConstructor] public Gotify(string endpoint, string appToken, Logger? logger = null) : base(NotificationManagerType.Gotify, logger) { this.endpoint = endpoint; @@ -33,6 +35,7 @@ public class Gotify : NotificationManager private class MessageData { + // ReSharper disable four times UnusedAutoPropertyAccessor.Local public string message { get; } public long priority { get; } public string title { get; } diff --git a/Tranga/NotificationManagers/LunaSea.cs b/Tranga/NotificationManagers/LunaSea.cs index 363bddf..aef14c5 100644 --- a/Tranga/NotificationManagers/LunaSea.cs +++ b/Tranga/NotificationManagers/LunaSea.cs @@ -6,8 +6,11 @@ namespace Tranga.NotificationManagers; public class LunaSea : NotificationManager { - public string id { get; } + // ReSharper disable once MemberCanBePrivate.Global + public string id { get; init; } private readonly HttpClient _client = new(); + + [JsonConstructor] public LunaSea(string id, Logger? logger = null) : base(NotificationManagerType.LunaSea, logger) { this.id = id; @@ -29,6 +32,7 @@ public class LunaSea : NotificationManager private class MessageData { + // ReSharper disable twice UnusedAutoPropertyAccessor.Local public string title { get; } public string body { get; } diff --git a/Tranga/Publication.cs b/Tranga/Publication.cs index c72e605..330e7c0 100644 --- a/Tranga/Publication.cs +++ b/Tranga/Publication.cs @@ -13,15 +13,20 @@ public struct Publication { public string sortName { get; } public List authors { get; } + // ReSharper disable once UnusedAutoPropertyAccessor.Global public Dictionary altTitles { get; } - // ReSharper disable trice MemberCanBePrivate.Global, trust + // ReSharper disable once MemberCanBePrivate.Global public string? description { get; } public string[] tags { get; } + // ReSharper disable once UnusedAutoPropertyAccessor.Global public string? posterUrl { get; } public string? coverFileNameInCache { get; } + // ReSharper disable once UnusedAutoPropertyAccessor.Global public Dictionary links { get; } + // ReSharper disable once MemberCanBePrivate.Global public int? year { get; } public string? originalLanguage { get; } + // ReSharper disable once MemberCanBePrivate.Global public string status { get; } public string folderName { get; } public string publicationId { get; } @@ -74,7 +79,7 @@ public struct Publication } /// Serialized JSON String for series.json - public string GetSeriesInfoJson() + private string GetSeriesInfoJson() { SeriesInfo si = new (new Metadata(this.sortName, this.year.ToString() ?? string.Empty, this.status, this.description ?? "")); return System.Text.Json.JsonSerializer.Serialize(si); diff --git a/Tranga/TaskManager.cs b/Tranga/TaskManager.cs index f3f4076..11c12d5 100644 --- a/Tranga/TaskManager.cs +++ b/Tranga/TaskManager.cs @@ -1,5 +1,4 @@ -using Logging; -using Newtonsoft.Json; +using Newtonsoft.Json; using Tranga.Connectors; using Tranga.TrangaTasks; @@ -182,6 +181,7 @@ public class TaskManager ExportDataAndSettings(); } + // ReSharper disable once MemberCanBePrivate.Global public IEnumerable GetTasksMatching(TrangaTask mTask) { switch (mTask.task) @@ -336,11 +336,10 @@ public class TaskManager private void ImportData() { settings.logger?.WriteLine(this.GetType().ToString(), "Importing Data"); - string buffer; if (File.Exists(settings.tasksFilePath)) { settings.logger?.WriteLine(this.GetType().ToString(), $"Importing tasks from {settings.tasksFilePath}"); - buffer = File.ReadAllText(settings.tasksFilePath); + string buffer = File.ReadAllText(settings.tasksFilePath); this._allTasks = JsonConvert.DeserializeObject>(buffer, new JsonSerializerSettings() { Converters = { new TrangaTask.TrangaTaskJsonConverter() } })!; } diff --git a/Tranga/TrangaTasks/DownloadChapterTask.cs b/Tranga/TrangaTasks/DownloadChapterTask.cs index 1546621..a70e350 100644 --- a/Tranga/TrangaTasks/DownloadChapterTask.cs +++ b/Tranga/TrangaTasks/DownloadChapterTask.cs @@ -9,10 +9,11 @@ public class DownloadChapterTask : TrangaTask { public string connectorName { get; } public Publication publication { get; } + // ReSharper disable once MemberCanBePrivate.Global public string language { get; } public Chapter chapter { get; } - private double _dctProgress = 0; + private double _dctProgress; public DownloadChapterTask(string connectorName, Publication publication, Chapter chapter, string language = "en", MonitorPublicationTask? parentTask = null) : base(Task.DownloadChapter, TimeSpan.Zero, parentTask) { @@ -27,7 +28,7 @@ public class DownloadChapterTask : TrangaTask if (cancellationToken?.IsCancellationRequested ?? false) return HttpStatusCode.RequestTimeout; Connector connector = taskManager.GetConnector(this.connectorName); - connector.CopyCoverFromCacheToDownloadLocation(this.publication, taskManager.settings); + connector.CopyCoverFromCacheToDownloadLocation(this.publication); HttpStatusCode downloadSuccess = connector.DownloadChapter(this.publication, this.chapter, this, cancellationToken); if ((int)downloadSuccess >= 200 && (int)downloadSuccess < 300) { diff --git a/Tranga/TrangaTasks/MonitorPublicationTask.cs b/Tranga/TrangaTasks/MonitorPublicationTask.cs index 5173ee6..5319759 100644 --- a/Tranga/TrangaTasks/MonitorPublicationTask.cs +++ b/Tranga/TrangaTasks/MonitorPublicationTask.cs @@ -7,6 +7,7 @@ public class MonitorPublicationTask : TrangaTask { public string connectorName { get; } public Publication publication { get; } + // ReSharper disable once MemberCanBePrivate.Global public string language { get; } public MonitorPublicationTask(string connectorName, Publication publication, TimeSpan reoccurrence, string language = "en") : base(Task.MonitorPublication, reoccurrence) { @@ -25,7 +26,7 @@ public class MonitorPublicationTask : TrangaTask publication.CreatePublicationFolder(taskManager.settings.downloadLocation); List newChapters = connector.GetNewChaptersList(publication, language, ref taskManager.collection); - connector.CopyCoverFromCacheToDownloadLocation(publication, taskManager.settings); + connector.CopyCoverFromCacheToDownloadLocation(publication); publication.SaveSeriesInfoJson(taskManager.settings.downloadLocation); diff --git a/Tranga/TrangaTasks/TrangaTask.cs b/Tranga/TrangaTasks/TrangaTask.cs index d867faa..b3e4e60 100644 --- a/Tranga/TrangaTasks/TrangaTask.cs +++ b/Tranga/TrangaTasks/TrangaTask.cs @@ -1,6 +1,5 @@ using System.Net; using System.Text.Json.Serialization; -using Logging; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using JsonConverter = Newtonsoft.Json.JsonConverter; @@ -15,8 +14,7 @@ namespace Tranga.TrangaTasks; [JsonDerivedType(typeof(DownloadChapterTask), 4)] public abstract class TrangaTask { - // ReSharper disable once CommentTypo ...Tell me why! - // ReSharper disable once MemberCanBePrivate.Global I want it thaaat way + // ReSharper disable once MemberCanBeProtected.Global public TimeSpan reoccurrence { get; } public DateTime lastExecuted { get; set; } [Newtonsoft.Json.JsonIgnore] public ExecutionState state { get; set; } @@ -26,9 +24,12 @@ public abstract class TrangaTask public string? parentTaskId { get; set; } [Newtonsoft.Json.JsonIgnore] internal HashSet childTasks { get; } public double progress => GetProgress(); + // ReSharper disable once MemberCanBePrivate.Global [Newtonsoft.Json.JsonIgnore]public DateTime executionStarted { get; private set; } [Newtonsoft.Json.JsonIgnore]public DateTime lastChange { get; internal set; } + // ReSharper disable once MemberCanBePrivate.Global [Newtonsoft.Json.JsonIgnore]public DateTime executionApproximatelyFinished => lastChange.Add(GetRemainingTime()); + // ReSharper disable once MemberCanBePrivate.Global public TimeSpan executionApproximatelyRemaining => executionApproximatelyFinished.Subtract(DateTime.Now); [Newtonsoft.Json.JsonIgnore]public DateTime nextExecution => lastExecuted.Add(reoccurrence); diff --git a/Tranga/TrangaTasks/UpdateLibrariesTask.cs b/Tranga/TrangaTasks/UpdateLibrariesTask.cs index 1039a9c..e7ecb02 100644 --- a/Tranga/TrangaTasks/UpdateLibrariesTask.cs +++ b/Tranga/TrangaTasks/UpdateLibrariesTask.cs @@ -1,5 +1,4 @@ using System.Net; -using Logging; namespace Tranga.TrangaTasks;