mirror of
https://github.com/C9Glax/tranga.git
synced 2025-09-11 04:18:18 +02:00
Add API
This commit is contained in:
21
API/Schema/Jobs/DownloadNewChaptersJob.cs
Normal file
21
API/Schema/Jobs/DownloadNewChaptersJob.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using API.Schema.MangaConnectors;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace API.Schema.Jobs;
|
||||
|
||||
public class DownloadNewChaptersJob(ulong recurrenceMs, string mangaId, string? parentJobId = null, string[]? dependsOnJobIds = null)
|
||||
: Job(TokenGen.CreateToken(typeof(DownloadNewChaptersJob), 64), JobType.DownloadNewChaptersJob, recurrenceMs, parentJobId, dependsOnJobIds)
|
||||
{
|
||||
[MaxLength(64)]
|
||||
public string MangaId { get; init; } = mangaId;
|
||||
public virtual Manga Manga { get; init; }
|
||||
|
||||
public override IEnumerable<Job> Run()
|
||||
{
|
||||
MangaConnector connector = Manga.MangaConnector;
|
||||
Chapter[] newChapters = connector.GetNewChapters(Manga);
|
||||
return newChapters.Select(chapter => new DownloadSingleChapterJob(chapter.ChapterId, this.JobId));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user