2
0

#67 prevent crash if xml document does not exist

This commit is contained in:
glax 2023-10-15 12:19:44 +02:00
parent fd9319de27
commit 6844d0a242

View File

@ -121,6 +121,8 @@ public class Mangasee : MangaConnector
public override Chapter[] GetChapters(Manga manga, string language="en")
{
Log($"Getting chapters {manga}");
try
{
XDocument doc = XDocument.Load($"https://mangasee123.com/rss/{manga.publicationId}.xml");
XElement[] chapterItems = doc.Descendants("item").ToArray();
List<Chapter> chapters = new();
@ -138,6 +140,12 @@ public class Mangasee : MangaConnector
Log($"Got {chapters.Count} chapters. {manga}");
return chapters.OrderBy(chapter => Convert.ToSingle(chapter.chapterNumber, numberFormatDecimalPoint)).ToArray();
}
catch (HttpRequestException e)
{
Log($"Failed to load XML\n\r{e}");
return Array.Empty<Chapter>();
}
}
public override HttpStatusCode DownloadChapter(Chapter chapter, ProgressToken? progressToken = null)
{