feat: add 深影译站首页 & 剧集 (#6833)
This commit is contained in:
parent
6f339909ec
commit
2913df9d32
|
|
@ -861,6 +861,20 @@ pageClass: routes
|
|||
|
||||
## 深影译站
|
||||
|
||||
### 首页
|
||||
|
||||
<Route author="nczitzk" example="/shinybbs" path="/shinybbs" />
|
||||
|
||||
### 剧集类型
|
||||
|
||||
<Route author="nczitzk" example="/shinybbs/62" path="/shinybbs/:id?" :paramsDesc="['类型 id,见下表']">
|
||||
|
||||
| 英美剧 | 日韩剧 | 小语种 |
|
||||
| ------ | ------ | ------ |
|
||||
| 62 | 140 | 2 |
|
||||
|
||||
</Route>
|
||||
|
||||
### 最新作品
|
||||
|
||||
<Route author="nczitzk" example="/shinybbs/latest" path="/shinybbs/latest" />
|
||||
|
|
|
|||
|
|
@ -3910,6 +3910,7 @@ router.get('/tingshen', require('./routes/tingshen/tingshen'));
|
|||
router.get('/gov/mohrss/sbjm/:category?', require('./routes/gov/mohrss/sbjm'));
|
||||
|
||||
// 深影译站
|
||||
router.get('/shinybbs/:id?', require('./routes/shinybbs/index'));
|
||||
router.get('/shinybbs/latest', require('./routes/shinybbs/latest'));
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id || '';
|
||||
|
||||
const rootUrl = 'https://sub.shinybbs.vip';
|
||||
const currentUrl = `${rootUrl}/?page_id=${id}`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.elementor-button-link, .kb-gallery-item-link')
|
||||
.slice(0, 10)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
link: item.attr('href'),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
content('.elementor-section').last().remove();
|
||||
content('.elementor-section').last().remove();
|
||||
|
||||
content('.elementor-tabs-wrapper').remove();
|
||||
|
||||
item.title = content('.post-title').text();
|
||||
item.description = content('.elementor-inner, .post-content').html();
|
||||
item.pubDate = new Date(content('.post-date').text().replace(/年|月/g, '-').replace('日', '')).toUTCString();
|
||||
|
||||
item.enclosure_type = 'application/x-bittorrent';
|
||||
|
||||
const enclosureUrl = content('.elementor-tab-content a').last().attr('href');
|
||||
|
||||
item.enclosure_url = enclosureUrl ? enclosureUrl.replace('http://magnet', 'magnet') : '';
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue