mirror of
https://github.com/mdtahseen7/AnimepaheApi.git
synced 2026-04-17 16:11:44 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user