Add MangaConnector.GetMangaFromId
This commit is contained in:
parent
083ce238d8
commit
449d406eab
@ -23,12 +23,7 @@ public class UpdateMetadata : Job
|
||||
|
||||
protected override IEnumerable<Job> ExecuteReturnSubTasksInternal(JobBoss jobBoss)
|
||||
{
|
||||
if(manga.websiteUrl is null)
|
||||
{
|
||||
Log($"Legacy manga {manga}");
|
||||
return Array.Empty<Job>();
|
||||
}
|
||||
Manga? possibleUpdatedManga = mangaConnector.GetMangaFromUrl(manga.websiteUrl);
|
||||
Manga? possibleUpdatedManga = mangaConnector.GetMangaFromId(manga.publicationId);
|
||||
if (possibleUpdatedManga is { } updatedManga)
|
||||
{
|
||||
cachedPublications.Remove(this.manga);
|
||||
|
@ -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 =
|
||||
|
@ -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);
|
||||
|
||||
/// <summary>
|
||||
/// Returns all Chapters of the publication in the provided language.
|
||||
|
@ -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<JsonObject>(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"))
|
||||
|
@ -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 =
|
||||
|
@ -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\/(.*)(\/.*)*");
|
||||
|
@ -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 =
|
||||
|
@ -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\/(.*)(\/.*)*");
|
||||
|
@ -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 =
|
||||
|
Loading…
Reference in New Issue
Block a user