2
0

Added Min-Chapter-Number to API

This commit is contained in:
glax 2023-07-28 10:47:36 +02:00
parent de14ff0b75
commit 485637d99a
2 changed files with 11 additions and 6 deletions

View File

@ -1,4 +1,5 @@
using System.Net; using System.Globalization;
using System.Net;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Tranga; using Tranga;
using Tranga.TrangaTasks; using Tranga.TrangaTasks;
@ -20,7 +21,7 @@ public class RequestHandler
new[] { "connectorName", "internalId", "onlyNew?", "onlyExisting?", "language?" }), new[] { "connectorName", "internalId", "onlyNew?", "onlyExisting?", "language?" }),
new(HttpMethod.Get, "/Tasks/Types", Array.Empty<string>()), new(HttpMethod.Get, "/Tasks/Types", Array.Empty<string>()),
new(HttpMethod.Post, "/Tasks/CreateMonitorTask", new(HttpMethod.Post, "/Tasks/CreateMonitorTask",
new[] { "connectorName", "internalId", "reoccurrenceTime", "language?" }), new[] { "connectorName", "internalId", "reoccurrenceTime", "language?", "ignoreChaptersBelow?" }),
//DEPRECATED new(HttpMethod.Post, "/Tasks/CreateUpdateLibraryTask", new[] { "reoccurrenceTime" }), //DEPRECATED new(HttpMethod.Post, "/Tasks/CreateUpdateLibraryTask", new[] { "reoccurrenceTime" }),
new(HttpMethod.Post, "/Tasks/CreateDownloadChaptersTask", new(HttpMethod.Post, "/Tasks/CreateDownloadChaptersTask",
new[] { "connectorName", "internalId", "chapters", "language?" }), new[] { "connectorName", "internalId", "chapters", "language?" }),
@ -151,6 +152,7 @@ public class RequestHandler
variables.TryGetValue("internalId", out string? internalId1); variables.TryGetValue("internalId", out string? internalId1);
variables.TryGetValue("reoccurrenceTime", out string? reoccurrenceTime1); variables.TryGetValue("reoccurrenceTime", out string? reoccurrenceTime1);
variables.TryGetValue("language", out string? language1); variables.TryGetValue("language", out string? language1);
variables.TryGetValue("ignoreChaptersBelow", out string? minChapter);
if (connectorName1 is null || internalId1 is null || reoccurrenceTime1 is null) if (connectorName1 is null || internalId1 is null || reoccurrenceTime1 is null)
return; return;
Connector? connector1 = Connector? connector1 =
@ -160,7 +162,10 @@ public class RequestHandler
Publication? publication1 = _taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == internalId1); Publication? publication1 = _taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == internalId1);
if (!publication1.HasValue) if (!publication1.HasValue)
return; return;
_taskManager.AddTask(new MonitorPublicationTask(connectorName1, (Publication)publication1, TimeSpan.Parse(reoccurrenceTime1), language1 ?? "en")); Publication pPublication1 = (Publication)publication1;
if (minChapter is not null)
pPublication1.ignoreChaptersBelow = float.Parse(minChapter,new NumberFormatInfo() { NumberDecimalSeparator = "." });
_taskManager.AddTask(new MonitorPublicationTask(connectorName1, pPublication1, TimeSpan.Parse(reoccurrenceTime1), language1 ?? "en"));
break; break;
case "/Tasks/CreateUpdateLibraryTask": // DEPRECATED case "/Tasks/CreateUpdateLibraryTask": // DEPRECATED
/*variables.TryGetValue("reoccurrenceTime", out string? reoccurrenceTime2); /*variables.TryGetValue("reoccurrenceTime", out string? reoccurrenceTime2);

View File

@ -9,7 +9,7 @@ namespace Tranga;
/// <summary> /// <summary>
/// Contains information on a Publication (Manga) /// Contains information on a Publication (Manga)
/// </summary> /// </summary>
public readonly struct Publication public struct Publication
{ {
public string sortName { get; } public string sortName { get; }
public List<string> authors { get; } public List<string> authors { get; }
@ -26,11 +26,11 @@ public readonly struct Publication
public string folderName { get; } public string folderName { get; }
public string publicationId { get; } public string publicationId { get; }
public string internalId { get; } public string internalId { get; }
public uint ignoreChaptersBelow { get; } public float ignoreChaptersBelow { get; set; }
private static readonly Regex LegalCharacters = new Regex(@"[A-Z]*[a-z]*[0-9]* *\.*-*,*'*\'*\)*\(*~*!*"); private static readonly Regex LegalCharacters = new Regex(@"[A-Z]*[a-z]*[0-9]* *\.*-*,*'*\'*\)*\(*~*!*");
public Publication(string sortName, List<string> authors, string? description, Dictionary<string,string> altTitles, string[] tags, string? posterUrl, string? coverFileNameInCache, Dictionary<string,string>? links, int? year, string? originalLanguage, string status, string publicationId, string? folderName = null, uint ignoreChaptersBelow = 0) public Publication(string sortName, List<string> authors, string? description, Dictionary<string,string> altTitles, string[] tags, string? posterUrl, string? coverFileNameInCache, Dictionary<string,string>? links, int? year, string? originalLanguage, string status, string publicationId, string? folderName = null, float ignoreChaptersBelow = 0)
{ {
this.sortName = sortName; this.sortName = sortName;
this.authors = authors; this.authors = authors;