Merge pull request 'Fixes for MangaKatana' (!53) from cuttingedge into master

Reviewed-on: glax/Tranga#53
This commit is contained in:
glax 2023-07-31 23:09:24 +02:00
commit a4f67c9ab4
2 changed files with 4 additions and 3 deletions

View File

@ -82,12 +82,11 @@ public class Server
response.OutputStream.Write(content is not null
? Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(content))
: Array.Empty<byte>());
response.OutputStream.Close();
}
catch (HttpListenerException)
{
}
response.OutputStream.Close();
}
}

View File

@ -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);
@ -48,6 +48,8 @@ public class MangaKatana : Connector
HtmlDocument document = new();
document.LoadHtml(htmlString);
IEnumerable<HtmlNode> searchResults = document.DocumentNode.SelectNodes("//*[@id='book_list']/div");
if (searchResults is null || !searchResults.Any())
return Array.Empty<Publication>();
List<string> urls = new();
foreach (HtmlNode mangaResult in searchResults)
{