feat(route): add 4k世界 (#12654)
This commit is contained in:
parent
c250039b1e
commit
aaef7c73ed
|
|
@ -144,6 +144,22 @@ pageClass: routes
|
|||
|
||||
</Route>
|
||||
|
||||
## 4k 世界
|
||||
|
||||
### 分类
|
||||
|
||||
<Route author="nczitzk" example="/4ksj/forum" path="/4ksj/forum/:id?" :paramsDesc="['分类 id,默认为最新4K电影']">
|
||||
|
||||
::: tip 提示
|
||||
|
||||
若订阅 [最新4K电影](https://www.4ksj.com/forum-2-1.html),网址为 <https://www.4ksj.com/forum-2-1.html>。截取 `https://www.4ksj.com/forum-` 到末尾 `.html` 的部分 `2-1` 作为参数,此时路由为 [`/4ksj/forum/2-1`](https://rsshub.app/4ksj/forum/2-1)。
|
||||
|
||||
若订阅子分类 [Dolby Vision纪录片4K电影](https://www.4ksj.com/forum-4kdianying-s7-dianyingbiaozhun-3-dytypes-9-1.html),网址为 <https://www.4ksj.com/forum-4kdianying-s7-dianyingbiaozhun-3-dytypes-9-1.html>。截取 `https://www.4ksj.com/forum-` 到末尾 `.html` 的部分 `4kdianying-s7-dianyingbiaozhun-3-dytypes-9-1` 作为参数,此时路由为 [`/4ksj/forum/4kdianying-s7-dianyingbiaozhun-3-dytypes-9-1`](https://rsshub.app/4ksj/forum/4kdianying-s7-dianyingbiaozhun-3-dytypes-9-1)。
|
||||
|
||||
:::
|
||||
|
||||
</Route>
|
||||
|
||||
## 60-Second Science - Scientific American
|
||||
|
||||
<Route author="emdoe" example="/60s-science" path="/60s-science"/>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,128 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
const iconv = require('iconv-lite');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id ?? '2-1';
|
||||
const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 25;
|
||||
|
||||
const rootUrl = 'https://www.4ksj.com';
|
||||
const currentUrl = `${rootUrl}/forum-${id}.html`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
responseType: 'buffer',
|
||||
});
|
||||
|
||||
const $ = cheerio.load(iconv.decode(response.data, 'gbk'));
|
||||
|
||||
let items = $('div.nex_cmo_piv a')
|
||||
.slice(0, limit)
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
link: new URL(item.attr('href'), rootUrl).href,
|
||||
};
|
||||
});
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
responseType: 'buffer',
|
||||
});
|
||||
|
||||
const content = cheerio.load(iconv.decode(detailResponse.data, 'gbk'));
|
||||
|
||||
const details = {};
|
||||
const links = {};
|
||||
|
||||
content('.nex_drama_Details')
|
||||
.find('em')
|
||||
.each(function () {
|
||||
const detail = content(this).parent();
|
||||
const key = content(this).text();
|
||||
const value = detail
|
||||
.text()
|
||||
.replace(key, '')
|
||||
.replace(/ /g, '')
|
||||
.trim();
|
||||
if (value) {
|
||||
details[key.replace(/:|\s/g, '')] = value;
|
||||
}
|
||||
});
|
||||
|
||||
content('.nex_netdrivelink, .nex_xunleilink').each(function () {
|
||||
links[content(this).text()] = content(this).next().html();
|
||||
});
|
||||
|
||||
content('.nex_drama_intros em').first().remove();
|
||||
content('.nex_thread_author_name em').first().remove();
|
||||
content('.xg1 a').remove();
|
||||
|
||||
const matches = content('.nex_drama_Top em')
|
||||
.text()
|
||||
.match(/(.*?)(豆瓣:(.*?))/);
|
||||
|
||||
item.title = content('.nex_drama_Top h5').text();
|
||||
item.author = content('.nex_thread_author_name').text();
|
||||
item.pubDate = timezone(
|
||||
parseDate(
|
||||
content('.nex_ifpost em')
|
||||
.text()
|
||||
.replace(/发表于/g, '')
|
||||
.trim(),
|
||||
'YYYY-M-D HH:mm'
|
||||
),
|
||||
+8
|
||||
);
|
||||
item.category = Object.values(details).map((d) => d.replace(/ /g, '').trim());
|
||||
item.description = art(path.join(__dirname, 'templates/description.art'), {
|
||||
picture: content('.nex_drama_pic')
|
||||
.html()
|
||||
.match(/background:url\((.*?)\)/)[1],
|
||||
name: item.title,
|
||||
time: matches[1],
|
||||
score: matches[2],
|
||||
details,
|
||||
detailKeys: Object.keys(details),
|
||||
intro: content('.nex_drama_intros').html(),
|
||||
links,
|
||||
linkKeys: Object.keys(links),
|
||||
bt: content('.t_f').html(),
|
||||
info: content('.nex_drama_sums').html(),
|
||||
});
|
||||
|
||||
const magnets = content('.t_f a')
|
||||
.toArray()
|
||||
.filter((a) => /^magnet/.test(content(a).attr('href')))
|
||||
.map((a) => content(a).attr('href'));
|
||||
|
||||
if (magnets.length > 0) {
|
||||
item.enclosure_url = magnets[0];
|
||||
item.enclosure_type = 'application/x-bittorrent';
|
||||
}
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `4k世界 - ${$('#fontsearch ul.cl li.a')
|
||||
.toArray()
|
||||
.map((a) => $(a).text())
|
||||
.join('+')}`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/forum/:id?': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'4ksj.com': {
|
||||
_name: '4k 世界',
|
||||
'.': [
|
||||
{
|
||||
title: '分类',
|
||||
docs: 'https://docs.rsshub.app/multimedia.html#4k-shi-jie-fen-lei',
|
||||
source: ['/forum-2-1.html', '/'],
|
||||
target: (params, url) => `/4ksj/forum/${new URL(url).href.match(/\/forum-([\w-]+)\.html/)[1]}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/forum/:id?', require('./forum'));
|
||||
};
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
{{ if picture }}
|
||||
<img src="{{ picture }}">
|
||||
{{ /if }}
|
||||
|
||||
{{ if details }}
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>片名</th>
|
||||
<td>{{ name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>时间</th>
|
||||
<td>{{ time }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>豆瓣评分</th>
|
||||
<td>{{ score }}</td>
|
||||
</tr>
|
||||
{{ each detailKeys detail }}
|
||||
<tr>
|
||||
<th>{{ detail }}</th>
|
||||
<td>{{@ details[detail] }}</td>
|
||||
</tr>
|
||||
{{ /each }}
|
||||
</tbody>
|
||||
</table>
|
||||
{{ /if }}
|
||||
|
||||
<h1>简介</h1>
|
||||
{{@ intro }}
|
||||
<br>
|
||||
|
||||
<h1>网盘下载</h1>
|
||||
{{ if links }}
|
||||
<table>
|
||||
<tbody>
|
||||
{{ each linkKeys link }}
|
||||
<tr>
|
||||
<th>{{ link }}</th>
|
||||
<td>{{@ links[link] }}</td>
|
||||
</tr>
|
||||
{{ /each }}
|
||||
</tbody>
|
||||
</table>
|
||||
{{ /if }}
|
||||
<br>
|
||||
|
||||
<h1>BT种子 / 磁力链下载</h1>
|
||||
{{@ bt }}
|
||||
<br>
|
||||
|
||||
<h1>影片信息</h1>
|
||||
{{ if info }}
|
||||
{{@ info }}
|
||||
{{ /if }}
|
||||
Loading…
Reference in New Issue