From 53fb40e9d49168c363976d82aeee985c49e37003 Mon Sep 17 00:00:00 2001 From: Fatpandac Date: Fri, 27 Jan 2023 14:28:55 +0800 Subject: [PATCH] fix(route): fix date err and refactor to v2 (#11705) * fix(route): fix date err and refactor to v2 * docs: add en docs * fix: typo --- docs/anime.md | 3 +- docs/en/anime.md | 16 ++++++++ lib/router.js | 4 +- lib/{routes => v2}/dlsite/campaign.js | 46 +++++++++++----------- lib/v2/dlsite/maintainer.js | 4 ++ lib/{routes => v2}/dlsite/new.js | 55 +++++++++++++-------------- lib/v2/dlsite/radar.js | 15 ++++++++ lib/v2/dlsite/router.js | 4 ++ 8 files changed, 91 insertions(+), 56 deletions(-) rename lib/{routes => v2}/dlsite/campaign.js (82%) create mode 100644 lib/v2/dlsite/maintainer.js rename lib/{routes => v2}/dlsite/new.js (64%) create mode 100644 lib/v2/dlsite/radar.js create mode 100644 lib/v2/dlsite/router.js diff --git a/docs/anime.md b/docs/anime.md index 3a75aa7ec..8e159cb00 100644 --- a/docs/anime.md +++ b/docs/anime.md @@ -276,8 +276,7 @@ pageClass: routes ### 产品打折信息 - - + ## ebb.io diff --git a/docs/en/anime.md b/docs/en/anime.md index 3181e88a7..765d0f51e 100644 --- a/docs/en/anime.md +++ b/docs/en/anime.md @@ -24,6 +24,22 @@ For more tags, please go to [Search torrent](https://bangumi.moe/search/index) +## DLsite + +### Current Release + + + +| Doujin | Comics | PC Games | Doujin (R18) | Adult Comics | H Games | Otome | BL | +| ---- | ----- | ---- | -------- | -------- | ----- | ----- | -- | +| home | comic | soft | maniax | books | pro | girls | bl | + + + +### Discounted Works + + + ## Hanime.tv ### Recently updated diff --git a/lib/router.js b/lib/router.js index e3065af34..5da0c787d 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2187,8 +2187,8 @@ router.get('/cell/cover', lazyloadRouteHandler('./routes/cell/cover')); // router.get('/sciencemag/early/science', lazyloadRouteHandler('./routes/sciencemag/early')); // dlsite -router.get('/dlsite/new/:type', lazyloadRouteHandler('./routes/dlsite/new')); -router.get('/dlsite/campaign/:type/:free?', lazyloadRouteHandler('./routes/dlsite/campaign')); +// router.get('/dlsite/new/:type', lazyloadRouteHandler('./routes/dlsite/new')); +// router.get('/dlsite/campaign/:type/:free?', lazyloadRouteHandler('./routes/dlsite/campaign')); // mcbbs router.get('/mcbbs/forum/:type', lazyloadRouteHandler('./routes/mcbbs/forum')); diff --git a/lib/routes/dlsite/campaign.js b/lib/v2/dlsite/campaign.js similarity index 82% rename from lib/routes/dlsite/campaign.js rename to lib/v2/dlsite/campaign.js index 68f4ed6b1..c8bc08593 100644 --- a/lib/routes/dlsite/campaign.js +++ b/lib/v2/dlsite/campaign.js @@ -139,31 +139,29 @@ module.exports = async (ctx) => { const title = `${info.name} | 割引中の作品`; const description = $('meta[name="description"]').attr('content'); const list = $('tr[class]', '.n_worklist'); - const item = list - .map((index, element) => { - const title = $('.work_name', element).text(); - const link = $('.work_name > a', element).attr('href'); - // 使链接 - $('a', element).each((index, element) => { - $(element).attr('target', '_blank'); - }); - const description = $(element).html(); - const arr = $('.search_tag', element); - const category = $('a', arr) - .map((index, a) => $(a).text()) - .get(); - const author = $('.maker_name', element).text(); + const item = list.toArray().map((element) => { + const title = $('.work_name', element).text(); + const link = $('.work_name > a', element).attr('href'); + // 使链接 + $('a', element).each((_index, element) => { + $(element).attr('target', '_blank'); + }); + const description = $(element).html(); + const arr = $('.search_tag', element); + const category = $('a', arr) + .toArray() + .map((a) => $(a).text()); + const author = $('.maker_name', element).text(); - const signle = { - title, - link, - description, - category, - author, - }; - return signle; - }) - .get(); + const signle = { + title, + link, + description, + category, + author, + }; + return signle; + }); ctx.state.data = { title, diff --git a/lib/v2/dlsite/maintainer.js b/lib/v2/dlsite/maintainer.js new file mode 100644 index 000000000..3c538f811 --- /dev/null +++ b/lib/v2/dlsite/maintainer.js @@ -0,0 +1,4 @@ +module.exports = { + '/campaign/:type/:free?': ['cssxsh'], + '/new/:type': ['cssxsh'], +}; diff --git a/lib/routes/dlsite/new.js b/lib/v2/dlsite/new.js similarity index 64% rename from lib/routes/dlsite/new.js rename to lib/v2/dlsite/new.js index 44df6a112..dd9f7dc7f 100644 --- a/lib/routes/dlsite/new.js +++ b/lib/v2/dlsite/new.js @@ -1,5 +1,6 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); const host = 'https://www.dlsite.com'; const infos = { @@ -69,35 +70,33 @@ module.exports = async (ctx) => { const list = $('.n_worklist_item'); const dateText = $('.work_update') .text() - .replace(/(年 |月)/g, '-') - .substring(0, 10); - const pubDate = new Date(`${dateText} GMT+0900`).toUTCString(); - const item = list - .map((index, element) => { - const title = $('.work_name', element).text(); - const link = $('.work_name > a', element).attr('href'); - // 使链接 - $('a', element).each((index, element) => { - $(element).attr('target', '_blank'); - }); - const description = $(element).html(); - const arr = $('.search_tag', element); - const category = $('a', arr) - .map((index, a) => $(a).text()) - .get(); - const author = $('.maker_name', element).text(); + .trim() + .replace(/(.*)/g, ''); + const pubDate = parseDate(dateText, 'YYYY年M月D日'); + const item = list.toArray().map((element) => { + const title = $('.work_name', element).text(); + const link = $('.work_name > a', element).attr('href'); + // 使链接 + $('a', element).each((_index, element) => { + $(element).attr('target', '_blank'); + }); + const description = $(element).html(); + const arr = $('.search_tag', element); + const category = $('a', arr) + .toArray() + .map((a) => $(a).text()); + const author = $('.maker_name', element).text(); - const signle = { - title, - link, - description, - category, - author, - pubDate, - }; - return signle; - }) - .get(); + const signle = { + title, + link, + description, + category, + author, + pubDate, + }; + return signle; + }); ctx.state.data = { title, diff --git a/lib/v2/dlsite/radar.js b/lib/v2/dlsite/radar.js new file mode 100644 index 000000000..87c0f5018 --- /dev/null +++ b/lib/v2/dlsite/radar.js @@ -0,0 +1,15 @@ +module.exports = { + 'dlsite.com': { + _name: 'DLsite', + '.': [ + { + title: '当前日期发售的新产品', + docs: 'https://docs.rsshub.app/anime.html#dlsite', + }, + { + title: '产品打折信息', + docs: 'https://docs.rsshub.app/anime.html#dlsite', + }, + ], + }, +}; diff --git a/lib/v2/dlsite/router.js b/lib/v2/dlsite/router.js new file mode 100644 index 000000000..d8346a6a6 --- /dev/null +++ b/lib/v2/dlsite/router.js @@ -0,0 +1,4 @@ +module.exports = function (router) { + router.get('/campaign/:type/:free?', require('./campaign')); + router.get('/new/:type', require('./new')); +};