Skip to content

Commit

Permalink
AsuraToon Crash on no Artists or Authors
Browse files Browse the repository at this point in the history
Fix #296
  • Loading branch information
C9Glax committed Dec 14, 2024
1 parent b8c624f commit 825b945
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Tranga/MangaConnectors/AsuraToon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,13 @@ private Manga ParseSinglePublicationFromHtml(HtmlDocument document, string publi

HtmlNode descriptionNode =
document.DocumentNode.SelectSingleNode("//h3[starts-with(text(),'Synopsis')]/../span");
string description = descriptionNode.InnerText;
string description = descriptionNode?.InnerText??"";

HtmlNodeCollection authorNodes = document.DocumentNode.SelectNodes("//h3[text()='Author']/../h3[not(text()='Author' or text()='_')]");
HtmlNodeCollection artistNodes = document.DocumentNode.SelectNodes("//h3[text()='Artist']/../h3[not(text()='Author' or text()='_')]");
List<string> authors = authorNodes.Select(a => a.InnerText).Concat(artistNodes.Select(a => a.InnerText)).ToList();
HtmlNodeCollection artistNodes = document.DocumentNode.SelectNodes("//h3[text()='Artist']/../h3[not(text()='Artist' or text()='_')]");
IEnumerable<string> authorNames = authorNodes is null ? [] : authorNodes.Select(a => a.InnerText);
IEnumerable<string> artistNames = artistNodes is null ? [] : artistNodes.Select(a => a.InnerText);
List<string> authors = authorNames.Concat(artistNames).ToList();

HtmlNode? firstChapterNode = document.DocumentNode.SelectSingleNode("//a[contains(@href, 'chapter/1')]/../following-sibling::h3");
int? year = int.Parse(firstChapterNode?.InnerText.Split(' ')[^1] ?? "2000");
Expand Down

0 comments on commit 825b945

Please sign in to comment.