feat: improve title searching algorithm for aniwatch

This commit is contained in:
2024-10-28 05:08:15 -04:00
parent c2411975d5
commit 9fafa5b45d
2 changed files with 41 additions and 13 deletions

View File

@@ -22,14 +22,14 @@ type Title = {
export const findBestMatchingTitle = (
title: Partial<Title>,
titles: Partial<Title>[],
titlesToSearch: Partial<Title>[],
): string | null => {
const { english, userPreferred } = title;
const userPreferredBestMatch = userPreferred
? findBestMatch(
userPreferred,
titles
titlesToSearch
.map((title) => title.userPreferred)
.filter((title) => title !== undefined),
)
@@ -37,7 +37,7 @@ export const findBestMatchingTitle = (
const englishBestMatch = english
? findBestMatch(
english,
titles
titlesToSearch
.map((title) => title.english)
.filter((title) => title !== undefined),
)