From 2be29e4019fe4af729c915dc3d8390a06b11bb13 Mon Sep 17 00:00:00 2001 From: Glax Date: Sat, 7 Sep 2024 20:16:05 +0200 Subject: [PATCH 01/18] MangaDex only download single release for chapter. Fix #219 --- Tranga/MangaConnectors/MangaDex.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tranga/MangaConnectors/MangaDex.cs b/Tranga/MangaConnectors/MangaDex.cs index 005da07..cbb8ffb 100644 --- a/Tranga/MangaConnectors/MangaDex.cs +++ b/Tranga/MangaConnectors/MangaDex.cs @@ -243,7 +243,7 @@ public class MangaDex : MangaConnector continue; } - if(chapterNum is not "null") + if(chapterNum is not "null" && !chapters.Any(chp => chp.volumeNumber.Equals(volume) && chp.chapterNumber.Equals(chapterNum))) chapters.Add(new Chapter(manga, title, volume, chapterNum, chapterId)); } } From 15f3e2b8ec3267af20d43ff31f00e810deda684d Mon Sep 17 00:00:00 2001 From: Glax Date: Sat, 7 Sep 2024 20:33:03 +0200 Subject: [PATCH 02/18] Use current time as internalId for Manga instead of BASE64 string of title #232 Fix #237 --- Tranga/Manga.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tranga/Manga.cs b/Tranga/Manga.cs index 5ebad19..6b48c5d 100644 --- a/Tranga/Manga.cs +++ b/Tranga/Manga.cs @@ -67,7 +67,7 @@ public struct Manga 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.internalId = DateTime.Now.Ticks.ToString(); this.ignoreChaptersBelow = ignoreChaptersBelow ?? 0f; this.latestChapterDownloaded = 0; this.latestChapterAvailable = 0; From 9b8b80cd2462ff0979c9405f1811c461a57f899f Mon Sep 17 00:00:00 2001 From: Glax Date: Sat, 7 Sep 2024 20:36:00 +0200 Subject: [PATCH 03/18] Fix response closed on OPTIONS request --- Tranga/Server.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Tranga/Server.cs b/Tranga/Server.cs index 4e387f1..dbf80a5 100644 --- a/Tranga/Server.cs +++ b/Tranga/Server.cs @@ -63,10 +63,11 @@ public class Server : GlobalBase { HttpListenerRequest request = context.Request; HttpListenerResponse response = context.Response; - if(request.HttpMethod == "OPTIONS") - SendResponse(HttpStatusCode.OK, context.Response); - if(request.Url!.LocalPath.Contains("favicon")) + if (request.Url!.LocalPath.Contains("favicon")) + { SendResponse(HttpStatusCode.NoContent, response); + return; + } switch (request.HttpMethod) { @@ -79,7 +80,10 @@ public class Server : GlobalBase case "DELETE": HandleDelete(request, response); break; - default: + case "OPTIONS": + SendResponse(HttpStatusCode.OK, context.Response); + break; + default: SendResponse(HttpStatusCode.BadRequest, response); break; } @@ -707,14 +711,15 @@ public class Server : GlobalBase private void SendResponse(HttpStatusCode statusCode, HttpListenerResponse response, object? content = null) { //Log($"Response: {statusCode} {content}"); + response.StatusCode = (int)statusCode; response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With"); response.AddHeader("Access-Control-Allow-Methods", "GET, POST, DELETE"); response.AddHeader("Access-Control-Max-Age", "1728000"); response.AppendHeader("Access-Control-Allow-Origin", "*"); - try { + if (content is not Stream) { response.ContentType = "application/json"; @@ -750,7 +755,7 @@ public class Server : GlobalBase stream.Close(); } } - catch (HttpListenerException e) + catch (Exception e) { Log(e.ToString()); } From cbecb257ef23a20e35458a6887fcec876d0c5aad Mon Sep 17 00:00:00 2001 From: Glax Date: Wed, 11 Sep 2024 14:39:16 +0200 Subject: [PATCH 04/18] Remove unused constant --- Tranga/MangaConnectors/ChromiumDownloadClient.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Tranga/MangaConnectors/ChromiumDownloadClient.cs b/Tranga/MangaConnectors/ChromiumDownloadClient.cs index 9042812..efe7f53 100644 --- a/Tranga/MangaConnectors/ChromiumDownloadClient.cs +++ b/Tranga/MangaConnectors/ChromiumDownloadClient.cs @@ -9,7 +9,6 @@ namespace Tranga.MangaConnectors; internal class ChromiumDownloadClient : DownloadClient { private IBrowser browser { get; set; } - private const string ChromiumVersion = "1154303"; private const int StartTimeoutMs = 30000; private readonly HttpDownloadClient _httpDownloadClient; From 5980b64caa91d5f80ada71e00064df54e47e5adb Mon Sep 17 00:00:00 2001 From: Glax Date: Wed, 11 Sep 2024 14:40:03 +0200 Subject: [PATCH 05/18] Readable Chapter comparison --- Tranga/Chapter.cs | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/Tranga/Chapter.cs b/Tranga/Chapter.cs index 369b8fc..2dbf346 100644 --- a/Tranga/Chapter.cs +++ b/Tranga/Chapter.cs @@ -58,29 +58,24 @@ public readonly struct Chapter : IComparable public int CompareTo(object? obj) { - if (obj is Chapter otherChapter) + if(obj is not Chapter otherChapter) + throw new ArgumentException($"{obj} can not be compared to {this}"); + + if (float.TryParse(volumeNumber, GlobalBase.numberFormatDecimalPoint, out float volumeNumberFloat) && + float.TryParse(chapterNumber, GlobalBase.numberFormatDecimalPoint, out float chapterNumberFloat) && + float.TryParse(otherChapter.volumeNumber, GlobalBase.numberFormatDecimalPoint, + out float otherVolumeNumberFloat) && + float.TryParse(otherChapter.chapterNumber, GlobalBase.numberFormatDecimalPoint, + out float otherChapterNumberFloat)) { - if (float.TryParse(volumeNumber, GlobalBase.numberFormatDecimalPoint, out float volumeNumberFloat) && - float.TryParse(chapterNumber, GlobalBase.numberFormatDecimalPoint, out float chapterNumberFloat) && - float.TryParse(otherChapter.volumeNumber, GlobalBase.numberFormatDecimalPoint, - out float otherVolumeNumberFloat) && - float.TryParse(otherChapter.chapterNumber, GlobalBase.numberFormatDecimalPoint, - out float otherChapterNumberFloat)) + return volumeNumberFloat.CompareTo(otherVolumeNumberFloat) switch { - - switch (volumeNumberFloat.CompareTo(otherVolumeNumberFloat)) - { - case < 0: - return -1; - case > 0: - return 1; - default: - return chapterNumberFloat.CompareTo(otherChapterNumberFloat); - } - } - else throw new FormatException($"Value could not be parsed"); + <0 => -1, + >0 => 1, + _ => chapterNumberFloat.CompareTo(otherChapterNumberFloat) + }; } - throw new ArgumentException($"{obj} can not be compared to {this}"); + else throw new FormatException($"Value could not be parsed"); } /// From 7d3deee74c95487f86a2d6d14a0de43fb700c183 Mon Sep 17 00:00:00 2001 From: Glax Date: Wed, 11 Sep 2024 14:40:28 +0200 Subject: [PATCH 06/18] Remove unused constant --- Tranga/MangaConnectors/ChromiumDownloadClient.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Tranga/MangaConnectors/ChromiumDownloadClient.cs b/Tranga/MangaConnectors/ChromiumDownloadClient.cs index 9042812..efe7f53 100644 --- a/Tranga/MangaConnectors/ChromiumDownloadClient.cs +++ b/Tranga/MangaConnectors/ChromiumDownloadClient.cs @@ -9,7 +9,6 @@ namespace Tranga.MangaConnectors; internal class ChromiumDownloadClient : DownloadClient { private IBrowser browser { get; set; } - private const string ChromiumVersion = "1154303"; private const int StartTimeoutMs = 30000; private readonly HttpDownloadClient _httpDownloadClient; From 96f3dbce6518733fe907dd6896720566f0a56cb6 Mon Sep 17 00:00:00 2001 From: Glax Date: Mon, 16 Sep 2024 18:32:34 +0200 Subject: [PATCH 07/18] Throw more readable exceptions if deserialization fails for Mangaconnectors. #249 --- .../MangaConnectorJsonConverter.cs | 41 ++++++++----------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/Tranga/MangaConnectors/MangaConnectorJsonConverter.cs b/Tranga/MangaConnectors/MangaConnectorJsonConverter.cs index 2213a48..3b3e6da 100644 --- a/Tranga/MangaConnectors/MangaConnectorJsonConverter.cs +++ b/Tranga/MangaConnectors/MangaConnectorJsonConverter.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json; +using System.Data; +using System.Diagnostics; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace Tranga.MangaConnectors; @@ -22,29 +24,22 @@ public class MangaConnectorJsonConverter : JsonConverter public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { JObject jo = JObject.Load(reader); - switch (jo.GetValue("name")!.Value()!) + string? connectorName = jo.Value("name"); + if (connectorName is null) + throw new ConstraintException("Name can not be null."); + return connectorName switch { - case "MangaDex": - return this._connectors.First(c => c is MangaDex); - case "Manganato": - return this._connectors.First(c => c is Manganato); - case "MangaKatana": - return this._connectors.First(c => c is MangaKatana); - case "Mangasee": - return this._connectors.First(c => c is Mangasee); - case "Mangaworld": - return this._connectors.First(c => c is Mangaworld); - case "Bato": - return this._connectors.First(c => c is Bato); - case "Manga4Life": - return this._connectors.First(c => c is MangaLife); - case "ManhuaPlus": - return this._connectors.First(c => c is ManhuaPlus); - case "MangaHere": - return this._connectors.First(c => c is MangaHere); - } - - throw new Exception(); + "MangaDex" => this._connectors.First(c => c is MangaDex), + "Manganato" => this._connectors.First(c => c is Manganato), + "MangaKatana" => this._connectors.First(c => c is MangaKatana), + "Mangasee" => this._connectors.First(c => c is Mangasee), + "Mangaworld" => this._connectors.First(c => c is Mangaworld), + "Bato" => this._connectors.First(c => c is Bato), + "Manga4Life" => this._connectors.First(c => c is MangaLife), + "ManhuaPlus" => this._connectors.First(c => c is ManhuaPlus), + "MangaHere" => this._connectors.First(c => c is MangaHere), + _ => throw new UnreachableException($"Could not find Connector with name {connectorName}") + }; } public override bool CanWrite => false; From 35f2625f0577c76a33bf70f32b42a692a419d623 Mon Sep 17 00:00:00 2001 From: Glax Date: Mon, 16 Sep 2024 19:52:25 +0200 Subject: [PATCH 08/18] Fix #249 Manhuaplus where author/tags are not set. --- Tranga/MangaConnectors/ManhuaPlus.cs | 32 ++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/Tranga/MangaConnectors/ManhuaPlus.cs b/Tranga/MangaConnectors/ManhuaPlus.cs index 524c267..9335388 100644 --- a/Tranga/MangaConnectors/ManhuaPlus.cs +++ b/Tranga/MangaConnectors/ManhuaPlus.cs @@ -82,17 +82,31 @@ public class ManhuaPlus : MangaConnector HtmlNode titleNode = document.DocumentNode.SelectSingleNode("//h1"); string sortName = titleNode.InnerText.Replace("\n", ""); - HtmlNode[] authorsNodes = document.DocumentNode - .SelectNodes("//a[contains(@href, 'https://manhuaplus.org/authors/')]") - .ToArray(); List authors = new(); - foreach (HtmlNode authorNode in authorsNodes) - authors.Add(authorNode.InnerText); + try + { + HtmlNode[] authorsNodes = document.DocumentNode + .SelectNodes("//a[contains(@href, 'https://manhuaplus.org/authors/')]") + .ToArray(); + foreach (HtmlNode authorNode in authorsNodes) + authors.Add(authorNode.InnerText); + } + catch (ArgumentNullException e) + { + Log("No authors found."); + } - HtmlNode[] genreNodes = document.DocumentNode - .SelectNodes("//a[contains(@href, 'https://manhuaplus.org/genres/')]").ToArray(); - foreach (HtmlNode genreNode in genreNodes) - tags.Add(genreNode.InnerText.Replace("\n", "")); + try + { + HtmlNode[] genreNodes = document.DocumentNode + .SelectNodes("//a[contains(@href, 'https://manhuaplus.org/genres/')]").ToArray(); + foreach (HtmlNode genreNode in genreNodes) + tags.Add(genreNode.InnerText.Replace("\n", "")); + } + catch (ArgumentNullException e) + { + Log("No genres found"); + } string yearNodeStr = document.DocumentNode .SelectSingleNode("//aside//i[contains(concat(' ',normalize-space(@class),' '),' fa-clock ')]/../span").InnerText.Replace("\n", ""); From 2dac5db4da6313bd2b6b225856c05e6c8a14f280 Mon Sep 17 00:00:00 2001 From: Glax Date: Mon, 16 Sep 2024 20:26:15 +0200 Subject: [PATCH 09/18] Create single Chromium Instance that is shared between all Connectors. Fix pages staying open when page could not be loaded. --- Tranga/MangaConnectors/ChromiumDownloadClient.cs | 16 +++++----------- Tranga/MangaConnectors/DownloadClient.cs | 1 - Tranga/MangaConnectors/HttpDownloadClient.cs | 5 ----- Tranga/MangaConnectors/MangaConnector.cs | 5 ----- 4 files changed, 5 insertions(+), 22 deletions(-) diff --git a/Tranga/MangaConnectors/ChromiumDownloadClient.cs b/Tranga/MangaConnectors/ChromiumDownloadClient.cs index efe7f53..c94f0bd 100644 --- a/Tranga/MangaConnectors/ChromiumDownloadClient.cs +++ b/Tranga/MangaConnectors/ChromiumDownloadClient.cs @@ -8,13 +8,12 @@ namespace Tranga.MangaConnectors; internal class ChromiumDownloadClient : DownloadClient { - private IBrowser browser { get; set; } - private const int StartTimeoutMs = 30000; + private static readonly IBrowser Browser = StartBrowser().Result; + private const int StartTimeoutMs = 10000; private readonly HttpDownloadClient _httpDownloadClient; - private async Task StartBrowser() + private static async Task StartBrowser() { - Log($"Starting Browser. ({StartTimeoutMs}ms timeout)"); return await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true, @@ -29,7 +28,6 @@ internal class ChromiumDownloadClient : DownloadClient public ChromiumDownloadClient(GlobalBase clone) : base(clone) { - this.browser = StartBrowser().Result; _httpDownloadClient = new(this); } @@ -43,7 +41,7 @@ internal class ChromiumDownloadClient : DownloadClient private RequestResult MakeRequestBrowser(string url, string? referrer = null, string? clickButton = null) { - IPage page = this.browser.NewPageAsync().Result; + IPage page = Browser.NewPageAsync().Result; page.DefaultTimeout = 10000; IResponse response; try @@ -54,6 +52,7 @@ internal class ChromiumDownloadClient : DownloadClient catch (Exception e) { Log($"Could not load Page:\n{e.Message}"); + page.CloseAsync(); return new RequestResult(HttpStatusCode.InternalServerError, null, Stream.Null); } @@ -84,9 +83,4 @@ internal class ChromiumDownloadClient : DownloadClient page.CloseAsync(); return new RequestResult(response.Status, document, stream, false, ""); } - - public override void Close() - { - this.browser.CloseAsync(); - } } \ No newline at end of file diff --git a/Tranga/MangaConnectors/DownloadClient.cs b/Tranga/MangaConnectors/DownloadClient.cs index 298774f..a138c62 100644 --- a/Tranga/MangaConnectors/DownloadClient.cs +++ b/Tranga/MangaConnectors/DownloadClient.cs @@ -41,5 +41,4 @@ internal abstract class DownloadClient : GlobalBase } internal abstract RequestResult MakeRequestInternal(string url, string? referrer = null, string? clickButton = null); - public abstract void Close(); } \ No newline at end of file diff --git a/Tranga/MangaConnectors/HttpDownloadClient.cs b/Tranga/MangaConnectors/HttpDownloadClient.cs index 238306b..a4a352f 100644 --- a/Tranga/MangaConnectors/HttpDownloadClient.cs +++ b/Tranga/MangaConnectors/HttpDownloadClient.cs @@ -72,9 +72,4 @@ internal class HttpDownloadClient : DownloadClient return new RequestResult(response.StatusCode, document, stream); } - - public override void Close() - { - Log("Closing."); - } } \ No newline at end of file diff --git a/Tranga/MangaConnectors/MangaConnector.cs b/Tranga/MangaConnectors/MangaConnector.cs index 5af28e5..b52112f 100644 --- a/Tranga/MangaConnectors/MangaConnector.cs +++ b/Tranga/MangaConnectors/MangaConnector.cs @@ -15,11 +15,6 @@ public abstract class MangaConnector : GlobalBase { internal DownloadClient downloadClient { get; init; } = null!; - public void StopDownloadClient() - { - downloadClient.Close(); - } - protected MangaConnector(GlobalBase clone, string name) : base(clone) { this.name = name; From 7f3754fb64e9d022a2c694540fc5e467b80c9320 Mon Sep 17 00:00:00 2001 From: Glax Date: Mon, 16 Sep 2024 20:36:40 +0200 Subject: [PATCH 10/18] Fix startup issue/issue with existing chapters: ProgressToken would not complete --- Tranga/MangaConnectors/MangaConnector.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tranga/MangaConnectors/MangaConnector.cs b/Tranga/MangaConnectors/MangaConnector.cs index b52112f..38619f9 100644 --- a/Tranga/MangaConnectors/MangaConnector.cs +++ b/Tranga/MangaConnectors/MangaConnector.cs @@ -229,7 +229,10 @@ public abstract class MangaConnector : GlobalBase Directory.CreateDirectory(directoryPath); if (File.Exists(saveArchiveFilePath)) //Don't download twice. + { + progressToken?.Complete(); return HttpStatusCode.Created; + } //Create a temporary folder to store images string tempFolder = Directory.CreateTempSubdirectory("trangatemp").FullName; From 600b56033d2d38fdcef83e1b82dfd4f1bab3b248 Mon Sep 17 00:00:00 2001 From: Glax Date: Mon, 16 Sep 2024 21:11:50 +0200 Subject: [PATCH 11/18] Upgrade to Dotnet 8.0 LangVer 12 --- CLI/CLI.csproj | 3 ++- Dockerfile | 2 +- Logging/Logging.csproj | 3 ++- Tranga/Tranga.csproj | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CLI/CLI.csproj b/CLI/CLI.csproj index abf151f..f4f37e2 100644 --- a/CLI/CLI.csproj +++ b/CLI/CLI.csproj @@ -2,9 +2,10 @@ Exe - net7.0 + net8.0 enable enable + 12 diff --git a/Dockerfile b/Dockerfile index e3938b3..5162023 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1 -ARG DOTNET=7.0 +ARG DOTNET=8.0 FROM mcr.microsoft.com/dotnet/runtime:$DOTNET AS base WORKDIR /publish diff --git a/Logging/Logging.csproj b/Logging/Logging.csproj index 6836c68..ccbcb6c 100644 --- a/Logging/Logging.csproj +++ b/Logging/Logging.csproj @@ -1,9 +1,10 @@ - net7.0 + net8.0 enable enable + 12 diff --git a/Tranga/Tranga.csproj b/Tranga/Tranga.csproj index 58cb6de..fece562 100644 --- a/Tranga/Tranga.csproj +++ b/Tranga/Tranga.csproj @@ -1,10 +1,11 @@ - net7.0 + net8.0 enable enable Exe + 12 From cf5cbba9a8e6af9f72c00c9dcc8468a489dca1e4 Mon Sep 17 00:00:00 2001 From: Glax Date: Mon, 16 Sep 2024 21:17:07 +0200 Subject: [PATCH 12/18] #247 Add supported languages to Mangaconnectors --- Tranga/MangaConnectors/Bato.cs | 2 +- Tranga/MangaConnectors/MangaConnector.cs | 4 +++- Tranga/MangaConnectors/MangaDex.cs | 9 ++++++--- Tranga/MangaConnectors/MangaHere.cs | 2 +- Tranga/MangaConnectors/MangaKatana.cs | 2 +- Tranga/MangaConnectors/MangaLife.cs | 2 +- Tranga/MangaConnectors/Manganato.cs | 2 +- Tranga/MangaConnectors/Mangasee.cs | 2 +- Tranga/MangaConnectors/Mangaworld.cs | 2 +- Tranga/MangaConnectors/ManhuaPlus.cs | 2 +- 10 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Tranga/MangaConnectors/Bato.cs b/Tranga/MangaConnectors/Bato.cs index 5b5f370..798967a 100644 --- a/Tranga/MangaConnectors/Bato.cs +++ b/Tranga/MangaConnectors/Bato.cs @@ -8,7 +8,7 @@ namespace Tranga.MangaConnectors; public class Bato : MangaConnector { - public Bato(GlobalBase clone) : base(clone, "Bato") + public Bato(GlobalBase clone) : base(clone, "Bato", ["en"]) { this.downloadClient = new HttpDownloadClient(clone); } diff --git a/Tranga/MangaConnectors/MangaConnector.cs b/Tranga/MangaConnectors/MangaConnector.cs index 38619f9..fbe377d 100644 --- a/Tranga/MangaConnectors/MangaConnector.cs +++ b/Tranga/MangaConnectors/MangaConnector.cs @@ -14,10 +14,12 @@ namespace Tranga.MangaConnectors; public abstract class MangaConnector : GlobalBase { internal DownloadClient downloadClient { get; init; } = null!; + protected string[] SupportedLanguages; - protected MangaConnector(GlobalBase clone, string name) : base(clone) + protected MangaConnector(GlobalBase clone, string name, string[] supportedLanguages) : base(clone) { this.name = name; + this.SupportedLanguages = supportedLanguages; Directory.CreateDirectory(TrangaSettings.coverImageCache); } diff --git a/Tranga/MangaConnectors/MangaDex.cs b/Tranga/MangaConnectors/MangaDex.cs index cbb8ffb..07480f5 100644 --- a/Tranga/MangaConnectors/MangaDex.cs +++ b/Tranga/MangaConnectors/MangaDex.cs @@ -7,14 +7,17 @@ using JsonSerializer = System.Text.Json.JsonSerializer; namespace Tranga.MangaConnectors; public class MangaDex : MangaConnector { - public MangaDex(GlobalBase clone) : base(clone, "MangaDex") + //https://api.mangadex.org/docs/3-enumerations/#language-codes--localization + //https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes + //https://gist.github.com/Josantonius/b455e315bc7f790d14b136d61d9ae469 + public MangaDex(GlobalBase clone) : base(clone, "MangaDex", ["en","pt","pt-br","it","de","ru","aa","ab","ae","af","ak","am","an","ar-ae","ar-bh","ar-dz","ar-eg","ar-iq","ar-jo","ar-kw","ar-lb","ar-ly","ar-ma","ar-om","ar-qa","ar-sa","ar-sy","ar-tn","ar-ye","ar","as","av","ay","az","ba","be","bg","bh","bi","bm","bn","bo","br","bs","ca","ce","ch","co","cr","cs","cu","cv","cy","da","de-at","de-ch","de-de","de-li","de-lu","div","dv","dz","ee","el","en-au","en-bz","en-ca","en-cb","en-gb","en-ie","en-jm","en-nz","en-ph","en-tt","en-us","en-za","en-zw","eo","es-ar","es-bo","es-cl","es-co","es-cr","es-do","es-ec","es-es","es-gt","es-hn","es-la","es-mx","es-ni","es-pa","es-pe","es-pr","es-py","es-sv","es-us","es-uy","es-ve","es","et","eu","fa","ff","fi","fj","fo","fr-be","fr-ca","fr-ch","fr-fr","fr-lu","fr-mc","fr","fy","ga","gd","gl","gn","gu","gv","ha","he","hi","ho","hr-ba","hr-hr","hr","ht","hu","hy","hz","ia","id","ie","ig","ii","ik","in","io","is","it-ch","it-it","iu","iw","ja","ja-ro","ji","jv","jw","ka","kg","ki","kj","kk","kl","km","kn","ko","ko-ro","kr","ks","ku","kv","kw","ky","kz","la","lb","lg","li","ln","lo","ls","lt","lu","lv","mg","mh","mi","mk","ml","mn","mo","mr","ms-bn","ms-my","ms","mt","my","na","nb","nd","ne","ng","nl-be","nl-nl","nl","nn","no","nr","ns","nv","ny","oc","oj","om","or","os","pa","pi","pl","ps","pt-pt","qu-bo","qu-ec","qu-pe","qu","rm","rn","ro","rw","sa","sb","sc","sd","se-fi","se-no","se-se","se","sg","sh","si","sk","sl","sm","sn","so","sq","sr-ba","sr-sp","sr","ss","st","su","sv-fi","sv-se","sv","sw","sx","syr","ta","te","tg","th","ti","tk","tl","tn","to","tr","ts","tt","tw","ty","ug","uk","ur","us","uz","ve","vi","vo","wa","wo","xh","yi","yo","za","zh-cn","zh-hk","zh-mo","zh-ro","zh-sg","zh-tw","zh","zu"]) { this.downloadClient = new HttpDownloadClient(clone); } public override Manga[] GetManga(string publicationTitle = "") { - Log($"Searching Publications. Term=\"{publicationTitle}\""); + Log($"Searching Publications. Term={publicationTitle}"); const int limit = 100; //How many values we want returned at once int offset = 0; //"Page" int total = int.MaxValue; //How many total results are there, is updated on first request @@ -54,7 +57,7 @@ public class MangaDex : MangaConnector if(MangaFromJsonObject(mangaNode.AsObject()) is { } manga) retManga.Add(manga); //Add Publication (Manga) to result } - Log($"Retrieved {retManga.Count} publications. Term=\"{publicationTitle}\""); + Log($"Retrieved {retManga.Count} publications. Term={publicationTitle}"); return retManga.ToArray(); } diff --git a/Tranga/MangaConnectors/MangaHere.cs b/Tranga/MangaConnectors/MangaHere.cs index 0da1c5a..2cf0c22 100644 --- a/Tranga/MangaConnectors/MangaHere.cs +++ b/Tranga/MangaConnectors/MangaHere.cs @@ -7,7 +7,7 @@ namespace Tranga.MangaConnectors; public class MangaHere : MangaConnector { - public MangaHere(GlobalBase clone) : base(clone, "MangaHere") + public MangaHere(GlobalBase clone) : base(clone, "MangaHere", ["en"]) { this.downloadClient = new ChromiumDownloadClient(clone); } diff --git a/Tranga/MangaConnectors/MangaKatana.cs b/Tranga/MangaConnectors/MangaKatana.cs index 64ab6c4..32bc78d 100644 --- a/Tranga/MangaConnectors/MangaKatana.cs +++ b/Tranga/MangaConnectors/MangaKatana.cs @@ -7,7 +7,7 @@ namespace Tranga.MangaConnectors; public class MangaKatana : MangaConnector { - public MangaKatana(GlobalBase clone) : base(clone, "MangaKatana") + public MangaKatana(GlobalBase clone) : base(clone, "MangaKatana", ["en"]) { this.downloadClient = new HttpDownloadClient(clone); } diff --git a/Tranga/MangaConnectors/MangaLife.cs b/Tranga/MangaConnectors/MangaLife.cs index 44b54a5..9c65a4b 100644 --- a/Tranga/MangaConnectors/MangaLife.cs +++ b/Tranga/MangaConnectors/MangaLife.cs @@ -7,7 +7,7 @@ namespace Tranga.MangaConnectors; public class MangaLife : MangaConnector { - public MangaLife(GlobalBase clone) : base(clone, "Manga4Life") + public MangaLife(GlobalBase clone) : base(clone, "Manga4Life", ["en"]) { this.downloadClient = new ChromiumDownloadClient(clone); } diff --git a/Tranga/MangaConnectors/Manganato.cs b/Tranga/MangaConnectors/Manganato.cs index 0c6e85b..3422b34 100644 --- a/Tranga/MangaConnectors/Manganato.cs +++ b/Tranga/MangaConnectors/Manganato.cs @@ -8,7 +8,7 @@ namespace Tranga.MangaConnectors; public class Manganato : MangaConnector { - public Manganato(GlobalBase clone) : base(clone, "Manganato") + public Manganato(GlobalBase clone) : base(clone, "Manganato", ["en"]) { this.downloadClient = new HttpDownloadClient(clone); } diff --git a/Tranga/MangaConnectors/Mangasee.cs b/Tranga/MangaConnectors/Mangasee.cs index 7128910..a4de0cc 100644 --- a/Tranga/MangaConnectors/Mangasee.cs +++ b/Tranga/MangaConnectors/Mangasee.cs @@ -11,7 +11,7 @@ namespace Tranga.MangaConnectors; public class Mangasee : MangaConnector { - public Mangasee(GlobalBase clone) : base(clone, "Mangasee") + public Mangasee(GlobalBase clone) : base(clone, "Mangasee", ["en"]) { this.downloadClient = new ChromiumDownloadClient(clone); } diff --git a/Tranga/MangaConnectors/Mangaworld.cs b/Tranga/MangaConnectors/Mangaworld.cs index 1140468..d21ae77 100644 --- a/Tranga/MangaConnectors/Mangaworld.cs +++ b/Tranga/MangaConnectors/Mangaworld.cs @@ -7,7 +7,7 @@ namespace Tranga.MangaConnectors; public class Mangaworld: MangaConnector { - public Mangaworld(GlobalBase clone) : base(clone, "Mangaworld") + public Mangaworld(GlobalBase clone) : base(clone, "Mangaworld", ["it"]) { this.downloadClient = new HttpDownloadClient(clone); } diff --git a/Tranga/MangaConnectors/ManhuaPlus.cs b/Tranga/MangaConnectors/ManhuaPlus.cs index 9335388..87dd3e1 100644 --- a/Tranga/MangaConnectors/ManhuaPlus.cs +++ b/Tranga/MangaConnectors/ManhuaPlus.cs @@ -7,7 +7,7 @@ namespace Tranga.MangaConnectors; public class ManhuaPlus : MangaConnector { - public ManhuaPlus(GlobalBase clone) : base(clone, "ManhuaPlus") + public ManhuaPlus(GlobalBase clone) : base(clone, "ManhuaPlus", ["en"]) { this.downloadClient = new ChromiumDownloadClient(clone); } From 5f05ba10497945d530c626f884f88c3dc625325a Mon Sep 17 00:00:00 2001 From: Glax Date: Mon, 16 Sep 2024 21:19:19 +0200 Subject: [PATCH 13/18] Make SupportedLanguages public. --- Tranga/MangaConnectors/MangaConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tranga/MangaConnectors/MangaConnector.cs b/Tranga/MangaConnectors/MangaConnector.cs index fbe377d..0a4adc0 100644 --- a/Tranga/MangaConnectors/MangaConnector.cs +++ b/Tranga/MangaConnectors/MangaConnector.cs @@ -14,7 +14,7 @@ namespace Tranga.MangaConnectors; public abstract class MangaConnector : GlobalBase { internal DownloadClient downloadClient { get; init; } = null!; - protected string[] SupportedLanguages; + public string[] SupportedLanguages; protected MangaConnector(GlobalBase clone, string name, string[] supportedLanguages) : base(clone) { From 52d0489a1b71584c92f0aabc050f997a526aeea2 Mon Sep 17 00:00:00 2001 From: Glax Date: Mon, 16 Sep 2024 22:47:55 +0200 Subject: [PATCH 14/18] Fix duplicate mangas on startup --- Tranga/Jobs/JobBoss.cs | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/Tranga/Jobs/JobBoss.cs b/Tranga/Jobs/JobBoss.cs index 610d70c..91d3870 100644 --- a/Tranga/Jobs/JobBoss.cs +++ b/Tranga/Jobs/JobBoss.cs @@ -148,7 +148,7 @@ public class JobBoss : GlobalBase Regex idRex = new (@"(.*)\.json"); //Load json-job-files - foreach (FileInfo file in new DirectoryInfo(TrangaSettings.jobsFolderPath).EnumerateFiles().Where(fileInfo => idRex.IsMatch(fileInfo.Name))) + foreach (FileInfo file in new DirectoryInfo(TrangaSettings.jobsFolderPath).EnumerateFiles().Where(fileInfo => idRex.IsMatch(fileInfo.Name))) { Log($"Adding {file.Name}"); Job? job = JsonConvert.DeserializeObject(File.ReadAllText(file.FullName), @@ -163,6 +163,7 @@ public class JobBoss : GlobalBase { Log($"Adding Job {job}"); this.jobs.Add(job); + UpdateJobFile(job, file.Name); } } @@ -188,42 +189,28 @@ public class JobBoss : GlobalBase internal void UpdateJobFile(Job job, string? oldFile = null) { string newJobFilePath = Path.Join(TrangaSettings.jobsFolderPath, $"{job.id}.json"); - - if (!this.jobs.Any(jjob => jjob.id == job.id)) + string oldFilePath = Path.Join(TrangaSettings.jobsFolderPath, oldFile); + + if (File.Exists(oldFilePath)) { + Log($"Deleting Job-file {oldFilePath}"); try { - Log($"Deleting Job-file {newJobFilePath}"); - while(IsFileInUse(newJobFilePath)) + while(IsFileInUse(oldFilePath)) Thread.Sleep(10); - File.Delete(newJobFilePath); + File.Delete(oldFilePath); } catch (Exception e) { Log(e.ToString()); } } - else - { - Log($"Exporting Job {newJobFilePath}"); - string jobStr = JsonConvert.SerializeObject(job, Formatting.Indented); - while(IsFileInUse(newJobFilePath)) - Thread.Sleep(10); - File.WriteAllText(newJobFilePath, jobStr); - } - if(oldFile is not null) - try - { - Log($"Deleting old Job-file {oldFile}"); - while(IsFileInUse(oldFile)) - Thread.Sleep(10); - File.Delete(oldFile); - } - catch (Exception e) - { - Log(e.ToString()); - } + Log($"Exporting Job {newJobFilePath}"); + string jobStr = JsonConvert.SerializeObject(job, Formatting.Indented); + while(IsFileInUse(newJobFilePath)) + Thread.Sleep(10); + File.WriteAllText(newJobFilePath, jobStr); } private void UpdateAllJobFiles() From 7c18466e958095f61cc9ecb73b9143fabdac7421 Mon Sep 17 00:00:00 2001 From: Glax Date: Mon, 16 Sep 2024 23:09:34 +0200 Subject: [PATCH 15/18] Fix NETSDK1194 on build --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5162023..f4180cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ COPY Tranga/Tranga.csproj /src/Tranga/Tranga.csproj RUN dotnet restore /src/Tranga.sln COPY . /src/ -RUN dotnet publish -c Release -o /publish -maxcpucount:1 +RUN dotnet publish -c Release --property:OutputPath=/publish -maxcpucount:1 FROM base AS runtime EXPOSE 6531 From 9dfbe89e879e5da0633365ed55f1dd4c7735ed5d Mon Sep 17 00:00:00 2001 From: Glax Date: Tue, 17 Sep 2024 00:51:22 +0200 Subject: [PATCH 16/18] include --platform=$BUILDPLATFORM in Dockerfile --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index f4180cf..1ffcca0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1 ARG DOTNET=8.0 -FROM mcr.microsoft.com/dotnet/runtime:$DOTNET AS base +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/runtime:$DOTNET AS base WORKDIR /publish ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium @@ -10,7 +10,7 @@ RUN apt-get update \ && apt-get autopurge -y \ && apt-get autoclean -y -FROM mcr.microsoft.com/dotnet/sdk:$DOTNET AS build-env +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:$DOTNET AS build-env WORKDIR /src COPY Tranga.sln /src @@ -22,7 +22,7 @@ RUN dotnet restore /src/Tranga.sln COPY . /src/ RUN dotnet publish -c Release --property:OutputPath=/publish -maxcpucount:1 -FROM base AS runtime +FROM --platform=$BUILDPLATFORM base AS runtime EXPOSE 6531 ARG UNAME=tranga ARG UID=1000 From 09fdb6e5f134be9ddf358ef54b81a45ffd866a6f Mon Sep 17 00:00:00 2001 From: Glax Date: Wed, 18 Sep 2024 18:45:55 +0200 Subject: [PATCH 17/18] Fix #250 old jobs getting re-exported. --- Tranga/Jobs/JobBoss.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Tranga/Jobs/JobBoss.cs b/Tranga/Jobs/JobBoss.cs index 91d3870..2e35168 100644 --- a/Tranga/Jobs/JobBoss.cs +++ b/Tranga/Jobs/JobBoss.cs @@ -191,6 +191,7 @@ public class JobBoss : GlobalBase string newJobFilePath = Path.Join(TrangaSettings.jobsFolderPath, $"{job.id}.json"); string oldFilePath = Path.Join(TrangaSettings.jobsFolderPath, oldFile); + //Delete old file if (File.Exists(oldFilePath)) { Log($"Deleting Job-file {oldFilePath}"); @@ -205,12 +206,16 @@ public class JobBoss : GlobalBase Log(e.ToString()); } } - - Log($"Exporting Job {newJobFilePath}"); - string jobStr = JsonConvert.SerializeObject(job, Formatting.Indented); - while(IsFileInUse(newJobFilePath)) - Thread.Sleep(10); - File.WriteAllText(newJobFilePath, jobStr); + + //Export job (in new file) if it is still in our jobs list + if (GetJobById(job.id) is not null) + { + Log($"Exporting Job {newJobFilePath}"); + string jobStr = JsonConvert.SerializeObject(job, Formatting.Indented); + while(IsFileInUse(newJobFilePath)) + Thread.Sleep(10); + File.WriteAllText(newJobFilePath, jobStr); + } } private void UpdateAllJobFiles() From 32ab9a552ffcc0e2342e31b6f53e40196ffe7612 Mon Sep 17 00:00:00 2001 From: Glax Date: Wed, 18 Sep 2024 18:56:01 +0200 Subject: [PATCH 18/18] Also delete files on UpdateJobFile if we dont provide a filepath --- Tranga/Jobs/JobBoss.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tranga/Jobs/JobBoss.cs b/Tranga/Jobs/JobBoss.cs index 2e35168..bd33c62 100644 --- a/Tranga/Jobs/JobBoss.cs +++ b/Tranga/Jobs/JobBoss.cs @@ -189,7 +189,7 @@ public class JobBoss : GlobalBase internal void UpdateJobFile(Job job, string? oldFile = null) { string newJobFilePath = Path.Join(TrangaSettings.jobsFolderPath, $"{job.id}.json"); - string oldFilePath = Path.Join(TrangaSettings.jobsFolderPath, oldFile); + string oldFilePath = Path.Join(TrangaSettings.jobsFolderPath, oldFile??$"{job.id}.json"); //Delete old file if (File.Exists(oldFilePath))