2
0

Fix for new publications: Add to collection

This commit is contained in:
glax 2023-07-02 22:46:01 +02:00
parent 1735bbcf8a
commit c97ff69148
7 changed files with 16 additions and 8 deletions

View File

@ -158,7 +158,7 @@ public class RequestHandler
if (connector1 is null) if (connector1 is null)
return; return;
Publication? publication1 = _taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == internalId1); Publication? publication1 = _taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == internalId1);
if (publication1 is null) if (!publication1.HasValue)
return; return;
_taskManager.AddTask(new MonitorPublicationTask(connectorName1, (Publication)publication1, TimeSpan.Parse(reoccurrenceTime1), language1 ?? "en")); _taskManager.AddTask(new MonitorPublicationTask(connectorName1, (Publication)publication1, TimeSpan.Parse(reoccurrenceTime1), language1 ?? "en"));
break; break;
@ -277,7 +277,7 @@ public class RequestHandler
return null; return null;
if(title.Length < 4) if(title.Length < 4)
return null; return null;
return connector1.GetPublications(title); return connector1.GetPublications(ref _taskManager.collection, title);
case "/Publications/Chapters": case "/Publications/Chapters":
string[] yes = { "true", "yes", "1", "y" }; string[] yes = { "true", "yes", "1", "y" };
variables.TryGetValue("connectorName", out string? connectorName2); variables.TryGetValue("connectorName", out string? connectorName2);

View File

@ -565,7 +565,7 @@ public static class Tranga_Cli
Console.WriteLine("Publication search query (leave empty for all):"); Console.WriteLine("Publication search query (leave empty for all):");
string? query = Console.ReadLine(); string? query = Console.ReadLine();
Publication[] publications = connector.GetPublications(query ?? ""); Publication[] publications = connector.GetPublications(ref taskManager.collection, query ?? "");
if (publications.Length < 1) if (publications.Length < 1)
{ {

View File

@ -30,13 +30,21 @@ public abstract class Connector
public abstract string name { get; } //Name of the Connector (e.g. Website) public abstract string name { get; } //Name of the Connector (e.g. Website)
public Publication[] GetPublications(ref HashSet<Publication> publicationCollection, string publicationTitle = "")
{
Publication[] ret = GetPublicationsInternal(publicationTitle);
foreach (Publication p in ret)
publicationCollection.Add(p);
return ret;
}
/// <summary> /// <summary>
/// Returns all Publications with the given string. /// Returns all Publications with the given string.
/// If the string is empty or null, returns all Publication of the Connector /// If the string is empty or null, returns all Publication of the Connector
/// </summary> /// </summary>
/// <param name="publicationTitle">Search-Query</param> /// <param name="publicationTitle">Search-Query</param>
/// <returns>Publications matching the query</returns> /// <returns>Publications matching the query</returns>
public abstract Publication[] GetPublications(string publicationTitle = ""); protected abstract Publication[] GetPublicationsInternal(string publicationTitle = "");
/// <summary> /// <summary>
/// Returns all Chapters of the publication in the provided language. /// Returns all Chapters of the publication in the provided language.

View File

@ -32,7 +32,7 @@ public class MangaDex : Connector
}, logger); }, logger);
} }
public override Publication[] GetPublications(string publicationTitle = "") protected override Publication[] GetPublicationsInternal(string publicationTitle = "")
{ {
logger?.WriteLine(this.GetType().ToString(), $"Getting Publications (title={publicationTitle})"); logger?.WriteLine(this.GetType().ToString(), $"Getting Publications (title={publicationTitle})");
const int limit = 100; //How many values we want returned at once const int limit = 100; //How many values we want returned at once

View File

@ -20,7 +20,7 @@ public class MangaKatana : Connector
}, logger); }, logger);
} }
public override Publication[] GetPublications(string publicationTitle = "") protected override Publication[] GetPublicationsInternal(string publicationTitle = "")
{ {
logger?.WriteLine(this.GetType().ToString(), $"Getting Publications (title={publicationTitle})"); logger?.WriteLine(this.GetType().ToString(), $"Getting Publications (title={publicationTitle})");
string sanitizedTitle = string.Concat(Regex.Matches(publicationTitle, "[A-z]* *")).ToLower().Replace(' ', '_'); string sanitizedTitle = string.Concat(Regex.Matches(publicationTitle, "[A-z]* *")).ToLower().Replace(' ', '_');

View File

@ -20,7 +20,7 @@ public class Manganato : Connector
}, logger); }, logger);
} }
public override Publication[] GetPublications(string publicationTitle = "") protected override Publication[] GetPublicationsInternal(string publicationTitle = "")
{ {
logger?.WriteLine(this.GetType().ToString(), $"Getting Publications (title={publicationTitle})"); logger?.WriteLine(this.GetType().ToString(), $"Getting Publications (title={publicationTitle})");
string sanitizedTitle = string.Join('_', Regex.Matches(publicationTitle, "[A-z]*")).ToLower(); string sanitizedTitle = string.Join('_', Regex.Matches(publicationTitle, "[A-z]*")).ToLower();

View File

@ -72,7 +72,7 @@ public class Mangasee : Connector
}); });
} }
public override Publication[] GetPublications(string publicationTitle = "") protected override Publication[] GetPublicationsInternal(string publicationTitle = "")
{ {
logger?.WriteLine(this.GetType().ToString(), $"Getting Publications (title={publicationTitle})"); logger?.WriteLine(this.GetType().ToString(), $"Getting Publications (title={publicationTitle})");
string requestUrl = $"https://mangasee123.com/_search.php"; string requestUrl = $"https://mangasee123.com/_search.php";