From 0b4c6581c3400cdf445da40e48cfe1ad4d3781f5 Mon Sep 17 00:00:00 2001 From: vzz64 <120877801+vzz64@users.noreply.github.com> Date: Mon, 2 Jan 2023 21:01:34 +0800 Subject: [PATCH] feat(route): add dmzj news (#11538) --- docs/anime.md | 12 +++++++ lib/v2/dmzj/maintainer.js | 3 ++ lib/v2/dmzj/news.js | 26 +++++++++++++++ lib/v2/dmzj/radar.js | 67 +++++++++++++++++++++++++++++++++++++++ lib/v2/dmzj/router.js | 3 ++ 5 files changed, 111 insertions(+) create mode 100644 lib/v2/dmzj/maintainer.js create mode 100644 lib/v2/dmzj/news.js create mode 100644 lib/v2/dmzj/radar.js create mode 100644 lib/v2/dmzj/router.js diff --git a/docs/anime.md b/docs/anime.md index 635d377259..ea29b6ae0b 100644 --- a/docs/anime.md +++ b/docs/anime.md @@ -574,6 +574,18 @@ Sources +## 动漫之家 + +### 新闻站 + + + +| 漫画情报 | 轻小说情报 | 动漫周边 | 声优情报 | 音乐资讯 | 游戏资讯 | 美图欣赏 | 漫展情报 | 大杂烩 | +| ------------- | ------------------- | -------------- | --------------- | ----------- | ---------- | ------------- | -------------- | ------- | +| manhuaqingbao | qingxiaoshuoqingbao | manhuazhoubian | shengyouqingbao | yinyuezixun | youxizixun | meituxinshang | manzhanqingbao | dazahui | + + + ## 動畫瘋 ### 最後更新 diff --git a/lib/v2/dmzj/maintainer.js b/lib/v2/dmzj/maintainer.js new file mode 100644 index 0000000000..3210958dc2 --- /dev/null +++ b/lib/v2/dmzj/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/news/:category?': ['vzz64'], +}; diff --git a/lib/v2/dmzj/news.js b/lib/v2/dmzj/news.js new file mode 100644 index 0000000000..772f78bb17 --- /dev/null +++ b/lib/v2/dmzj/news.js @@ -0,0 +1,26 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +module.exports = async (ctx) => { + const url = `https://news.dmzj.com/${ctx.params.category || ''}`; + const $ = cheerio.load((await got(url)).data); + ctx.state.data = { + title: $('title').text(), + link: url, + item: $('.briefnews_con_li .li_img_de') + .map((_, item) => ({ + title: $(item).find('h3 a').text(), + link: $(item).find('h3 a').attr('href'), + author: $(item).find('.head_con_p_o span:nth-child(3)').text().split(':')[1], + pubDate: timezone(parseDate($(item).find('.head_con_p_o span').first().text(), 'YYYY-MM-DD HH:mm'), +8), + description: $(item).find('p.com_about').text(), + category: $(item) + .find('.u_comfoot a .bqwarp') + .map((_, item) => $(item).text()) + .get(), + })) + .get(), + }; +}; diff --git a/lib/v2/dmzj/radar.js b/lib/v2/dmzj/radar.js new file mode 100644 index 0000000000..3542e51181 --- /dev/null +++ b/lib/v2/dmzj/radar.js @@ -0,0 +1,67 @@ +module.exports = { + 'dmzj.com': { + _name: '动漫之家', + news: [ + { + title: '宅新闻', + docs: 'https://docs.rsshub.app/anime.html#dong-man-zhi-jia', + source: '/', + target: '/dmzj/news', + }, + { + title: '漫画情报', + docs: 'https://docs.rsshub.app/anime.html#dong-man-zhi-jia', + source: '/manhuaqingbao', + target: '/dmzj/news/manhuaqingbao', + }, + { + title: '轻小说情报', + docs: 'https://docs.rsshub.app/anime.html#dong-man-zhi-jia', + source: '/qingxiaoshuoqingbao', + target: '/dmzj/news/qingxiaoshuoqingbao', + }, + { + title: '动漫周边', + docs: 'https://docs.rsshub.app/anime.html#dong-man-zhi-jia', + source: '/manhuazhoubian', + target: '/dmzj/news/manhuazhoubian', + }, + { + title: '声优情报', + docs: 'https://docs.rsshub.app/anime.html#dong-man-zhi-jia', + source: '/shengyouqingbao', + target: '/dmzj/news/shengyouqingbao', + }, + { + title: '音乐资讯', + docs: 'https://docs.rsshub.app/anime.html#dong-man-zhi-jia', + source: '/yinyuezixun', + target: '/dmzj/news/yinyuezixun', + }, + { + title: '游戏资讯', + docs: 'https://docs.rsshub.app/anime.html#dong-man-zhi-jia', + source: '/youxizixun', + target: '/dmzj/news/youxizixun', + }, + { + title: '美图欣赏', + docs: 'https://docs.rsshub.app/anime.html#dong-man-zhi-jia', + source: '/meituxinshang', + target: '/dmzj/news/meituxinshang', + }, + { + title: '漫展情报', + docs: 'https://docs.rsshub.app/anime.html#dong-man-zhi-jia', + source: '/manzhanqingbao', + target: '/dmzj/news/manzhanqingbao', + }, + { + title: '大杂烩', + docs: 'https://docs.rsshub.app/anime.html#dong-man-zhi-jia', + source: '/dazahui', + target: '/dmzj/news/dazahui', + }, + ], + }, +}; diff --git a/lib/v2/dmzj/router.js b/lib/v2/dmzj/router.js new file mode 100644 index 0000000000..1b7e394502 --- /dev/null +++ b/lib/v2/dmzj/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/news/:category?', require('./news')); +};