mirror of
https://github.com/shafat-96/anicrush-api.git
synced 2026-04-17 15:51:44 +00:00
Your commit message
This commit is contained in:
30
mapper.js
30
mapper.js
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
if (currentSimilarity > highestSimilarity) {
|
// Add bonus for type match
|
||||||
highestSimilarity = currentSimilarity;
|
if (expectedType && result.type && expectedType === result.type) {
|
||||||
bestMatch = result;
|
currentSimilarity += 20; // Higher bonus for type match
|
||||||
}
|
}
|
||||||
} else if (similarity > highestSimilarity) {
|
|
||||||
highestSimilarity = similarity;
|
if (currentSimilarity > highestSimilarity) {
|
||||||
|
highestSimilarity = currentSimilarity;
|
||||||
bestMatch = result;
|
bestMatch = result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3
package-lock.json
generated
3
package-lock.json
generated
@@ -15,6 +15,9 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"nodemon": "^3.0.2"
|
"nodemon": "^3.0.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "18.x"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/accepts": {
|
"node_modules/accepts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user