Added NatoManga page provider logic. Fixed UI font configuration.

This commit is contained in:
2025-06-09 09:58:23 -04:00
parent c26ed11bfc
commit 000a20bb0f
7 changed files with 100 additions and 11 deletions

View File

@@ -22,18 +22,22 @@ public static class ServiceCollectionExtensions
client.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:139.0) Gecko/20100101 Firefox/139.0");
});
// Http
services.AddScoped<IHttpService, HttpService>();
services.AddScoped<IHtmlLoader, HtmlLoader>();
// NatoManga
//services.AddScoped<INatoMangaClient, NatoMangaClient>();
services.AddScoped<IMangaDexClient, MangaDexClient>();
//services.AddScoped<IMangaSearchProvider, NatoMangaSearchProvider>();
services.AddScoped<IMangaSearchProvider, MangaDexSearchProvider>();
services.AddScoped<IMangaSearchCoordinator, MangaSearchCoordinator>();
//services.AddScoped<IMangaMetadataProvider, NatoMangaWebCrawler>();
///services.AddScoped<IMangaMetadataProvider, NatoMangaWebCrawler>();
// MangaDex
services.AddScoped<IMangaDexClient, MangaDexClient>();
services.AddScoped<IMangaSearchProvider, MangaDexSearchProvider>();
services.AddScoped<IMangaMetadataProvider, MangaDexMetadataProvider>();
services.AddScoped<IMangaSearchCoordinator, MangaSearchCoordinator>();
return services;
}
}

View File

@@ -0,0 +1,8 @@
using MangaReader.Core.Sources;
namespace MangaReader.Core.Pages;
public interface IMangaPageProvider : IMangaSourceComponent
{
Task<IReadOnlyList<string>> GetPageImageUrlsAsync(string chapterUrl, CancellationToken cancellationToken);
}

View File

@@ -0,0 +1,43 @@
using HtmlAgilityPack;
using MangaReader.Core.Http;
using MangaReader.Core.Pages;
namespace MangaReader.Core.Sources.NatoManga.Pages;
public class NatoMangaPageProvider(IHtmlLoader htmlLoader) : IMangaPageProvider
{
public string SourceId => "NatoManga";
public async Task<IReadOnlyList<string>> GetPageImageUrlsAsync(string chapterUrl, CancellationToken cancellationToken)
{
List<string> imageUrlCollection = [];
HtmlDocument document = await htmlLoader.GetHtmlDocumentAsync(chapterUrl, cancellationToken);
HtmlNodeCollection? htmlNodeCollection = GetImageNodeCollection(document);
if (htmlNodeCollection == null)
return imageUrlCollection;
foreach (var htmlNode in htmlNodeCollection)
{
string imageSourceUrl = htmlNode.GetAttributeValue<string>("src", string.Empty);
if (string.IsNullOrWhiteSpace(imageSourceUrl))
continue;
imageUrlCollection.Add(imageSourceUrl);
}
return imageUrlCollection;
}
private static HtmlNodeCollection? GetImageNodeCollection(HtmlDocument document)
{
HtmlNode? chapterReaderNode = document.DocumentNode.SelectSingleNode(".//div[@class='container-chapter-reader']");
if (chapterReaderNode == null)
return null;
return chapterReaderNode.SelectNodes(".//img");
}
}