diff --git a/lib/routes/4ksj/forum.ts b/lib/routes/4ksj/forum.ts
index c10c8b0e8..94d9d33fb 100644
--- a/lib/routes/4ksj/forum.ts
+++ b/lib/routes/4ksj/forum.ts
@@ -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,
};
}
diff --git a/lib/routes/4ksj/templates/description.art b/lib/routes/4ksj/templates/description.art
index 8b4f8f609..160b5fb5c 100644
--- a/lib/routes/4ksj/templates/description.art
+++ b/lib/routes/4ksj/templates/description.art
@@ -1,56 +1,59 @@
-{{ if picture }}
-
+{{ if images }}
+ {{ each images image }}
+ {{ if !videos?.[0]?.src && image?.src }}
+
+
+
+ {{ /if }}
+ {{ /each }}
{{ /if }}
-{{ if details }}
-
-
-
- | 片名 |
- {{ name }} |
-
-
- | 时间 |
- {{ time }} |
-
-
- | 豆瓣评分 |
- {{ score }} |
-
- {{ each detailKeys detail }}
-
- | {{ detail }} |
- {{@ details[detail] }} |
-
- {{ /each }}
+{{ if title }}
+ {{ title }}
+{{ /if }}
+
+{{ if keys && details }}
+
+
+ {{ each keys key }}
+
+ |
+ {{ key }}
+ |
+
+ {{ details[key] }}
+ |
+
+ {{ /each }}
-
+
{{ /if }}
-简介
- {{@ intro }}
-
-
-网盘下载
-{{ if links }}
-
-
- {{ each linkKeys link }}
-
- | {{ link }} |
- {{@ links[link] }} |
-
- {{ /each }}
-
-
+{{ if description }}
+ {{ description }}
{{ /if }}
-
-BT种子 / 磁力链下载
-{{@ bt }}
-
-
-影片信息
{{ if info }}
-{{@ info }}
+ {{@ info }}
+{{ /if }}
+
+{{ if links }}
+
+
+ {{ each links link }}
+
+ |
+ {{ link.title }}
+ |
+
+ {{ link.tags?.join('') ?? '' }}
+ |
+
+ {{ /each }}
+
+
{{ /if }}
\ No newline at end of file