mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat: add anki changes (#5799)
Co-authored-by: Henry Wang <hi@henry.wang>
This commit is contained in:
@@ -4,6 +4,12 @@ pageClass: routes
|
||||
|
||||
# Application Updates
|
||||
|
||||
## Anki
|
||||
|
||||
### Changes
|
||||
|
||||
<Route author="nczitzk" example="/anki/changes" path="/anki/changes"/>
|
||||
|
||||
## Apkpure
|
||||
|
||||
### Versions
|
||||
|
||||
@@ -14,6 +14,12 @@ pageClass: routes
|
||||
|
||||
</Route>
|
||||
|
||||
## Anki
|
||||
|
||||
### Changes
|
||||
|
||||
<Route author="nczitzk" example="/anki/changes" path="/anki/changes"/>
|
||||
|
||||
## Apkpure
|
||||
|
||||
### Versions
|
||||
|
||||
@@ -3260,6 +3260,9 @@ router.get('/appsales/:caty?/:time?', require('./routes/appsales/index'));
|
||||
// CGTN
|
||||
router.get('/cgtn/top', require('./routes/cgtn/top'));
|
||||
|
||||
// Anki
|
||||
router.get('/anki/changes', require('./routes/anki/changes'));
|
||||
|
||||
// ABC News
|
||||
router.get('/abc/:site?', require('./routes/abc/index.js'));
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const md = require('markdown-it')({
|
||||
html: true,
|
||||
});
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://changes.ankiweb.net';
|
||||
const currentUrl = `${rootUrl}/README.md`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const html = md.render(response.data.replace(/# Changes in/g, '## Changes in').replace(/### Changes in/g, '## Changes in'));
|
||||
const $ = cheerio.load(html.replace(/<h2>/g, '</div><div><h2>'));
|
||||
|
||||
const items = $('div')
|
||||
.slice(0, 20)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const h2 = item.find('h2');
|
||||
const match = item.find('p').text().match('Released (.*).');
|
||||
h2.remove();
|
||||
return {
|
||||
title: h2.text(),
|
||||
description: item.html(),
|
||||
link: `${rootUrl}/#/?id=changes-in-${h2.text().toLowerCase().split(' ').join('-').replace(/\./g, '')}`,
|
||||
pubDate: match ? new Date(match[1].split(',')[0] + ' GMT+8').toUTCString() : '',
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Changes - Anki',
|
||||
link: rootUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user