Merge pull request #6676 from nczitzk/feature/newzmz

feat: add NEW字幕组
This commit is contained in:
NeverBehave 2021-01-11 21:13:46 -05:00 committed by GitHub
commit 9fc72b42e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 91 additions and 0 deletions

View File

@ -440,6 +440,18 @@ pageClass: routes
<Route author="hoilc" example="/mqube/tag/UTAU" path="/mqube/tag/:tag" :paramsDesc="['标签名称, 可参考`https://mqube.net/search/tag`']" radar="1" rssbud="1"/>
## NEW 字幕组
### 分类
<Route author="nczitzk" example="/newzmz" path="/newzmz/:category?" :paramsDesc="['分类,见下表,默认为最近更新']">
| 最近更新 | 剧集推荐 | 电影推荐 | 纪录片推荐 | 动画推荐 | 真人秀推荐 |
| -------- | -------- | -------- | ---------- | -------- | ---------- |
| 1 | 2 | 3 | 4 | 5 | 6 |
</Route>
## Nyaa
### 搜索结果

View File

@ -3872,4 +3872,7 @@ router.get('/feed-the-beast/modpack/:modpackEntry', require('./routes/feed-the-b
router.get('/gab/user/:username', require('./routes/gab/user'));
router.get('/gab/popular/:sort?', require('./routes/gab/explore'));
// NEW字幕组
router.get('/newzmz/:category?', require('./routes/newzmz/index'));
module.exports = router;

View File

@ -0,0 +1,76 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const category = parseInt(ctx.params.category || '1');
const rootUrl = 'https://newzmz.com';
const response = await got({
method: 'get',
url: rootUrl,
});
const $ = cheerio.load(response.data);
const target = $('.rowMod').eq(category);
const links = await Promise.all(
target
.find('.slides li a')
.slice(0, 15)
.map((_, item) => {
item = $(item);
return {
title: item.text(),
link: `${rootUrl}${item.attr('href')}`,
};
})
.get()
.map(
async (item) =>
await ctx.cache.tryGet(item.link, async () => {
const resourceResponse = await got({
method: 'get',
url: item.link,
});
const $ = cheerio.load(resourceResponse.data);
item.link = $('.addgz').attr('href');
item.pubDate = new Date($('.duration').text().replace(/更新时间:/, '')).toUTCString();
return item;
})
)
);
const items = await Promise.all(
links.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('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,
item: items,
};
};