mirror of
https://github.com/C9Glax/tranga.git
synced 2025-06-19 17:47:53 +02:00
Add API
This commit is contained in:
43
API/Schema/MangaConnectors/MangaConnector.cs
Normal file
43
API/Schema/MangaConnectors/MangaConnector.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using API.MangaDownloadClients;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace API.Schema.MangaConnectors;
|
||||
|
||||
[PrimaryKey("Name")]
|
||||
public abstract class MangaConnector(string name, string[] supportedLanguages, string[] baseUris)
|
||||
{
|
||||
[MaxLength(32)]
|
||||
public string Name { get; init; } = name;
|
||||
public string[] SupportedLanguages { get; init; } = supportedLanguages;
|
||||
public string[] BaseUris { get; init; } = baseUris;
|
||||
|
||||
[ForeignKey("MangaIds")]
|
||||
public virtual Manga[] Mangas { get; internal set; } = [];
|
||||
|
||||
|
||||
public abstract Manga[] GetManga(string publicationTitle = "");
|
||||
|
||||
public abstract Manga? GetMangaFromUrl(string url);
|
||||
|
||||
public abstract Manga? GetMangaFromId(string publicationId);
|
||||
|
||||
public abstract Chapter[] GetChapters(Manga manga, string language="en");
|
||||
|
||||
[JsonIgnore]
|
||||
[NotMapped]
|
||||
internal DownloadClient downloadClient { get; init; } = null!;
|
||||
|
||||
public Chapter[] GetNewChapters(Manga manga)
|
||||
{
|
||||
Chapter[] allChapters = GetChapters(manga);
|
||||
if (allChapters.Length < 1)
|
||||
return [];
|
||||
|
||||
return allChapters.Where(chapter => !chapter.IsDownloaded()).ToArray();
|
||||
}
|
||||
|
||||
internal abstract string[] GetChapterImageUrls(Chapter chapter);
|
||||
}
|
Reference in New Issue
Block a user