From 4e52a65ed0b43f0260cb0c74dede4ef871cbe758 Mon Sep 17 00:00:00 2001 From: Ethan Shen Date: Tue, 2 Mar 2021 13:03:37 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20NEW=E5=AD=97=E5=B9=95?= =?UTF-8?q?=E7=BB=84=E6=8C=87=E5=AE=9A=E5=89=A7=E9=9B=86=20(#7022)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/multimedia.md | 8 ++++++++ lib/router.js | 3 ++- lib/routes/newzmz/view.js | 42 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 lib/routes/newzmz/view.js diff --git a/docs/multimedia.md b/docs/multimedia.md index 7bb71502c..bb4464908 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -477,6 +477,14 @@ pageClass: routes +### 指定剧集 + + + +如:雪国列车(剧版)的下载页 URL 为 `https://ysfx.tv/view/qEzRyY3v.html`,即剧集 id 为 `qEzRyY3v`。 + + + ## Nyaa ### 搜索结果 diff --git a/lib/router.js b/lib/router.js index bfa853886..4542c512e 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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 diff --git a/lib/routes/newzmz/view.js b/lib/routes/newzmz/view.js new file mode 100644 index 000000000..9107a7e9a --- /dev/null +++ b/lib/routes/newzmz/view.js @@ -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: ``, + }; + }) + .get(); + + ctx.state.data = { + title: `${$('.page-header-content .title').text()} - NEW字幕组`, + link: currentUrl, + item: list, + }; +};