From 436edfde66e015da99494db2e7a79cb59cbefc0d Mon Sep 17 00:00:00 2001 From: glax Date: Mon, 31 Jul 2023 22:58:41 +0200 Subject: [PATCH 1/3] Fix issue where closed connection crashes api --- Tranga/API/Server.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Tranga/API/Server.cs b/Tranga/API/Server.cs index ae913ed..8d19bc4 100644 --- a/Tranga/API/Server.cs +++ b/Tranga/API/Server.cs @@ -82,12 +82,11 @@ public class Server response.OutputStream.Write(content is not null ? Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(content)) : Array.Empty()); + response.OutputStream.Close(); } catch (HttpListenerException) { } - response.OutputStream.Close(); - } } \ No newline at end of file From 81d58020928228c2730bd0b95722e49c8283fd16 Mon Sep 17 00:00:00 2001 From: glax Date: Mon, 31 Jul 2023 23:03:46 +0200 Subject: [PATCH 2/3] MangaKatana fix bug where empty result in search would crash program --- Tranga/Connectors/MangaKatana.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tranga/Connectors/MangaKatana.cs b/Tranga/Connectors/MangaKatana.cs index e5cec4d..6c7179d 100644 --- a/Tranga/Connectors/MangaKatana.cs +++ b/Tranga/Connectors/MangaKatana.cs @@ -48,6 +48,8 @@ public class MangaKatana : Connector HtmlDocument document = new(); document.LoadHtml(htmlString); IEnumerable searchResults = document.DocumentNode.SelectNodes("//*[@id='book_list']/div"); + if (searchResults is null || !searchResults.Any()) + return Array.Empty(); List urls = new(); foreach (HtmlNode mangaResult in searchResults) { From 2538a297888faa20d49fb888e343d328aff6490a Mon Sep 17 00:00:00 2001 From: glax Date: Mon, 31 Jul 2023 23:05:29 +0200 Subject: [PATCH 3/3] MangaKatana fix search result characters --- Tranga/Connectors/MangaKatana.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tranga/Connectors/MangaKatana.cs b/Tranga/Connectors/MangaKatana.cs index 6c7179d..6205d38 100644 --- a/Tranga/Connectors/MangaKatana.cs +++ b/Tranga/Connectors/MangaKatana.cs @@ -22,7 +22,7 @@ public class MangaKatana : Connector protected override Publication[] GetPublicationsInternal(string publicationTitle = "") { commonObjects.logger?.WriteLine(this.GetType().ToString(), $"Getting Publications (title={publicationTitle})"); - string sanitizedTitle = string.Concat(Regex.Matches(publicationTitle, "[A-z]* *")).ToLower().Replace(' ', '_'); + string sanitizedTitle = string.Join('_', Regex.Matches(publicationTitle, "[A-z]*").Where(m => m.Value.Length > 0)).ToLower(); string requestUrl = $"https://mangakatana.com/?search={sanitizedTitle}&search_by=book_name"; DownloadClient.RequestResult requestResult = downloadClient.MakeRequest(requestUrl, 1);