Manga search provider updates.

This commit is contained in:
2025-05-25 19:19:45 -04:00
parent 1a752bb57e
commit 648aa95f32
8 changed files with 60 additions and 16 deletions

View File

@@ -4,8 +4,14 @@ using System.Text.RegularExpressions;
namespace MangaReader.Core.Search.MangaDex;
public class MangaDexSearchProvider(IHttpService httpService) : MangaSearchProviderBase<MangaDexSearchResult>(httpService)
public partial class MangaDexSearchProvider(IHttpService httpService) : MangaSearchProviderBase<MangaDexSearchResult>(httpService)
{
[GeneratedRegex(@"[^a-z0-9\s-]")]
private static partial Regex InvalidSlugCharactersRegex();
[GeneratedRegex(@"\s+")]
private static partial Regex WhitespaceRegex();
protected override string GetSearchUrl(string keyword)
{
string normalizedKeyword = keyword.ToLowerInvariant().Normalize(NormalizationForm.FormD);
@@ -41,9 +47,9 @@ public class MangaDexSearchProvider(IHttpService httpService) : MangaSearchProvi
// title.ToLowerInvariant().Normalize(NormalizationForm.FormD);
title = title.ToLowerInvariant();
//title = Regex.Replace(title, @"[^a-z0-9\s-]", ""); // remove invalid chars
title = Regex.Replace(title, @"[^a-z0-9\s-]", "-"); // replace invalid chars with dash
title = Regex.Replace(title, @"\s+", "-"); // replace spaces with dash
//title = InvalidSlugCharactersRegex().Replace(title, ""); // remove invalid chars
title = InvalidSlugCharactersRegex().Replace(title, "-"); // replace invalid chars with dash
title = WhitespaceRegex().Replace(title, "-"); // replace spaces with dash
return title.Trim('-');
}