diff --git a/lib/router.js b/lib/router.js index daa24dde37..b5676b91dd 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2681,9 +2681,6 @@ router.get('/krankenkassen', lazyloadRouteHandler('./routes/krankenkassen')); // 桂林航天工业学院 router.get('/guat/news/:type?', lazyloadRouteHandler('./routes/guat/news')); -// LearnKu -router.get('/learnku/:community/:category?', lazyloadRouteHandler('./routes/learnku/topic')); - // NEEA router.get('/neea/:type', lazyloadRouteHandler('./routes/neea')); diff --git a/lib/routes/learnku/topic.js b/lib/routes/learnku/topic.js deleted file mode 100644 index cf3a75d0d7..0000000000 --- a/lib/routes/learnku/topic.js +++ /dev/null @@ -1,53 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); - -module.exports = async (ctx) => { - const community = ctx.params.community; - const category = ctx.params.category || ''; - - let url = `https://learnku.com/${community}`; - if (category !== '') { - url = `https://learnku.com/${community}/c/${category}`; - } - - const response = await got({ - method: 'get', - url, - }); - - const data = response.data; - const $ = cheerio.load(data); - const list = $('.simple-topic').get(); - const title = $('.sidebar .community-details .header span').text(); - $('.sidebar .community-details .main div div a').remove(); - const description = $('.sidebar .community-details .main div div').text(); - const categoryTitle = new Map([ - ['translations', { name: '翻译' }], - ['jobs', { name: '招聘' }], - ['qa', { name: '问答' }], - ['links', { name: '链接' }], - ['', { name: '最新' }], - ]); - - ctx.state.data = { - title: `LearnKu - ${title} - ${categoryTitle.get(category).name}`, - link: url, - description, - item: list - .map((item) => { - const $ = cheerio.load(item); - const categoryName = $('.category-name').text().trim(); - if (['置顶', '广告'].includes(categoryName)) { - return ''; - } - $('.topic-title i').remove(); - return { - title: $('.topic-title').text().trim(), - category: categoryName, - link: $('.topic-title-wrap').attr('href'), - pubDate: new Date($('.timeago').attr('title')).toUTCString(), - }; - }) - .filter((item) => item !== ''), - }; -}; diff --git a/lib/v2/learnku/maintainer.js b/lib/v2/learnku/maintainer.js new file mode 100644 index 0000000000..ae7fe1ee57 --- /dev/null +++ b/lib/v2/learnku/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:community/:category?': ['kayw-geek'], +}; diff --git a/lib/v2/learnku/radar.js b/lib/v2/learnku/radar.js new file mode 100644 index 0000000000..a2965ad4fa --- /dev/null +++ b/lib/v2/learnku/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'learnku.com': { + _name: 'Learn Ku 社区', + '.': [ + { + title: '分区', + docs: 'https://docs.rsshub.app/bbs.html#learnku', + source: ['/:community'], + target: '/learnku/:community', + }, + ], + }, +}; diff --git a/lib/v2/learnku/router.js b/lib/v2/learnku/router.js new file mode 100644 index 0000000000..1c4ed102bd --- /dev/null +++ b/lib/v2/learnku/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/:community/:category?', require('./topic.js')); +}; diff --git a/lib/v2/learnku/templates/topic.art b/lib/v2/learnku/templates/topic.art new file mode 100644 index 0000000000..0dd3dce470 --- /dev/null +++ b/lib/v2/learnku/templates/topic.art @@ -0,0 +1,14 @@ +