Your commit message

This commit is contained in:
shafat420
2025-05-06 22:11:03 +06:00
parent 17c69544b7
commit 227c231e4b
2 changed files with 26 additions and 7 deletions

View File

@@ -211,6 +211,19 @@ function findBestMatch(anilistData, anicrushResults) {
let bestMatch = null; let bestMatch = null;
let highestSimilarity = 0; let highestSimilarity = 0;
// Map AniList format to Anicrush type
const formatTypeMap = {
'TV': 'TV',
'TV_SHORT': 'TV',
'MOVIE': 'MOVIE',
'SPECIAL': 'SPECIAL',
'OVA': 'OVA',
'ONA': 'ONA',
'MUSIC': 'MUSIC'
};
const expectedType = formatTypeMap[anilistData.format] || null;
// Check each result from anicrush // Check each result from anicrush
for (const result of anicrushResults.result.movies) { for (const result of anicrushResults.result.movies) {
const resultTitles = [ const resultTitles = [
@@ -227,16 +240,19 @@ function findBestMatch(anilistData, anicrushResults) {
); );
// Add bonus for year match // Add bonus for year match
let currentSimilarity = similarity;
if (anilistData.seasonYear && result.aired_from) { if (anilistData.seasonYear && result.aired_from) {
const yearMatch = result.aired_from.includes(anilistData.seasonYear.toString()); const yearMatch = result.aired_from.includes(anilistData.seasonYear.toString());
const currentSimilarity = similarity + (yearMatch ? 15 : 0); if (yearMatch) currentSimilarity += 15;
}
// Add bonus for type match
if (expectedType && result.type && expectedType === result.type) {
currentSimilarity += 20; // Higher bonus for type match
}
if (currentSimilarity > highestSimilarity) { if (currentSimilarity > highestSimilarity) {
highestSimilarity = currentSimilarity; highestSimilarity = currentSimilarity;
bestMatch = result;
}
} else if (similarity > highestSimilarity) {
highestSimilarity = similarity;
bestMatch = result; bestMatch = result;
} }
} }

3
package-lock.json generated
View File

@@ -15,6 +15,9 @@
}, },
"devDependencies": { "devDependencies": {
"nodemon": "^3.0.2" "nodemon": "^3.0.2"
},
"engines": {
"node": "18.x"
} }
}, },
"node_modules/accepts": { "node_modules/accepts": {