The Kenmei manga entry to match.
Optional
token: stringOptional authentication token.
Optional search service configuration.
A promise resolving to a MangaMatchResult object.
export async function matchSingleManga(
kenmeiManga: KenmeiManga,
token?: string,
config: Partial<SearchServiceConfig> = {},
): Promise<MangaMatchResult> {
const searchConfig = { ...DEFAULT_SEARCH_CONFIG, ...config };
// Search for potential matches
const potentialMatches = await searchMangaByTitle(
kenmeiManga.title,
token,
searchConfig,
);
// If using exact matching and we have matches, just use the top match
if (searchConfig.exactMatchingOnly && potentialMatches.length > 0) {
// Calculate a match score for the top result
const score = calculateMatchScore(
potentialMatches[0].manga,
kenmeiManga.title,
);
// If we have a good match, return it directly
if (score > 0.7) {
return {
kenmeiManga,
anilistMatches: [
{ manga: potentialMatches[0].manga, confidence: score * 100 },
],
selectedMatch: potentialMatches[0].manga,
status: "matched",
matchDate: new Date(),
};
}
}
// Fall back to the match engine for more complex matching or no exact matches
return findBestMatches(
kenmeiManga,
potentialMatches.map((match) => match.manga),
searchConfig.matchConfig,
);
}
Match a single Kenmei manga with AniList entries.