From a96af536fc012fde2c1f554642ac1f5df8122b24 Mon Sep 17 00:00:00 2001
From: Ethan Shen <42264778+nczitzk@users.noreply.github.com>
Date: Mon, 27 Jun 2022 20:34:30 +0800
Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E6=B0=B4=E6=9E=9C?=
=?UTF-8?q?=E6=B4=BE=20(#10034)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/new-media.md | 6 ++
lib/v2/shuiguopai/index.js | 76 +++++++++++++++++++++
lib/v2/shuiguopai/maintainer.js | 3 +
lib/v2/shuiguopai/radar.js | 13 ++++
lib/v2/shuiguopai/router.js | 3 +
lib/v2/shuiguopai/templates/description.art | 6 ++
6 files changed, 107 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/docs/new-media.md b/docs/new-media.md
index a95618816..abe5ba932 100644
--- a/docs/new-media.md
+++ b/docs/new-media.md
@@ -3253,6 +3253,12 @@ column 为 third 时可选的 category:
| --- | ------ | ------- | ------------- | ------ | -------- |
| all | weekly | monthly | international | hot | favorite |
+## 水果派
+
+### 首页
+
+
+
## 搜狐号
### 更新
diff --git a/lib/v2/shuiguopai/index.js b/lib/v2/shuiguopai/index.js
new file mode 100644
index 000000000..c5baf1e3b
--- /dev/null
+++ b/lib/v2/shuiguopai/index.js
@@ -0,0 +1,76 @@
+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://shuiguopai.com';
+ const apiRootUrl = 'https://api.cbbee0.com';
+ const listUrl = `${apiRootUrl}/v1_2/homePage`;
+ const filmUrl = `${apiRootUrl}/v1_2/filmInfo`;
+
+ const response = await got({
+ method: 'post',
+ url: listUrl,
+ json: {
+ device_id: '',
+ hm: '008-api',
+ last_page: 0,
+ length: 3,
+ 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, 'MM月DD日 HH:mm'), +8),
+ }));
+
+ 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();
+
+ const infoResponse = await got({
+ method: 'post',
+ url: filmUrl,
+ json: {
+ device_id: '',
+ film_id: detailResponse.data.match(/film_id:"(\d+)",/)[1],
+ hm: '008-api',
+ userToken: '',
+ },
+ });
+
+ const data = infoResponse.data.data[0];
+
+ item.author = data.actor;
+ item.category = data.tags.map((t) => t.tag_title);
+ item.description = art(path.join(__dirname, 'templates/description.art'), {
+ video: data.download_url,
+ 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 000000000..ca7cf1eb1
--- /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 000000000..ff386c9dc
--- /dev/null
+++ b/lib/v2/shuiguopai/radar.js
@@ -0,0 +1,13 @@
+module.exports = {
+ 'shuiguopai.com': {
+ _name: '水果派',
+ '.': [
+ {
+ title: '首页',
+ docs: 'https://docs.rsshub.app/new-media.html#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 000000000..20c52b09d
--- /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 000000000..2609b35e3
--- /dev/null
+++ b/lib/v2/shuiguopai/templates/description.art
@@ -0,0 +1,6 @@
+{{ if video }}
+
+{{ /if }}
+{{@ description }}
\ No newline at end of file