diff --git a/docs/multimedia.md b/docs/multimedia.md index fcf94a9e0cdf8f..c96f20bdd38a7f 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -979,6 +979,22 @@ pageClass: routes +## 弯弯字幕组 + +### 分类 + + + +| ALL | 英语小分队 | 日语小分队 | 韩语小分队 | 葡语小分队 | 西语小分队 | 法语小分队 | 意语小分队 | 德语小分队 | 泰语小分队 | 其他语种 | +| --- | ---------- | ---------- | ---------- | ---------- | ---------- | ---------- | ---------- | ---------- | ---------- | -------- | +| 139 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 153 | 117 | 154 | + + + +### 剧集 + + + ## 网易云音乐 ### 歌单歌曲 diff --git a/lib/router.js b/lib/router.js index d57eb8b756c35c..8e7256c301c98f 100644 --- a/lib/router.js +++ b/lib/router.js @@ -4067,6 +4067,10 @@ router.get('/jisilu/topic/:user', require('./routes/jisilu/topic')); // Constitutional Court of Baden-Württemberg (Germany) router.get('/verfghbw/press/:keyword?', require('./routes/verfghbw/press')); +// 弯弯字幕组 +router.get('/wanwansub/info/:id', require('./routes/wanwansub/info')); +router.get('/wanwansub/:id?', require('./routes/wanwansub/index')); + // FIX 字幕侠 router.get('/zimuxia/portfolio/:id', require('./routes/zimuxia/portfolio')); router.get('/zimuxia/:category?', require('./routes/zimuxia/index')); diff --git a/lib/routes/wanwansub/index.js b/lib/routes/wanwansub/index.js new file mode 100644 index 00000000000000..8d4d87eadc0c32 --- /dev/null +++ b/lib/routes/wanwansub/index.js @@ -0,0 +1,58 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const id = ctx.params.id || '139'; + + const rootUrl = 'http://wanwansub.com'; + const currentUrl = `${rootUrl}/node/${id}`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const list = $('.pg-item a') + .slice(0, 10) + .map((_, item) => { + item = $(item); + return { + title: item.text(), + link: `${rootUrl}${item.attr('href')}`, + }; + }) + .get(); + + const items = await Promise.all( + list.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('.button').remove(); + + const links = detailResponse.data.match(/磁力<\/a>/g); + + if (links) { + item.enclosure_type = 'application/x-bittorrent'; + item.enclosure_url = links.pop().match(/磁力<\/a>/)[1]; + } + + item.description = content('.content-box').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + }; +}; diff --git a/lib/routes/wanwansub/info.js b/lib/routes/wanwansub/info.js new file mode 100644 index 00000000000000..7cd978654bca9d --- /dev/null +++ b/lib/routes/wanwansub/info.js @@ -0,0 +1,44 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const id = ctx.params.id; + + const rootUrl = 'http://wanwansub.com'; + const currentUrl = `${rootUrl}/info/${id}`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const items = $('.lightbox-image') + .nextAll('p') + .slice(3) + .map((_, item) => { + const i = {}; + + item = $(item); + + item.find('a').each(function () { + if ($(this).text() === '磁力') { + i.enclosure_url = $(this).attr('href'); + i.enclosure_type = 'application/x-bittorrent'; + } + }); + + i.description = `

${item.html()}

`; + i.title = item.text().split(' ')[0]; + i.link = currentUrl; + + return i; + }) + .get(); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + }; +};