Add /ids route to scrape AniList and MyAnimeList IDs

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
kyle maliza
2026-03-16 08:34:55 +00:00
parent 475e456fc5
commit cdabadce73
2 changed files with 40 additions and 0 deletions

View File

@@ -318,6 +318,31 @@ ${transformedScript}
}
}
/**
* Get external IDs (AniList, MyAnimeList) for an anime
* @param {string} animeSession - Anime session ID
* @returns {Promise<Object>} Object with anilist and myanimelist IDs
*/
async getIds(animeSession) {
try {
const animePageUrl = `${this.base}/anime/${animeSession}`;
const html = await cloudscraper.get(animePageUrl, {
headers: this.getHeaders()
});
const $ = cheerio.load(html);
const anilistId = $('meta[name="anilist"]').attr('content') || null;
const malId = $('meta[name="myanimelist"]').attr('content') || null;
return {
anilist: anilistId ? parseInt(anilistId, 10) : null,
myanimelist: malId ? parseInt(malId, 10) : null
};
} catch (error) {
throw new Error(`Failed to get IDs: ${error.message}`);
}
}
/**
* Execute a Node.js script and capture output
* @param {string} scriptPath - Path to script file