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
This commit is contained in:
Fatpandac 2023-01-27 14:28:55 +08:00 committed by GitHub
parent e33c617acb
commit 53fb40e9d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 91 additions and 56 deletions

View File

@ -276,8 +276,7 @@ pageClass: routes
### 产品打折信息
<Route author="cssxsh" example="/dlsite/campaign/home" path="/dlsite/campaign/:type/:free?" :paramsDesc="['类型,同上表', '只看免费,任意值开启,为空关闭']">
</Route>
<Route author="cssxsh" example="/dlsite/campaign/home" path="/dlsite/campaign/:type/:free?" :paramsDesc="['类型,同上表', '只看免费,任意值开启,为空关闭']"/>
## ebb.io

View File

@ -24,6 +24,22 @@ For more tags, please go to [Search torrent](https://bangumi.moe/search/index)
<RouteEn author="stjohnjohnson" example="/comicskingdom/pardon-my-planet" path="/comicskingdom/:name" :paramsDesc="['URL path of the strip on comicskingdom.com']" />
## DLsite
### Current Release
<RouteEn author="cssxsh" example="/dlsite/new/home" path="/dlsite/new/:type" :paramsDesc="['Type, see table below']">
| Doujin | Comics | PC Games | Doujin (R18) | Adult Comics | H Games | Otome | BL |
| ---- | ----- | ---- | -------- | -------- | ----- | ----- | -- |
| home | comic | soft | maniax | books | pro | girls | bl |
</RouteEn>
### Discounted Works
<RouteEn author="cssxsh" example="/dlsite/campaign/home" path="/dlsite/campaign/:type/:free?" :paramsDesc="['Type, see table above', 'Free only, empty means false, other value means true']"/>
## Hanime.tv
### Recently updated

View File

@ -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'));

View File

@ -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,

View File

@ -0,0 +1,4 @@
module.exports = {
'/campaign/:type/:free?': ['cssxsh'],
'/new/:type': ['cssxsh'],
};

View File

@ -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,

15
lib/v2/dlsite/radar.js Normal file
View File

@ -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',
},
],
},
};

4
lib/v2/dlsite/router.js Normal file
View File

@ -0,0 +1,4 @@
module.exports = function (router) {
router.get('/campaign/:type/:free?', require('./campaign'));
router.get('/new/:type', require('./new'));
};