Add Job UpdateMetadata --> untested!
This commit is contained in:
parent
0a5ded2036
commit
963ad375e8
@ -4,7 +4,7 @@ namespace Tranga.Jobs;
|
||||
|
||||
public class DownloadNewChapters : Job
|
||||
{
|
||||
public Manga manga { get; init; }
|
||||
public Manga manga { get; set; }
|
||||
public string translatedLanguage { get; init; }
|
||||
|
||||
public DownloadNewChapters(GlobalBase clone, MangaConnector connector, Manga manga, DateTime lastExecution,
|
||||
|
63
Tranga/Jobs/UpdateMetadata.cs
Normal file
63
Tranga/Jobs/UpdateMetadata.cs
Normal file
@ -0,0 +1,63 @@
|
||||
using Tranga.MangaConnectors;
|
||||
|
||||
namespace Tranga.Jobs;
|
||||
|
||||
public class UpdateMetadata : Job
|
||||
{
|
||||
private Manga manga { get; set; }
|
||||
private JobBoss jobBoss { get; init; }
|
||||
|
||||
public UpdateMetadata(GlobalBase clone, MangaConnector connector, Manga manga, JobBoss jobBoss, DateTime lastExecution, string? parentJobId = null) : base(clone, connector, lastExecution, parentJobId: parentJobId)
|
||||
{
|
||||
this.manga = manga;
|
||||
this.jobBoss = jobBoss;
|
||||
}
|
||||
|
||||
public UpdateMetadata(GlobalBase clone, MangaConnector connector, Manga manga, JobBoss jobBoss, string? parentJobId = null) : base(clone, connector, parentJobId: parentJobId)
|
||||
{
|
||||
this.manga = manga;
|
||||
this.jobBoss = jobBoss;
|
||||
}
|
||||
|
||||
protected override string GetId()
|
||||
{
|
||||
return $"{GetType()}-{manga.internalId}";
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{id} Manga: {manga}";
|
||||
}
|
||||
|
||||
protected override IEnumerable<Job> ExecuteReturnSubTasksInternal()
|
||||
{
|
||||
if(manga.websiteUrl is null)
|
||||
{
|
||||
Log($"Legacy manga {manga}");
|
||||
return Array.Empty<Job>();
|
||||
}
|
||||
if (parentJobId is null)
|
||||
{
|
||||
Log($"Missing parentJob {this}");
|
||||
return Array.Empty<Job>();
|
||||
}
|
||||
Manga? possibleUpdatedManga = mangaConnector.GetMangaFromUrl(manga.websiteUrl);
|
||||
if (possibleUpdatedManga is { } updatedManga)
|
||||
{
|
||||
cachedPublications.Remove(this.manga);
|
||||
this.manga = updatedManga;
|
||||
cachedPublications.Add(updatedManga);
|
||||
this.manga.SaveSeriesInfoJson(settings.downloadLocation, true);
|
||||
|
||||
DownloadNewChapters dncJob = this.jobBoss.GetJobById(this.parentJobId) as DownloadNewChapters ??
|
||||
throw new Exception("Jobtype has to be DownloadNewChapters");
|
||||
dncJob.manga = updatedManga;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log($"Could not find Manga {manga}");
|
||||
return Array.Empty<Job>();
|
||||
}
|
||||
return Array.Empty<Job>();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user