#50 translated-language support (if connector supports it)
API GET Manga/Chapters new parameter "translatedLanguage"
This commit is contained in:
parent
39307f4313
commit
1066e1ca2e
@ -1,22 +1,24 @@
|
|||||||
using System.Text;
|
using Tranga.MangaConnectors;
|
||||||
using Tranga.MangaConnectors;
|
|
||||||
|
|
||||||
namespace Tranga.Jobs;
|
namespace Tranga.Jobs;
|
||||||
|
|
||||||
public class DownloadNewChapters : Job
|
public class DownloadNewChapters : Job
|
||||||
{
|
{
|
||||||
public Manga manga { get; init; }
|
public Manga manga { get; init; }
|
||||||
|
public string translatedLanguage { get; init; }
|
||||||
|
|
||||||
public DownloadNewChapters(GlobalBase clone, MangaConnector connector, Manga manga, DateTime lastExecution,
|
public DownloadNewChapters(GlobalBase clone, MangaConnector connector, Manga manga, DateTime lastExecution,
|
||||||
bool recurring = false, TimeSpan? recurrence = null, string? parentJobId = null) : base(clone, connector, lastExecution, recurring,
|
bool recurring = false, TimeSpan? recurrence = null, string? parentJobId = null, string translatedLanguage = "en") : base(clone, connector, lastExecution, recurring,
|
||||||
recurrence, parentJobId)
|
recurrence, parentJobId)
|
||||||
{
|
{
|
||||||
this.manga = manga;
|
this.manga = manga;
|
||||||
|
this.translatedLanguage = translatedLanguage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DownloadNewChapters(GlobalBase clone, MangaConnector connector, Manga manga, bool recurring = false, TimeSpan? recurrence = null, string? parentJobId = null) : base (clone, connector, recurring, recurrence, parentJobId)
|
public DownloadNewChapters(GlobalBase clone, MangaConnector connector, Manga manga, bool recurring = false, TimeSpan? recurrence = null, string? parentJobId = null, string translatedLanguage = "en") : base (clone, connector, recurring, recurrence, parentJobId)
|
||||||
{
|
{
|
||||||
this.manga = manga;
|
this.manga = manga;
|
||||||
|
this.translatedLanguage = translatedLanguage;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string GetId()
|
protected override string GetId()
|
||||||
@ -31,7 +33,7 @@ public class DownloadNewChapters : Job
|
|||||||
|
|
||||||
protected override IEnumerable<Job> ExecuteReturnSubTasksInternal()
|
protected override IEnumerable<Job> ExecuteReturnSubTasksInternal()
|
||||||
{
|
{
|
||||||
Chapter[] chapters = mangaConnector.GetNewChapters(manga);
|
Chapter[] chapters = mangaConnector.GetNewChapters(manga, this.translatedLanguage);
|
||||||
this.progressToken.increments = chapters.Length;
|
this.progressToken.increments = chapters.Length;
|
||||||
List<Job> jobs = new();
|
List<Job> jobs = new();
|
||||||
foreach (Chapter chapter in chapters)
|
foreach (Chapter chapter in chapters)
|
||||||
|
@ -163,7 +163,8 @@ public class Server : GlobalBase
|
|||||||
SendResponse(HttpStatusCode.BadRequest, response);
|
SendResponse(HttpStatusCode.BadRequest, response);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SendResponse(HttpStatusCode.OK, response, connector!.GetChapters((Manga)manga!));
|
requestVariables.TryGetValue("translatedLanguage", out string? translatedLanguage);
|
||||||
|
SendResponse(HttpStatusCode.OK, response, connector!.GetChapters((Manga)manga!, translatedLanguage??"en"));
|
||||||
break;
|
break;
|
||||||
case "Jobs":
|
case "Jobs":
|
||||||
if (!requestVariables.TryGetValue("jobId", out jobId))
|
if (!requestVariables.TryGetValue("jobId", out jobId))
|
||||||
|
Loading…
Reference in New Issue
Block a user