diff --git a/Tranga/Jobs/UpdateMetadata.cs b/Tranga/Jobs/UpdateMetadata.cs index 1d0db67..c7e25ec 100644 --- a/Tranga/Jobs/UpdateMetadata.cs +++ b/Tranga/Jobs/UpdateMetadata.cs @@ -23,12 +23,7 @@ public class UpdateMetadata : Job protected override IEnumerable ExecuteReturnSubTasksInternal(JobBoss jobBoss) { - if(manga.websiteUrl is null) - { - Log($"Legacy manga {manga}"); - return Array.Empty(); - } - Manga? possibleUpdatedManga = mangaConnector.GetMangaFromUrl(manga.websiteUrl); + Manga? possibleUpdatedManga = mangaConnector.GetMangaFromId(manga.publicationId); if (possibleUpdatedManga is { } updatedManga) { cachedPublications.Remove(this.manga); diff --git a/Tranga/MangaConnectors/Bato.cs b/Tranga/MangaConnectors/Bato.cs index 9b6dfa4..7ca30da 100644 --- a/Tranga/MangaConnectors/Bato.cs +++ b/Tranga/MangaConnectors/Bato.cs @@ -36,6 +36,11 @@ public class Bato : MangaConnector return publications; } + public override Manga? GetMangaFromId(string publicationId) + { + return GetMangaFromUrl($"https://bato.to/title/{publicationId}"); + } + public override Manga? GetMangaFromUrl(string url) { DownloadClient.RequestResult requestResult = diff --git a/Tranga/MangaConnectors/MangaConnector.cs b/Tranga/MangaConnectors/MangaConnector.cs index a2a8a48..4b1b3fb 100644 --- a/Tranga/MangaConnectors/MangaConnector.cs +++ b/Tranga/MangaConnectors/MangaConnector.cs @@ -37,6 +37,8 @@ public abstract class MangaConnector : GlobalBase public abstract Manga[] GetManga(string publicationTitle = ""); public abstract Manga? GetMangaFromUrl(string url); + + public abstract Manga? GetMangaFromId(string publicationId); /// /// Returns all Chapters of the publication in the provided language. diff --git a/Tranga/MangaConnectors/MangaDex.cs b/Tranga/MangaConnectors/MangaDex.cs index 290dc6c..c0a39de 100644 --- a/Tranga/MangaConnectors/MangaDex.cs +++ b/Tranga/MangaConnectors/MangaDex.cs @@ -72,13 +72,10 @@ public class MangaDex : MangaConnector return retManga.ToArray(); } - public override Manga? GetMangaFromUrl(string url) + public override Manga? GetMangaFromId(string publicationId) { - Regex idRex = new (@"https:\/\/mangadex.org\/title\/([A-z0-9-]*)\/.*"); - string id = idRex.Match(url).Groups[1].Value; - Log($"Got id {id} from {url}"); DownloadClient.RequestResult requestResult = - downloadClient.MakeRequest($"https://api.mangadex.org/manga/{id}", (byte)RequestType.Manga); + downloadClient.MakeRequest($"https://api.mangadex.org/manga/{publicationId}", (byte)RequestType.Manga); if ((int)requestResult.statusCode < 200 || (int)requestResult.statusCode >= 300) return null; JsonObject? result = JsonSerializer.Deserialize(requestResult.result); @@ -87,6 +84,14 @@ public class MangaDex : MangaConnector return null; } + public override Manga? GetMangaFromUrl(string url) + { + Regex idRex = new (@"https:\/\/mangadex.org\/title\/([A-z0-9-]*)\/.*"); + string id = idRex.Match(url).Groups[1].Value; + Log($"Got id {id} from {url}"); + return GetMangaFromId(id); + } + private Manga? MangaFromJsonObject(JsonObject manga) { if (!manga.ContainsKey("attributes")) diff --git a/Tranga/MangaConnectors/MangaKatana.cs b/Tranga/MangaConnectors/MangaKatana.cs index 43f9dcc..10dd89e 100644 --- a/Tranga/MangaConnectors/MangaKatana.cs +++ b/Tranga/MangaConnectors/MangaKatana.cs @@ -39,6 +39,11 @@ public class MangaKatana : MangaConnector return publications; } + public override Manga? GetMangaFromId(string publicationId) + { + return GetMangaFromUrl($"https://mangakatana.com/manga/{publicationId}"); + } + public override Manga? GetMangaFromUrl(string url) { DownloadClient.RequestResult requestResult = diff --git a/Tranga/MangaConnectors/MangaLife.cs b/Tranga/MangaConnectors/MangaLife.cs index f93cdcc..19b9ced 100644 --- a/Tranga/MangaConnectors/MangaLife.cs +++ b/Tranga/MangaConnectors/MangaLife.cs @@ -32,6 +32,11 @@ public class MangaLife : MangaConnector return publications; } + public override Manga? GetMangaFromId(string publicationId) + { + return GetMangaFromUrl($"https://manga4life.com/manga/{publicationId}"); + } + public override Manga? GetMangaFromUrl(string url) { Regex publicationIdRex = new(@"https:\/\/manga4life.com\/manga\/(.*)(\/.*)*"); diff --git a/Tranga/MangaConnectors/Manganato.cs b/Tranga/MangaConnectors/Manganato.cs index 816e81a..2ef28d2 100644 --- a/Tranga/MangaConnectors/Manganato.cs +++ b/Tranga/MangaConnectors/Manganato.cs @@ -54,6 +54,11 @@ public class Manganato : MangaConnector return ret.ToArray(); } + public override Manga? GetMangaFromId(string publicationId) + { + return GetMangaFromUrl($"https://chapmanganato.com/{publicationId}"); + } + public override Manga? GetMangaFromUrl(string url) { DownloadClient.RequestResult requestResult = diff --git a/Tranga/MangaConnectors/Mangasee.cs b/Tranga/MangaConnectors/Mangasee.cs index d3d5759..e4e54b6 100644 --- a/Tranga/MangaConnectors/Mangasee.cs +++ b/Tranga/MangaConnectors/Mangasee.cs @@ -110,7 +110,12 @@ public class Mangasee : MangaConnector return 1 + (case2 < case3 ? case2 : case3); } } - + + public override Manga? GetMangaFromId(string publicationId) + { + return GetMangaFromUrl($"https://mangasee123.com/manga/{publicationId}"); + } + public override Manga? GetMangaFromUrl(string url) { Regex publicationIdRex = new(@"https:\/\/mangasee123.com\/manga\/(.*)(\/.*)*"); diff --git a/Tranga/MangaConnectors/Mangaworld.cs b/Tranga/MangaConnectors/Mangaworld.cs index 422008e..11cfb17 100644 --- a/Tranga/MangaConnectors/Mangaworld.cs +++ b/Tranga/MangaConnectors/Mangaworld.cs @@ -54,6 +54,11 @@ public class Mangaworld: MangaConnector return ret.ToArray(); } + public override Manga? GetMangaFromId(string publicationId) + { + throw new NotImplementedException(); + } + public override Manga? GetMangaFromUrl(string url) { DownloadClient.RequestResult requestResult =