32 lines
984 B
C#
32 lines
984 B
C#
using MangaReader.Core.Metadata;
|
|
using MangaReader.Core.Sources.MangaDex.Api;
|
|
|
|
namespace MangaReader.Core.Sources.MangaDex.Metadata;
|
|
|
|
public class MangaDexMetadataProvider(IMangaDexClient mangaDexClient) : IMangaMetadataProvider
|
|
{
|
|
public string SourceId => "MangaDex";
|
|
|
|
public async Task<SourceManga?> GetMangaAsync(string url, CancellationToken cancellationToken)
|
|
{
|
|
Guid mangaGuid = GetSourceMangaGuid(url);
|
|
MangaDexResponse? mangaDexResponse = await mangaDexClient.GetMangaAsync(mangaGuid, cancellationToken);
|
|
|
|
if (mangaDexResponse == null)
|
|
return null;
|
|
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
private static Guid GetSourceMangaGuid(string url)
|
|
{
|
|
string[] parts = url.Split('/');
|
|
|
|
if (parts.Length < 5 || Guid.TryParse(parts[4], out Guid mangaGuid) == false)
|
|
{
|
|
throw new Exception("Unable to get guid from MangaDex url: " + url);
|
|
}
|
|
|
|
return mangaGuid;
|
|
}
|
|
} |