fix(route): NEW字幕组 (#12400)

* fix(route): NEW字幕组

* update files

* fix: set default id
This commit is contained in:
Ethan Shen 2023-04-28 22:59:34 +08:00 committed by GitHub
parent 25fb241523
commit 2e2c0058a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 100 additions and 66 deletions

View File

@ -960,7 +960,7 @@ JavDB 有多个备用域名,本路由默认使用永久域名 <https://javdb.c
### 指定剧集
<Route author="nczitzk" example="/newzmz/view/qEzRyY3v" path="/newzmz/view/:id?" :paramsDesc="['剧集 id可在剧集下载页 URL 中找到']">
<Route author="nczitzk" example="/newzmz/qEzRyY3v" path="/newzmz/:id?" :paramsDesc="['剧集 id可在剧集下载页 URL 中找到']">
如:雪国列车(剧版)的下载页 URL 为 `https://ysfx.tv/view/qEzRyY3v.html`,即剧集 id 为 `qEzRyY3v`

View File

@ -1,79 +1,90 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');
module.exports = async (ctx) => {
const category = parseInt(ctx.params.category || '1');
const category = ctx.params.category ? parseInt(ctx.params.category) : 1;
const rootUrl = 'http://newzmz.com';
const rootSUrl = 'http://s.newzmz.com';
const currentUrl = `${rootUrl}/index.html`;
const response = await got({
method: 'get',
url: `${rootUrl}/index.html`,
url: currentUrl,
});
const $ = cheerio.load(response.data);
const target = $('.rowMod').eq(category);
const links = await Promise.all(
const items = [];
const target = $('div.rowMod').eq(category);
await Promise.all(
target
.find('.slides li a')
.map((_, item) => {
.find('ul.slides li a')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.text(),
link: `${rootUrl}${item.attr('href')}`,
link: `${rootSUrl}/view/${item.attr('href').split('/details-').pop()}`,
};
})
.get()
.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const resourceResponse = await got({
const detailResponse = await got({
method: 'get',
url: item.link,
});
const $ = cheerio.load(resourceResponse.data);
item.link = $('.addgz').attr('href').replace('http:', 'https:');
item.pubDate = parseDate(
$('.duration')
.not('.upday')
.text()
.replace(/更新时间:/, '')
const content = cheerio.load(detailResponse.data);
const title = content('.page-header-content').text();
items.push(
...content('div.team-con-area')
.toArray()
.map((a) => {
a = content(a);
const episode = a
.find('span.up')
.text()
.trim()
.replace(/第 (\d+) /g, '第$1');
return {
link: item.link,
guid: `${item.link}#${episode.replace(/\s*/g, '')}`,
title: `${title} ${episode}`,
category: a
.find('div.item-label a')
.toArray()
.map((l) => content(l).text()),
description: art(path.join(__dirname, 'templates/description.art'), {
links: a
.find('ul.team-icons li')
.toArray()
.map((i) => ({
name: content(i).find('p').text(),
link: content(i).find('a').attr('href'),
})),
}),
enclosure_type: 'application/x-bittorrent',
enclosure_url: a.find('a[title="磁力链下载"]').attr('href'),
};
})
);
return item;
})
)
);
const items = await Promise.all(
links.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(detailResponse.data);
content('img, .link-name').remove();
content('a[title]').each(function () {
content(this).text(content(this).attr('title'));
});
item.description = content('.faq--area').html();
item.enclosure_type = 'application/x-bittorrent';
item.enclosure_url = content('a[title="磁力链下载"]').attr('href');
return item;
})
)
);
ctx.state.data = {
title: `${target.find('.row-header-title').text()} - NEW字幕组`,
link: rootUrl,
title: `NEW字幕组 - ${target.find('.row-header-title').text()}`,
link: currentUrl,
item: items,
};
};

View File

@ -1,4 +1,4 @@
module.exports = {
'/:category?': ['nczitzk'],
'/view/:id?': ['nczitzk'],
'/:id?': ['nczitzk'],
};

View File

@ -12,7 +12,7 @@ module.exports = {
title: '指定剧集',
docs: 'https://docs.rsshub.app/multimedia.html#new-zi-mu-zu',
source: ['/view/:id'],
target: (params) => `/newzmz/view/${params.id.replace('.html', '')}`,
target: (params) => `/newzmz/${params.id.replace('.html', '')}`,
},
],
},

View File

@ -1,4 +1,5 @@
module.exports = (router) => {
router.get('/:category?', require('./index'));
router.get(/\/(\d+)?/, require('./index'));
router.get('/view/:id', require('./view'));
router.get('/:id', require('./view'));
};

View File

@ -0,0 +1,7 @@
{{ if links }}
<ul>
{{ each links link }}
<li><a href="{{ link.link }}">{{ link.name }}</a></li>
{{ /each }}
</ul>
{{ /if }}

View File

@ -1,5 +1,7 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { art } = require('@/utils/render');
const path = require('path');
module.exports = async (ctx) => {
const id = ctx.params.id;
@ -11,32 +13,45 @@ module.exports = async (ctx) => {
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
$('img, .link-name').remove();
$('a[title]').each(function () {
$(this).text($(this).attr('title'));
});
const list = $('.team-con-area')
.map((_, item) => {
const items = $('div.team-con-area')
.toArray()
.map((item) => {
item = $(item);
const link = item.find('a[data-target="#down-modal"]').eq(0).attr('href');
const episode = item
.find('span.up')
.text()
.trim()
.replace(/第 (\d+) /g, '第$1');
return {
link,
enclosure_url: link,
link: currentUrl,
guid: `${currentUrl}#${episode.replace(/\s*/g, '')}`,
title: episode,
category: item
.find('div.item-label a')
.toArray()
.map((l) => $(l).text()),
description: art(path.join(__dirname, 'templates/description.art'), {
links: item
.find('ul.team-icons li')
.toArray()
.map((i) => ({
name: $(i).find('p').text(),
link: $(i).find('a').attr('href'),
})),
}),
enclosure_type: 'application/x-bittorrent',
title: item.find('.item-content').text(),
description: `<ul>${item.find('.team-icons').html()}</ul>`,
enclosure_url: item.find('a[title="磁力链下载"]').attr('href'),
};
})
.get();
});
ctx.state.data = {
title: `${$('.page-header-content .title').text()} - NEW字幕组`,
title: `NEW字幕组 - ${$('.page-header-content').text()}`,
link: currentUrl,
item: list,
item: items,
};
};