fix: update devil fruit extraction to handle redirects and ensure correct title retrieval
Some checks failed
Build Docker Image / build (push) Has been cancelled
Some checks failed
Build Docker Image / build (push) Has been cancelled
This commit is contained in:
@@ -611,9 +611,14 @@ async function extractDevilFruit($: cheerio.CheerioAPI): Promise<DevilFruitData
|
||||
|
||||
const cleanUrl = href.replace('/wiki/', '');
|
||||
|
||||
// Query the devil fruit page via API to get the correct HTML content (in case of redirect) and extract the type from there
|
||||
const dfResponse = await fetchWithRetry(`${FANDOM_API_BASE}${cleanUrl}`);
|
||||
const dfJsonData = await dfResponse.json();
|
||||
const fruitTitle = dfJsonData.parse?.title || '';
|
||||
|
||||
return {
|
||||
devilFruitId: normalizeId(cleanUrl),
|
||||
devilFruitUrl: cleanUrl
|
||||
devilFruitId: normalizeId(fruitTitle),
|
||||
devilFruitUrl: fruitTitle
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user