feat(route): add NEW字幕组指定剧集 (#7022)

This commit is contained in:
Ethan Shen 2021-03-02 13:03:37 +08:00 committed by GitHub
parent 45eff8ea5a
commit 4e52a65ed0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 52 additions and 1 deletions

View File

@ -477,6 +477,14 @@ pageClass: routes
</Route>
### 指定剧集
<Route author="nczitzk" example="/newzmz/view/qEzRyY3v" path="/newzmz/view/:id?" :paramsDesc="['剧集 id可在剧集下载页 URL 中找到']">
如:雪国列车(剧版)的下载页 URL 为 `https://ysfx.tv/view/qEzRyY3v.html`,即剧集 id 为 `qEzRyY3v`
</Route>
## Nyaa
### 搜索结果

View File

@ -3888,7 +3888,8 @@ 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字幕组
// NEW 字幕组
router.get('/newzmz/view/:id', require('./routes/newzmz/view'));
router.get('/newzmz/:category?', require('./routes/newzmz/index'));
// Phrack Magazine

42
lib/routes/newzmz/view.js Normal file
View File

@ -0,0 +1,42 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const id = ctx.params.id;
const rootUrl = `https://ysfx.tv`;
const currentUrl = `${rootUrl}/view/${id}.html`;
const response = await got({
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) => {
item = $(item);
const link = item.find('a[data-target="#down-modal"]').eq(0).attr('href');
return {
link,
enclosure_url: link,
enclosure_type: 'application/x-bittorrent',
title: item.find('.item-content').text(),
description: `<ul>${item.find('.team-icons').html()}</ul>`,
};
})
.get();
ctx.state.data = {
title: `${$('.page-header-content .title').text()} - NEW字幕组`,
link: currentUrl,
item: list,
};
};