fix(route): 4k世界 (#14859)
* style: auto format * fix(route): 4k世界 --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
github-actions[bot]
parent
6c8bb2ff9b
commit
e0beaad687
+130
-77
@@ -12,42 +12,36 @@ import * as path from 'node:path';
|
||||
import iconv from 'iconv-lite';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/forum/:id?',
|
||||
categories: ['multimedia'],
|
||||
example: '/4ksj/forum',
|
||||
parameters: { id: '分类 id,默认为最新4K电影' },
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: false,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
path: '/:id?',
|
||||
name: '分类',
|
||||
url: '4ksj.com',
|
||||
maintainers: ['nczitzk'],
|
||||
handler,
|
||||
example: '/4ksj/4k-uhd-1',
|
||||
parameters: { id: '分类 id,默认为最新4K电影' },
|
||||
description: `:::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)。
|
||||
若订阅 [最新 4K 电影](https://www.4ksj.com/4k-uhd-1.html),网址为 \`https://www.4ksj.com/4k-uhd-1.html\`。截取 \`https://www.4ksj.com/\` 到末尾 \`.html\` 的部分 \`4k-uhd-1\` 作为参数,此时路由为 [\`/4ksj/4k-uhd-1\`](https://rsshub.app/4ksj/4k-uhd-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)。
|
||||
若订阅子分类 [Dolby Vision 动作 4K 电影](https://www.4ksj.com/4k-uhd-s7-display-3-dytypes-1-1.html),网址为 \`https://www.4ksj.com/4k-uhd-s7-display-3-dytypes-1-1.html\`。截取 \`https://www.4ksj.com/forum-\` 到末尾 \`.html\` 的部分 \`4kdianying-s7-dianyingbiaozhun-3-dytypes-9-1\` 作为参数,此时路由为 [\`/4ksj/4k-uhd-s7-display-3-dytypes-1-1\`](https://rsshub.app/4ksj/4k-uhd-s7-display-3-dytypes-1-1)。
|
||||
:::`,
|
||||
categories: ['multimedia'],
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const id = ctx.req.param('id') ?? '2-1';
|
||||
const { id = '4k-uhd-1' } = ctx.req.param();
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 25;
|
||||
|
||||
const rootUrl = 'https://www.4ksj.com';
|
||||
const currentUrl = `${rootUrl}/forum-${id}.html`;
|
||||
const currentUrl = new URL(`${id}.html`, rootUrl).href;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
const { data: response } = await got(currentUrl, {
|
||||
responseType: 'buffer',
|
||||
});
|
||||
|
||||
const $ = load(iconv.decode(response.data, 'gbk'));
|
||||
const $ = load(iconv.decode(response, 'gbk'));
|
||||
|
||||
const language = 'zh';
|
||||
const image = $('div.nexlogo img').prop('src');
|
||||
|
||||
let items = $('div.nex_cmo_piv a')
|
||||
.slice(0, limit)
|
||||
@@ -56,76 +50,128 @@ async function handler(ctx) {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
link: new URL(item.attr('href'), rootUrl).href,
|
||||
link: new URL(item.prop('href'), rootUrl).href,
|
||||
};
|
||||
});
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
const { data: detailResponse } = await got(item.link, {
|
||||
responseType: 'buffer',
|
||||
});
|
||||
|
||||
const content = load(iconv.decode(detailResponse.data, 'gbk'));
|
||||
const $$ = load(iconv.decode(detailResponse, 'gbk'));
|
||||
|
||||
const details = {};
|
||||
const links = {};
|
||||
$$('div.nex_drama_intros em').first().remove();
|
||||
$$('strong font').each((_, el) => {
|
||||
el = $$(el);
|
||||
|
||||
content('.nex_drama_Details')
|
||||
.find('em')
|
||||
.each(function () {
|
||||
const detail = content(this).parent();
|
||||
const key = content(this).text();
|
||||
const value = detail.text().replace(key, '').replaceAll(' ', '').trim();
|
||||
if (value) {
|
||||
details[key.replaceAll(/:|\s/g, '')] = value;
|
||||
}
|
||||
});
|
||||
|
||||
content('.nex_netdrivelink, .nex_xunleilink').each(function () {
|
||||
links[content(this).text()] = content(this).next().html();
|
||||
el.parent().remove();
|
||||
});
|
||||
|
||||
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().replaceAll('发表于', '').trim(), 'YYYY-M-D HH:mm'), +8);
|
||||
item.category = Object.values(details).map((d) => d.replaceAll(' ', '').trim());
|
||||
item.description = art(path.join(__dirname, 'templates/description.art'), {
|
||||
picture: content('.nex_drama_pic')
|
||||
const title = $$('div.nex_drama_Top h5').text();
|
||||
const description = $$('div.nex_drama_intros').html();
|
||||
const picture =
|
||||
$$('div.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(),
|
||||
});
|
||||
.match(/background:url\((.*?)\)/)?.[1] ?? '';
|
||||
|
||||
const magnets = content('.t_f a')
|
||||
const details = $$('li.nex_drama_Detail_li, li.nex_drama_Detail_lis dd')
|
||||
.toArray()
|
||||
.filter((a) => content(a).attr('href').startsWith('magnet'))
|
||||
.map((a) => content(a).attr('href'));
|
||||
.map((li) => {
|
||||
li = $$(li);
|
||||
|
||||
if (magnets.length > 0) {
|
||||
item.enclosure_url = magnets[0];
|
||||
item.enclosure_type = 'application/x-bittorrent';
|
||||
}
|
||||
const key = li.find('em').text().replaceAll(/:|\s/g, '');
|
||||
const value = li.find('span').length === 0 ? li.contents().last().text().trim() : li.find('span').text().trim();
|
||||
|
||||
return { [key]: value };
|
||||
})
|
||||
.reduce(
|
||||
(obj, item) => ({
|
||||
...obj,
|
||||
...item,
|
||||
}),
|
||||
{}
|
||||
);
|
||||
|
||||
const links =
|
||||
$$('td.t_f ignore_js_op').length === 0
|
||||
? $$('td.t_f strong')
|
||||
.toArray()
|
||||
.map((l) => {
|
||||
l = $$(l);
|
||||
|
||||
const title = l.contents().first().text();
|
||||
const link = l.next().prop('href') ?? l.nextUntil('a').next().prop('href');
|
||||
|
||||
item.enclosure_url = item.enclosure_url ?? link;
|
||||
item.enclosure_type = item.enclosure_type ?? 'application/x-bittorrent';
|
||||
item.enclosure_title = item.enclosure_title ?? title;
|
||||
|
||||
return {
|
||||
title,
|
||||
tags: l
|
||||
.contents()
|
||||
.last()
|
||||
.text()
|
||||
.match(/【(.*?)】/g),
|
||||
link,
|
||||
};
|
||||
})
|
||||
: $$('div.newfujian')
|
||||
.toArray()
|
||||
.map((l) => {
|
||||
l = $$(l);
|
||||
|
||||
return {
|
||||
title: l.find('p.filename').prop('title') || l.find('p.filename').text(),
|
||||
tags: l
|
||||
.find('div.fileaq')
|
||||
.text()
|
||||
.match(/【(.*?)】/g),
|
||||
link: l.find('div.down_2 a').prop('href'),
|
||||
};
|
||||
});
|
||||
|
||||
const pubDateEl = $$('table.boxtable em').first();
|
||||
const pubDate =
|
||||
pubDateEl.find('span[title]').length === 0
|
||||
? pubDateEl
|
||||
.first()
|
||||
.text()
|
||||
.replace(/发表于\s/, '')
|
||||
: pubDateEl.find('span[title]').prop('title');
|
||||
|
||||
item.title = title;
|
||||
item.description = art(path.join(__dirname, 'templates/description.art'), {
|
||||
images: picture
|
||||
? [
|
||||
{
|
||||
src: picture,
|
||||
alt: title,
|
||||
},
|
||||
]
|
||||
: undefined,
|
||||
title,
|
||||
keys: Object.keys(details),
|
||||
details,
|
||||
description,
|
||||
info: $$('div.nex_drama_sums').html(),
|
||||
links,
|
||||
});
|
||||
item.pubDate = timezone(parseDate(pubDate, 'YYYY-M-D HH:mm:ss'), +8);
|
||||
item.category = Object.values(details)
|
||||
.flatMap((c) => c.split(/\s/))
|
||||
.filter(Boolean);
|
||||
item.author = details['导演'];
|
||||
item.content = {
|
||||
html: description,
|
||||
text: $$('div.nex_drama_intros').text(),
|
||||
};
|
||||
item.image = picture;
|
||||
item.banner = picture;
|
||||
item.language = language;
|
||||
|
||||
return item;
|
||||
})
|
||||
@@ -133,11 +179,18 @@ async function handler(ctx) {
|
||||
);
|
||||
|
||||
return {
|
||||
title: `4k世界 - ${$('#fontsearch ul.cl li.a')
|
||||
.toArray()
|
||||
.map((a) => $(a).text())
|
||||
.join('+')}`,
|
||||
title: `4k世界 - ${
|
||||
$('#fontsearch ul.cl li.a')
|
||||
.toArray()
|
||||
.map((a) => $(a).text())
|
||||
.join('+') || '不限'
|
||||
}`,
|
||||
description: $('meta[name="description"]').prop('content'),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
allowEmpty: true,
|
||||
image,
|
||||
author: $('meta[name="application-name"]').prop('content'),
|
||||
language,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,56 +1,59 @@
|
||||
{{ if picture }}
|
||||
<img src="{{ picture }}">
|
||||
{{ if images }}
|
||||
{{ each images image }}
|
||||
{{ if !videos?.[0]?.src && image?.src }}
|
||||
<figure>
|
||||
<img
|
||||
{{ if image.alt }}
|
||||
alt="{{ image.alt }}"
|
||||
{{ /if }}
|
||||
src="{{ image.src }}">
|
||||
</figure>
|
||||
{{ /if }}
|
||||
{{ /each }}
|
||||
{{ /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 }}
|
||||
{{ if title }}
|
||||
<h1>{{ title }}</h1>
|
||||
{{ /if }}
|
||||
|
||||
{{ if keys && details }}
|
||||
<table>
|
||||
<tbody>
|
||||
{{ each keys key }}
|
||||
<tr>
|
||||
<th>
|
||||
{{ key }}
|
||||
</th>
|
||||
<td>
|
||||
{{ details[key] }}
|
||||
</td>
|
||||
</tr>
|
||||
{{ /each }}
|
||||
</tbody>
|
||||
</table>
|
||||
</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 description }}
|
||||
<p>{{ description }}</p>
|
||||
{{ /if }}
|
||||
<br>
|
||||
|
||||
<h1>BT种子 / 磁力链下载</h1>
|
||||
{{@ bt }}
|
||||
<br>
|
||||
|
||||
<h1>影片信息</h1>
|
||||
{{ if info }}
|
||||
{{@ info }}
|
||||
<blockquote>{{@ info }}</blockquote>
|
||||
{{ /if }}
|
||||
|
||||
{{ if links }}
|
||||
<table>
|
||||
<tbody>
|
||||
{{ each links link }}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{{ link.link }}">{{ link.title }}</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ link.tags?.join('') ?? '' }}
|
||||
</td>
|
||||
</tr>
|
||||
{{ /each }}
|
||||
</tbody>
|
||||
</table>
|
||||
{{ /if }}
|
||||
Reference in New Issue
Block a user