Add Manga to cached on parsing
This commit is contained in:
parent
99ad702163
commit
32fd75bdae
@ -65,8 +65,6 @@ public class MangaDex : MangaConnector
|
||||
retManga.Add(manga); //Add Publication (Manga) to result
|
||||
}
|
||||
}
|
||||
|
||||
cachedPublications.AddRange(retManga);
|
||||
Log($"Retrieved {retManga.Count} publications. Term=\"{publicationTitle}\"");
|
||||
return retManga.ToArray();
|
||||
}
|
||||
@ -170,6 +168,7 @@ public class MangaDex : MangaConnector
|
||||
status,
|
||||
publicationId
|
||||
);
|
||||
cachedPublications.Add(pub);
|
||||
return pub;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,6 @@ public class MangaKatana : MangaConnector
|
||||
}
|
||||
|
||||
Manga[] publications = ParsePublicationsFromHtml(requestResult.result);
|
||||
cachedPublications.AddRange(publications);
|
||||
Log($"Retrieved {publications.Length} publications. Term=\"{publicationTitle}\"");
|
||||
return publications;
|
||||
}
|
||||
@ -140,8 +139,10 @@ public class MangaKatana : MangaConnector
|
||||
year = Convert.ToInt32(yearString);
|
||||
}
|
||||
|
||||
return new Manga(sortName, authors.ToList(), description, altTitles, tags.ToArray(), posterUrl, coverFileNameInCache, links,
|
||||
Manga manga = new (sortName, authors.ToList(), description, altTitles, tags.ToArray(), posterUrl, coverFileNameInCache, links,
|
||||
year, originalLanguage, status, publicationId);
|
||||
cachedPublications.Add(manga);
|
||||
return manga;
|
||||
}
|
||||
|
||||
public override Chapter[] GetChapters(Manga manga, string language="en")
|
||||
|
@ -30,7 +30,6 @@ public class Manganato : MangaConnector
|
||||
return Array.Empty<Manga>();
|
||||
|
||||
Manga[] publications = ParsePublicationsFromHtml(requestResult.result);
|
||||
cachedPublications.AddRange(publications);
|
||||
Log($"Retrieved {publications.Length} publications. Term=\"{publicationTitle}\"");
|
||||
return publications;
|
||||
}
|
||||
@ -129,8 +128,10 @@ public class Manganato : MangaConnector
|
||||
.First(s => s.HasClass("chapter-time")).InnerText;
|
||||
int year = Convert.ToInt32(yearString.Split(',')[^1]) + 2000;
|
||||
|
||||
return new Manga(sortName, authors.ToList(), description, altTitles, tags.ToArray(), posterUrl, coverFileNameInCache, links,
|
||||
Manga manga = new (sortName, authors.ToList(), description, altTitles, tags.ToArray(), posterUrl, coverFileNameInCache, links,
|
||||
year, originalLanguage, status, publicationId);
|
||||
cachedPublications.Add(manga);
|
||||
return manga;
|
||||
}
|
||||
|
||||
public override Chapter[] GetChapters(Manga manga, string language="en")
|
||||
|
@ -79,7 +79,6 @@ public class Mangasee : MangaConnector
|
||||
return Array.Empty<Manga>();
|
||||
|
||||
Manga[] publications = ParsePublicationsFromHtml(requestResult.result, publicationTitle);
|
||||
cachedPublications.AddRange(publications);
|
||||
Log($"Retrieved {publications.Length} publications. Term=\"{publicationTitle}\"");
|
||||
return publications;
|
||||
}
|
||||
@ -148,8 +147,8 @@ public class Mangasee : MangaConnector
|
||||
string coverFileNameInCache = SaveCoverImageToCache(posterUrl, 1);
|
||||
|
||||
HtmlNode titleNode = document.DocumentNode.SelectSingleNode("//div[@class='BoxBody']//div[@class='row']//h1");
|
||||
string title = titleNode.InnerText;
|
||||
string publicationId = title;
|
||||
string sortName = titleNode.InnerText;
|
||||
string publicationId = sortName;
|
||||
|
||||
HtmlNode[] authorsNodes = document.DocumentNode.SelectNodes("//div[@class='BoxBody']//div[@class='row']//span[text()='Author(s):']/..").Descendants("a").ToArray();
|
||||
List<string> authors = new();
|
||||
@ -171,8 +170,10 @@ public class Mangasee : MangaConnector
|
||||
HtmlNode descriptionNode = document.DocumentNode.SelectNodes("//div[@class='BoxBody']//div[@class='row']//span[text()='Description:']/..").Descendants("div").First();
|
||||
string description = descriptionNode.InnerText;
|
||||
|
||||
return new Manga(title, authors, description, altTitles, tags.ToArray(), posterUrl, coverFileNameInCache, links,
|
||||
Manga manga = new (sortName, authors.ToList(), description, altTitles, tags.ToArray(), posterUrl, coverFileNameInCache, links,
|
||||
year, originalLanguage, status, publicationId);
|
||||
cachedPublications.Add(manga);
|
||||
return manga;
|
||||
}
|
||||
|
||||
// ReSharper disable once ClassNeverInstantiated.Local Will be instantiated during deserialization
|
||||
|
@ -134,14 +134,25 @@ public class Server : GlobalBase
|
||||
}
|
||||
break;
|
||||
case "Manga/FromConnector":
|
||||
requestVariables.TryGetValue("title", out string? title);
|
||||
requestVariables.TryGetValue("url", out string? url);
|
||||
if (!requestVariables.TryGetValue("connector", out connectorName) ||
|
||||
!requestVariables.TryGetValue("title", out string? title) ||
|
||||
!_parent.TryGetConnector(connectorName, out connector))
|
||||
!_parent.TryGetConnector(connectorName, out connector) ||
|
||||
(title is null && url is null))
|
||||
{
|
||||
SendResponse(HttpStatusCode.BadRequest, response);
|
||||
break;
|
||||
}
|
||||
SendResponse(HttpStatusCode.OK, response, connector!.GetManga(title));
|
||||
|
||||
if (url is not null)
|
||||
{
|
||||
HashSet<Manga> ret = new();
|
||||
manga = connector!.GetMangaFromUrl(url);
|
||||
if (manga is not null)
|
||||
ret.Add((Manga)manga);
|
||||
SendResponse(HttpStatusCode.OK, response, ret);
|
||||
}else
|
||||
SendResponse(HttpStatusCode.OK, response, connector!.GetManga(title!));
|
||||
break;
|
||||
case "Manga/Chapters":
|
||||
if(!requestVariables.TryGetValue("connector", out connectorName) ||
|
||||
|
Loading…
Reference in New Issue
Block a user