From a4b331b14b035388209222595b8992811c14519b Mon Sep 17 00:00:00 2001 From: Tony Date: Mon, 15 Jan 2024 16:53:35 +0000 Subject: [PATCH] feat: recover shuiguopai --- lib/v2/shuiguopai/index.js | 86 +++++++++++++++++++++ lib/v2/shuiguopai/maintainer.js | 3 + lib/v2/shuiguopai/radar.js | 13 ++++ lib/v2/shuiguopai/router.js | 3 + lib/v2/shuiguopai/templates/description.art | 8 ++ website/docs/routes/new-media.mdx | 6 ++ 6 files changed, 119 insertions(+) create mode 100644 lib/v2/shuiguopai/index.js create mode 100644 lib/v2/shuiguopai/maintainer.js create mode 100644 lib/v2/shuiguopai/radar.js create mode 100644 lib/v2/shuiguopai/router.js create mode 100644 lib/v2/shuiguopai/templates/description.art diff --git a/lib/v2/shuiguopai/index.js b/lib/v2/shuiguopai/index.js new file mode 100644 index 00000000000000..1ff1c7937ed4a0 --- /dev/null +++ b/lib/v2/shuiguopai/index.js @@ -0,0 +1,86 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const timezone = require('@/utils/timezone'); +const { parseDate } = require('@/utils/parse-date'); +const { art } = require('@/utils/render'); +const path = require('path'); + +module.exports = async (ctx) => { + const rootUrl = 'https://sgptv.vip'; + const apiRootUrl = 'https://api.cbbee0.com'; + const listUrl = `${apiRootUrl}/v1_2/homePage`; + const filmUrl = `${apiRootUrl}/v1_2/filmInfo`; + + const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 50; + + const response = await got({ + method: 'post', + url: listUrl, + json: { + device_id: '', + hm: '008-api', + last_page: 0, + length: limit, + ltype: 1, + page: 1, + userToken: '', + }, + }); + + let items = response.data.data.list.map((item) => ({ + title: item.title, + guid: item.library_id, + link: `${rootUrl}/play-details/${item.library_id}`, + pubDate: timezone(parseDate(item.show_time_origin, 'YYYY-MM-DD HH:mm:ss'), +8), + category: item.tags.map((t) => t.tag_title), + })); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + + const content = cheerio.load(detailResponse.data); + content('iframe').remove(); + + let videos; + const filmId = detailResponse.data.match(/film_id:"([\d,]+)",/)?.[1]; + if (filmId) { + const infoResponse = await got({ + method: 'post', + url: filmUrl, + json: { + device_id: '', + film_id: filmId, + hm: '008-api', + userToken: '', + }, + }); + + const data = infoResponse.data.data; + + videos = data.map((d) => d.download_url); + + item.category = data.flatMap((d) => d.tags.map((t) => t.tag_title)); + item.author = data.map((d) => d.actor).join(' '); + } + + item.description = art(path.join(__dirname, 'templates/description.art'), { + videos, + description: content('.content').html(), + }); + + return item; + }) + ) + ); + + ctx.state.data = { + title: '水果派', + link: rootUrl, + item: items, + }; +}; diff --git a/lib/v2/shuiguopai/maintainer.js b/lib/v2/shuiguopai/maintainer.js new file mode 100644 index 00000000000000..ca7cf1eb13c68a --- /dev/null +++ b/lib/v2/shuiguopai/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/': ['nczitzk'], +}; diff --git a/lib/v2/shuiguopai/radar.js b/lib/v2/shuiguopai/radar.js new file mode 100644 index 00000000000000..ea43cfb98da7cd --- /dev/null +++ b/lib/v2/shuiguopai/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'shuiguopai.com': { + _name: '水果派', + '.': [ + { + title: '首页', + docs: 'https://docs.rsshub.app/routes/new-media#shui-guo-pai-shou-ye', + source: ['/'], + target: '/shuiguopai', + }, + ], + }, +}; diff --git a/lib/v2/shuiguopai/router.js b/lib/v2/shuiguopai/router.js new file mode 100644 index 00000000000000..20c52b09d72938 --- /dev/null +++ b/lib/v2/shuiguopai/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/', require('./index')); +}; diff --git a/lib/v2/shuiguopai/templates/description.art b/lib/v2/shuiguopai/templates/description.art new file mode 100644 index 00000000000000..4d4411a4375152 --- /dev/null +++ b/lib/v2/shuiguopai/templates/description.art @@ -0,0 +1,8 @@ +{{ if videos }} +{{ each videos video }} + +{{ /each }} +{{ /if }} +{{@ description }} diff --git a/website/docs/routes/new-media.mdx b/website/docs/routes/new-media.mdx index 86c7c93730050c..1cf7184d7488c4 100644 --- a/website/docs/routes/new-media.mdx +++ b/website/docs/routes/new-media.mdx @@ -4340,6 +4340,12 @@ | all | weekly | monthly | international | hot | favorite | +## 水果派 {#shui-guo-pai} + +### 首页 {#shui-guo-pai-shou-ye} + + + ## 搜狐号 {#sou-hu-hao} ### 更新 {#sou-hu-hao-geng-xin}