mirror of
https://github.com/C9Glax/tranga.git
synced 2025-07-04 09:54:16 +02:00
StartNewChapterDownloadsWorker.cs
This commit is contained in:
@ -2,20 +2,18 @@ using API.Schema.MangaContext;
|
|||||||
|
|
||||||
namespace API.Workers;
|
namespace API.Workers;
|
||||||
|
|
||||||
public class CheckForNewChaptersWorker(Manga manga, TimeSpan? interval = null, IEnumerable<BaseWorker>? dependsOn = null)
|
public class CheckForNewChaptersWorker(TimeSpan? interval = null, IEnumerable<BaseWorker>? dependsOn = null)
|
||||||
: BaseWorkerWithContext<MangaContext>(dependsOn), IPeriodic
|
: BaseWorkerWithContext<MangaContext>(dependsOn), IPeriodic
|
||||||
{
|
{
|
||||||
public Manga Manga = manga;
|
|
||||||
public DateTime LastExecution { get; set; } = DateTime.UtcNow;
|
public DateTime LastExecution { get; set; } = DateTime.UtcNow;
|
||||||
public TimeSpan Interval { get; set; } = interval??TimeSpan.FromMinutes(60);
|
public TimeSpan Interval { get; set; } = interval??TimeSpan.FromMinutes(60);
|
||||||
|
|
||||||
protected override BaseWorker[] DoWorkInternal()
|
protected override BaseWorker[] DoWorkInternal()
|
||||||
{
|
{
|
||||||
ICollection<MangaConnectorId<Manga>> connectorIdsManga = Manga.MangaConnectorIds;
|
IQueryable<MangaConnectorId<Manga>> connectorIdsManga = DbContext.MangaConnectorToManga.Where(id => id.UseForDownload);
|
||||||
IEnumerable<MangaConnectorId<Manga>> mangasToDownload = connectorIdsManga.Where(id => id.UseForDownload);
|
|
||||||
|
|
||||||
List<BaseWorker> newWorkers = new();
|
List<BaseWorker> newWorkers = new();
|
||||||
foreach (MangaConnectorId<Manga> mangaConnectorId in mangasToDownload)
|
foreach (MangaConnectorId<Manga> mangaConnectorId in connectorIdsManga)
|
||||||
newWorkers.Add(new RetrieveMangaChaptersFromMangaconnectorWorker(mangaConnectorId, Tranga.Settings.DownloadLanguage));
|
newWorkers.Add(new RetrieveMangaChaptersFromMangaconnectorWorker(mangaConnectorId, Tranga.Settings.DownloadLanguage));
|
||||||
|
|
||||||
return newWorkers.ToArray();
|
return newWorkers.ToArray();
|
@ -0,0 +1,21 @@
|
|||||||
|
using API.Schema.MangaContext;
|
||||||
|
|
||||||
|
namespace API.Workers;
|
||||||
|
|
||||||
|
public class StartNewChapterDownloadsWorker(TimeSpan? interval = null, IEnumerable<BaseWorker>? dependsOn = null)
|
||||||
|
: BaseWorkerWithContext<MangaContext>(dependsOn), IPeriodic
|
||||||
|
{
|
||||||
|
|
||||||
|
public DateTime LastExecution { get; set; } = DateTime.UtcNow;
|
||||||
|
public TimeSpan Interval { get; set; } = interval ?? TimeSpan.FromMinutes(120);
|
||||||
|
protected override BaseWorker[] DoWorkInternal()
|
||||||
|
{
|
||||||
|
IQueryable<MangaConnectorId<Chapter>> mangaConnectorIds = DbContext.MangaConnectorToChapter.Where(id => id.Obj.Downloaded == false && id.UseForDownload);
|
||||||
|
|
||||||
|
List<BaseWorker> newWorkers = new();
|
||||||
|
foreach (MangaConnectorId<Chapter> mangaConnectorId in mangaConnectorIds)
|
||||||
|
newWorkers.Add(new DownloadChapterFromMangaconnectorWorker(mangaConnectorId));
|
||||||
|
|
||||||
|
return newWorkers.ToArray();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user