diff --git a/assets/radar-rules.js b/assets/radar-rules.js index fa7db4e66..39c11e072 100644 --- a/assets/radar-rules.js +++ b/assets/radar-rules.js @@ -2731,6 +2731,33 @@ }, ], }, + 'eagle.cool': { + _name: 'Eagle', + cn: [ + { + title: '更新日志', + docs: 'https://docs.rsshub.app/program-update.html#eagle', + source: '/changelog', + target: '/eagle/changelog/cn', + }, + ], + tw: [ + { + title: '更新日誌', + docs: 'https://docs.rsshub.app/program-update.html#eagle', + source: '/changelog', + target: '/eagle/changelog/tw', + }, + ], + en: [ + { + title: 'Release Notes', + docs: 'https://docs.rsshub.app/program-update.html#eagle', + source: '/changelog', + target: '/eagle/changelog/en', + }, + ], + }, 'furaffinity.net': { _name: 'Fur Affinity', www: [ diff --git a/docs/en/program-update.md b/docs/en/program-update.md index 8502dcecd..8c1d5a06e 100644 --- a/docs/en/program-update.md +++ b/docs/en/program-update.md @@ -120,6 +120,20 @@ The owner of the official image fills in the library, for example: https://rsshu ::: +## Eagle + +### Changelog + + + +Language + +| Simplified Chinese | Traditional Chinese | English | +| ------ | -------- | -------- | +| cn | tw | en | + + + ## Everything ### Changes diff --git a/docs/program-update.md b/docs/program-update.md index 9ae092b3c..4228c1d90 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -158,6 +158,20 @@ pageClass: routes ::: +## Eagle + +### 更新日志 + + + +语言 + +| 简体中文 | 繁体中文 | 英文 | +| ------ | -------- | -------- | +| cn | tw | en | + + + ## Everything ### Changes diff --git a/lib/router.js b/lib/router.js index 9b22df7c3..d917b8ae4 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3968,4 +3968,7 @@ router.get('/iyiou', require('./routes/iyiou')); // 香港商报 router.get('/hkcd/pdf', require('./routes/hkcd/pdf')); +// Eagle +router.get('/eagle/changelog/:language?', require('./routes/eagle/changelog')); + module.exports = router; diff --git a/lib/routes/eagle/changelog.js b/lib/routes/eagle/changelog.js new file mode 100644 index 000000000..0671192a1 --- /dev/null +++ b/lib/routes/eagle/changelog.js @@ -0,0 +1,74 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + let language = ctx.params.language; + let changelog = ''; + + // 如果为空或选项以外的值,则设置默认值 + if (language === undefined || !(language === 'tw' || language === 'en')) { + language = 'cn'; + changelog = '更新日志'; + } + if (language === 'tw') { + changelog = '更新日誌'; + } + if (language === 'en') { + changelog = 'Release Notes'; + } + + // 发起 HTTP GET 请求 + const response = await got({ + method: 'get', + url: `https://${language}.eagle.cool/changelog`, + headers: { + Referer: `https://${language}.eagle.cool/`, + }, + }); + + // 使用 cheerio 加载返回的 HTML + const data = response.data; + const $ = cheerio.load(data); + + const list = $('.version'); + + ctx.state.data = { + // 源标题 + title: `Eagle ${changelog}`, + // 源链接 + link: `https://${language}.eagle.cool/changelog`, + // 源说明 + description: `Eagle ${changelog}`, + + // 遍历此前获取的数据 + item: + list && + list.map((index, item) => { + item = $(item); + // 对获取的日期进行格式化处理 + function getDate() { + const str = item.find('.date').text(); + let date = ""; + if (language === "cn" || language === "tw") { + const patt = /[0-9]\d*/g; + let result; + while ((result = patt.exec(str)) !== null) { + date += result + '-'; + } + date = date.replace(/-$/g, ""); + } else if (language === "en") { + date = str.replace(/RELEASED/g, ""); + } + return date; + } + + return { + title: item.find('.ver').text(), + description: item.find('.logs').html(), + link: `https://${language}.eagle.cool/changelog`, + pubDate: new Date(getDate()).toUTCString(), + }; + }) + .get(), + }; +};