diff --git a/docs/anime.md b/docs/anime.md index 68fc264e7..344a88acc 100644 --- a/docs/anime.md +++ b/docs/anime.md @@ -217,6 +217,10 @@ pageClass: routes +### Ci-en 创作者文章 + + + ## ebb.io ### ebb diff --git a/docs/en/anime.md b/docs/en/anime.md index 3c4ab7d71..af5ac93de 100644 --- a/docs/en/anime.md +++ b/docs/en/anime.md @@ -40,6 +40,10 @@ For more tags, please go to [Search torrent](https://bangumi.moe/search/index) +### Ci-en Creators' Article + + + ## Hanime.tv ### Recently updated diff --git a/lib/v2/dlsite/ci-en/article.js b/lib/v2/dlsite/ci-en/article.js new file mode 100644 index 000000000..1c33b1a9b --- /dev/null +++ b/lib/v2/dlsite/ci-en/article.js @@ -0,0 +1,64 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const timezone = require('@/utils/timezone'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const id = ctx.params.id ?? '7400'; + const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 10; + + const rootUrl = 'https://ci-en.dlsite.com'; + const currentUrl = `${rootUrl}/creator/${id}/article?mode=list`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + let items = $('.articleTitle a') + .slice(0, limit) + .toArray() + .map((item) => { + item = $(item); + + return { + title: item.text(), + link: item.attr('href'), + }; + }); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + + const content = cheerio.load(detailResponse.data); + + content('.article-title').remove(); + + content('.file-player-image').each(function () { + content(this).replaceWith(``); + }); + + item.description = content('article').html(); + item.pubDate = timezone(parseDate(content('.e-date').first().text()), +9); + item.category = content('.c-hashTagList-item') + .toArray() + .map((t) => content(t).text().split('#').pop().trim()); + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + }; +}; diff --git a/lib/v2/dlsite/maintainer.js b/lib/v2/dlsite/maintainer.js index 3c538f811..9a5f6de24 100644 --- a/lib/v2/dlsite/maintainer.js +++ b/lib/v2/dlsite/maintainer.js @@ -1,4 +1,5 @@ module.exports = { '/campaign/:type/:free?': ['cssxsh'], + '/ci-en/:id/article': ['nczitzk'], '/new/:type': ['cssxsh'], }; diff --git a/lib/v2/dlsite/radar.js b/lib/v2/dlsite/radar.js index 87c0f5018..c5dcd80dd 100644 --- a/lib/v2/dlsite/radar.js +++ b/lib/v2/dlsite/radar.js @@ -11,5 +11,13 @@ module.exports = { docs: 'https://docs.rsshub.app/anime.html#dlsite', }, ], + 'ci-en': [ + { + title: 'Ci-en 创作者文章', + docs: 'https://docs.rsshub.app/anime.html#dlsite', + source: ['/creator/:id/article/843558', '/'], + target: '/dlsite/ci-en/:id/article', + }, + ], }, }; diff --git a/lib/v2/dlsite/router.js b/lib/v2/dlsite/router.js index d8346a6a6..e655506ee 100644 --- a/lib/v2/dlsite/router.js +++ b/lib/v2/dlsite/router.js @@ -1,4 +1,5 @@ module.exports = function (router) { router.get('/campaign/:type/:free?', require('./campaign')); + router.get('/ci-en/:id/article', require('./ci-en/article')); router.get('/new/:type', require('./new')); };