mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
fix(route/kurogames): handle unavailable article content property (#19131)
The article https://wutheringwaves.kurogames.com/zh-tw/main/news/detail/2596 has no article content property in the API and causes a cheerio load error during runtime, this commit fixes that issue and falls back to an empty RSS item description for these kind of articles. Closes #19124
This commit is contained in:
@@ -21,7 +21,7 @@ export enum Parameter {
|
||||
export const SUPPORTED_LANGUAGES = Object.values(Language);
|
||||
|
||||
export interface Article {
|
||||
articleContent: string;
|
||||
articleContent?: string;
|
||||
articleDesc: string;
|
||||
articleId: number;
|
||||
articleTitle: string;
|
||||
|
||||
@@ -63,7 +63,10 @@ Language codes for the \`${Parameter.Language}\` parameter:
|
||||
};
|
||||
|
||||
return cache.tryGet(`wutheringwaves:${language}:${article.articleId}`, async () => {
|
||||
const { articleContent } = await ofetch<Article>(contentUrl, { query: { t: Date.now() } });
|
||||
const articleDetails = await ofetch<Article>(contentUrl, { query: { t: Date.now() } });
|
||||
// Article content may not always be available, e.g: https://wutheringwaves.kurogames.com/zh-tw/main/news/detail/2596
|
||||
const articleContent = articleDetails.articleContent ?? '';
|
||||
|
||||
const $ = cheerio.load(articleContent);
|
||||
|
||||
item.description = $.html() ?? article.articleDesc ?? '';
|
||||
|
||||
Reference in New Issue
Block a user