feat(route): add DLsite Ci-en Creators' Article (#12336)

This commit is contained in:
Ethan Shen
2023-04-17 20:45:38 +08:00
committed by GitHub
parent 7c94578a34
commit f50f5fe402
6 changed files with 82 additions and 0 deletions
+4
View File
@@ -217,6 +217,10 @@ pageClass: routes
<Route author="cssxsh" example="/dlsite/campaign/home" path="/dlsite/campaign/:type/:free?" :paramsDesc="['类型,同上表', '只看免费,任意值开启,为空关闭']"/>
### Ci-en 创作者文章
<Route author="nczitzk" example="/dlsite/ci-en/:id/article" path="/dlsite/ci-en/7400/article" :paramsDesc="['创作者 id,可在对应创作者页 URL 中找到']"/>
## ebb.io
### ebb
+4
View File
@@ -40,6 +40,10 @@ For more tags, please go to [Search torrent](https://bangumi.moe/search/index)
<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']"/>
### Ci-en Creators' Article
<RouteEn author="nczitzk" example="/dlsite/ci-en/:id/article" path="/dlsite/ci-en/7400/article" :paramsDesc="['Creator id, can be found in URL']"/>
## Hanime.tv
### Recently updated
+64
View File
@@ -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(`<img src="${content(this).attr('data-actual')}">`);
});
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,
};
};
+1
View File
@@ -1,4 +1,5 @@
module.exports = {
'/campaign/:type/:free?': ['cssxsh'],
'/ci-en/:id/article': ['nczitzk'],
'/new/:type': ['cssxsh'],
};
+8
View File
@@ -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',
},
],
},
};
+1
View File
@@ -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'));
};