Restrcutured the database, and updated pipeline to include cover art.
This commit is contained in:
@@ -31,10 +31,11 @@ public class MangaDexMetadataProvider(IMangaDexClient mangaDexClient) : IMangaMe
|
||||
{
|
||||
Title = GetTitle(mangaAttributes),
|
||||
AlternateTitles = GetAlternateTitles(mangaAttributes),
|
||||
Descriptions = GetDescriptions(mangaAttributes),
|
||||
Genres = GetGenres(mangaAttributes),
|
||||
Contributors = GetContributors(mangaRelationships),
|
||||
Chapters = GetChapters(mangaDexFeedResponse),
|
||||
CoverArt = GetCoverArt(mangaGuid, coverArtResponse)
|
||||
CoverArtUrls = GetCoverArtUrls(mangaGuid, coverArtResponse)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -52,22 +53,27 @@ public class MangaDexMetadataProvider(IMangaDexClient mangaDexClient) : IMangaMe
|
||||
|
||||
private static SourceMangaTitle GetTitle(MangaAttributes attributes)
|
||||
{
|
||||
(string title, Language langauge) = GetTileAndLanguage(attributes);
|
||||
|
||||
return new()
|
||||
{
|
||||
Name = GetTileName(attributes),
|
||||
Language = Language.English
|
||||
Name = title,
|
||||
Language = langauge
|
||||
};
|
||||
}
|
||||
|
||||
private static string GetTileName(MangaAttributes attributes)
|
||||
private static (string title, Language langauge) GetTileAndLanguage(MangaAttributes attributes)
|
||||
{
|
||||
if (attributes.Title.TryGetValue("en", out string? title))
|
||||
return title;
|
||||
if (attributes.Title.TryGetValue("en", out string? englishTitle))
|
||||
return (englishTitle, Language.English);
|
||||
|
||||
return string.Empty;
|
||||
if (attributes.Title.TryGetValue("ja-ro", out string? japaneseTitle))
|
||||
return (japaneseTitle, Language.Japanese);
|
||||
|
||||
return (string.Empty, Language.Unknown);
|
||||
}
|
||||
|
||||
private static List<SourceMangaTitle> GetAlternateTitles(MangaAttributes attributes)
|
||||
private static SourceMangaTitle[] GetAlternateTitles(MangaAttributes attributes)
|
||||
{
|
||||
if (attributes.AltTitles == null || attributes.AltTitles.Count == 0)
|
||||
return [];
|
||||
@@ -98,10 +104,41 @@ public class MangaDexMetadataProvider(IMangaDexClient mangaDexClient) : IMangaMe
|
||||
}
|
||||
}
|
||||
|
||||
return sourceMangaTitles;
|
||||
return [.. sourceMangaTitles];
|
||||
}
|
||||
|
||||
private static List<string> GetGenres(MangaAttributes attributes)
|
||||
private static SourceMangaDescription[] GetDescriptions(MangaAttributes attributes)
|
||||
{
|
||||
if (attributes.AltTitles == null || attributes.AltTitles.Count == 0)
|
||||
return [];
|
||||
|
||||
Dictionary<string, Language> languageIdMap = new()
|
||||
{
|
||||
{ "en", Language.English },
|
||||
{ "ja", Language.Japanese },
|
||||
{ "ja-ro", Language.Romaji },
|
||||
};
|
||||
|
||||
List<SourceMangaDescription> sourceMangaDescriptions = [];
|
||||
|
||||
foreach (string key in attributes.Description.Keys)
|
||||
{
|
||||
if (languageIdMap.TryGetValue(key, out Language language) == false)
|
||||
continue;
|
||||
|
||||
SourceMangaDescription sourceMangaDescription = new()
|
||||
{
|
||||
Name = attributes.Description[key],
|
||||
Language = language
|
||||
};
|
||||
|
||||
sourceMangaDescriptions.Add(sourceMangaDescription);
|
||||
}
|
||||
|
||||
return [.. sourceMangaDescriptions];
|
||||
}
|
||||
|
||||
private static string[] GetGenres(MangaAttributes attributes)
|
||||
{
|
||||
if (attributes.Tags == null || attributes.Tags.Count == 0)
|
||||
return [];
|
||||
@@ -119,7 +156,7 @@ public class MangaDexMetadataProvider(IMangaDexClient mangaDexClient) : IMangaMe
|
||||
tags.Add(tagEntity.Attributes.Name.FirstOrDefault().Value);
|
||||
}
|
||||
|
||||
return tags;
|
||||
return [.. tags];
|
||||
}
|
||||
|
||||
private static SourceMangaContributor[] GetContributors(List<MangaDexEntity> relationships)
|
||||
@@ -160,7 +197,7 @@ public class MangaDexMetadataProvider(IMangaDexClient mangaDexClient) : IMangaMe
|
||||
return [.. contributors];
|
||||
}
|
||||
|
||||
private static List<SourceMangaChapter> GetChapters(MangaDexResponse? mangaDexFeedResponse)
|
||||
private static SourceMangaChapter[] GetChapters(MangaDexResponse? mangaDexFeedResponse)
|
||||
{
|
||||
if (mangaDexFeedResponse == null || mangaDexFeedResponse is not MangaDexCollectionResponse collectionResponse)
|
||||
return [];
|
||||
@@ -191,10 +228,10 @@ public class MangaDexMetadataProvider(IMangaDexClient mangaDexClient) : IMangaMe
|
||||
chapters.Add(chapter);
|
||||
}
|
||||
|
||||
return chapters;
|
||||
return [.. chapters];
|
||||
}
|
||||
|
||||
private static string[] GetCoverArt(Guid mangaGuid, MangaDexResponse? coverArtResponse)
|
||||
private static string[] GetCoverArtUrls(Guid mangaGuid, MangaDexResponse? coverArtResponse)
|
||||
{
|
||||
if (coverArtResponse == null || coverArtResponse is not MangaDexCollectionResponse collectionResponse)
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user