diff --git a/docs/anime.md b/docs/anime.md index 80a99d967..1922e6f0d 100644 --- a/docs/anime.md +++ b/docs/anime.md @@ -347,6 +347,12 @@ Sources +## lovelive-anime + +### Love Live 官网最新News + + + ## Mox.moe ### 首頁 diff --git a/docs/en/anime.md b/docs/en/anime.md index 1120f83f9..a43c09e62 100644 --- a/docs/en/anime.md +++ b/docs/en/anime.md @@ -56,6 +56,12 @@ When `posts` is selected as the value of the parameter **source**, the parameter +## lovelive-anime + +### Love Live! Official Website Latest NEWS + + + ## Touhougarakuta ### Articles diff --git a/lib/v2/lovelive-anime/maintainer.js b/lib/v2/lovelive-anime/maintainer.js new file mode 100644 index 000000000..4dc741ff7 --- /dev/null +++ b/lib/v2/lovelive-anime/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/news/:option?': ['axojhf'], +}; diff --git a/lib/v2/lovelive-anime/news.js b/lib/v2/lovelive-anime/news.js new file mode 100644 index 000000000..ec9c987e3 --- /dev/null +++ b/lib/v2/lovelive-anime/news.js @@ -0,0 +1,56 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const path = require('path'); +const { art } = require('@/utils/render'); +const renderDescription = (desc) => art(path.join(__dirname, 'templates/description.art'), desc); + +module.exports = async (ctx) => { + const rootUrl = 'https://www.lovelive-anime.jp/news/'; + + const response = await got(rootUrl); + + const $ = cheerio.load(response.data); + + const pageFace = $('div.c-card.p-colum__box') + .map((_, item) => { + item = $(item); + + return { + link: item.find('a.c-card__head').attr('href'), + pubDate: item.find('span.c-card__date').text(), + title: item.find('div.c-card__title').text(), + // description: `${item.find('div.c-card__title').text()}
` + description: renderDescription({ + title: item.find('div.c-card__title').text(), + imglink: item.find('a.c-card__head > div > figure > img').attr('src'), + }), + }; + }) + .get(); + + let items = pageFace; + + if (ctx.params.option === 'detail') { + items = await Promise.all( + pageFace.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResp = await got(item.link); + const $ = cheerio.load(detailResp.data); + + const content = $('div.p-page__detail.p-article'); + for (const v of content.find('img')) { + v.attribs.src = 'https://www.lovelive-anime.jp' + v.attribs.src; + } + item.description = content.html(); + return item; + }) + ) + ); + } + + ctx.state.data = { + title: 'lovelive official website news', + link: 'https://www.lovelive-anime.jp/news/', + item: items, + }; +}; diff --git a/lib/v2/lovelive-anime/radar.js b/lib/v2/lovelive-anime/radar.js new file mode 100644 index 000000000..fa57df0d3 --- /dev/null +++ b/lib/v2/lovelive-anime/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'lovelive-anime.jp': { + _name: 'Love Live 官网', + www: [ + { + title: '最新NEWS', + docs: 'https://docs.rsshub.app/anime.html#lovelive-anime', + source: ['/'], + target: '/lovelive-anime/news', + }, + ], + }, +}; diff --git a/lib/v2/lovelive-anime/router.js b/lib/v2/lovelive-anime/router.js new file mode 100644 index 000000000..c7bbc2e16 --- /dev/null +++ b/lib/v2/lovelive-anime/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/news/:option?', require('./news')); +}; diff --git a/lib/v2/lovelive-anime/templates/description.art b/lib/v2/lovelive-anime/templates/description.art new file mode 100644 index 000000000..6f85ee13f --- /dev/null +++ b/lib/v2/lovelive-anime/templates/description.art @@ -0,0 +1 @@ +{{title}}
\ No newline at end of file