diff --git a/docs/multimedia.md b/docs/multimedia.md index bf59d65da..a0e5cbca2 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -440,6 +440,18 @@ pageClass: routes +## NEW 字幕组 + +### 分类 + + + +| 最近更新 | 剧集推荐 | 电影推荐 | 纪录片推荐 | 动画推荐 | 真人秀推荐 | +| -------- | -------- | -------- | ---------- | -------- | ---------- | +| 1 | 2 | 3 | 4 | 5 | 6 | + + + ## Nyaa ### 搜索结果 diff --git a/lib/router.js b/lib/router.js index c852de52c..2dd203b13 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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; diff --git a/lib/routes/newzmz/index.js b/lib/routes/newzmz/index.js new file mode 100644 index 000000000..e3cc8b720 --- /dev/null +++ b/lib/routes/newzmz/index.js @@ -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, + }; +};