Fix for new publications: Add to collection
This commit is contained in:
parent
1735bbcf8a
commit
c97ff69148
@ -158,7 +158,7 @@ public class RequestHandler
|
||||
if (connector1 is null)
|
||||
return;
|
||||
Publication? publication1 = _taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == internalId1);
|
||||
if (publication1 is null)
|
||||
if (!publication1.HasValue)
|
||||
return;
|
||||
_taskManager.AddTask(new MonitorPublicationTask(connectorName1, (Publication)publication1, TimeSpan.Parse(reoccurrenceTime1), language1 ?? "en"));
|
||||
break;
|
||||
@ -277,7 +277,7 @@ public class RequestHandler
|
||||
return null;
|
||||
if(title.Length < 4)
|
||||
return null;
|
||||
return connector1.GetPublications(title);
|
||||
return connector1.GetPublications(ref _taskManager.collection, title);
|
||||
case "/Publications/Chapters":
|
||||
string[] yes = { "true", "yes", "1", "y" };
|
||||
variables.TryGetValue("connectorName", out string? connectorName2);
|
||||
|
@ -565,7 +565,7 @@ public static class Tranga_Cli
|
||||
Console.WriteLine("Publication search query (leave empty for all):");
|
||||
string? query = Console.ReadLine();
|
||||
|
||||
Publication[] publications = connector.GetPublications(query ?? "");
|
||||
Publication[] publications = connector.GetPublications(ref taskManager.collection, query ?? "");
|
||||
|
||||
if (publications.Length < 1)
|
||||
{
|
||||
|
@ -29,6 +29,14 @@ public abstract class Connector
|
||||
}
|
||||
|
||||
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>
|
||||
/// Returns all Publications with the given string.
|
||||
@ -36,7 +44,7 @@ public abstract class Connector
|
||||
/// </summary>
|
||||
/// <param name="publicationTitle">Search-Query</param>
|
||||
/// <returns>Publications matching the query</returns>
|
||||
public abstract Publication[] GetPublications(string publicationTitle = "");
|
||||
protected abstract Publication[] GetPublicationsInternal(string publicationTitle = "");
|
||||
|
||||
/// <summary>
|
||||
/// Returns all Chapters of the publication in the provided language.
|
||||
|
@ -32,7 +32,7 @@ public class MangaDex : Connector
|
||||
}, logger);
|
||||
}
|
||||
|
||||
public override Publication[] GetPublications(string publicationTitle = "")
|
||||
protected override Publication[] GetPublicationsInternal(string publicationTitle = "")
|
||||
{
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Getting Publications (title={publicationTitle})");
|
||||
const int limit = 100; //How many values we want returned at once
|
||||
|
@ -20,7 +20,7 @@ public class MangaKatana : Connector
|
||||
}, logger);
|
||||
}
|
||||
|
||||
public override Publication[] GetPublications(string publicationTitle = "")
|
||||
protected override Publication[] GetPublicationsInternal(string publicationTitle = "")
|
||||
{
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Getting Publications (title={publicationTitle})");
|
||||
string sanitizedTitle = string.Concat(Regex.Matches(publicationTitle, "[A-z]* *")).ToLower().Replace(' ', '_');
|
||||
|
@ -20,7 +20,7 @@ public class Manganato : Connector
|
||||
}, logger);
|
||||
}
|
||||
|
||||
public override Publication[] GetPublications(string publicationTitle = "")
|
||||
protected override Publication[] GetPublicationsInternal(string publicationTitle = "")
|
||||
{
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Getting Publications (title={publicationTitle})");
|
||||
string sanitizedTitle = string.Join('_', Regex.Matches(publicationTitle, "[A-z]*")).ToLower();
|
||||
|
@ -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})");
|
||||
string requestUrl = $"https://mangasee123.com/_search.php";
|
||||
|
Loading…
Reference in New Issue
Block a user