From 4ecae47d2e86607a7e1896c9d9a8708dfa3075b1 Mon Sep 17 00:00:00 2001
From: Zhengyi <10750252+fuzy112@users.noreply.github.com>
Date: Fri, 7 Jul 2023 11:20:14 +0800
Subject: [PATCH] =?UTF-8?q?feat(route):=20Add=20=E4=B8=8A=E6=B5=B7?=
=?UTF-8?q?=E6=96=87=E5=8C=96=E5=B9=BF=E5=9C=BA=20-=20=E8=8A=82=E7=9B=AE?=
=?UTF-8?q?=E5=88=97=E8=A1=A8=20(#12761)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* feat(route): Add 上海文化广场 - 节目列表
* feat(route): include full article content for shcstheatre
* fix(route): correct image urls for shcstheatre
* fix(route): fix typo in shcstheatre
* refactor(route): shcstheatre: hide the titles for empty section
* doc: document shcstheatre
* feat(radar): : add rule for shcstheatre
* fix(route): use cache for shcstheatre
* feat(route): add cover image for shcstheatre
* refactor(route): move description.art to templates subdir
* Update lib/v2/shcstheatre/programs.js
* Update lib/v2/shcstheatre/programs.js
* Update lib/v2/shcstheatre/programs.js
* Update lib/v2/shcstheatre/radar.js
* fix: use path.join() instead of string concatenation
---------
---
docs/shopping.md | 6 ++
lib/v2/shcstheatre/maintainer.js | 3 +
lib/v2/shcstheatre/programs.js | 39 ++++++++++++
lib/v2/shcstheatre/radar.js | 13 ++++
lib/v2/shcstheatre/router.js | 3 +
lib/v2/shcstheatre/templates/description.art | 65 ++++++++++++++++++++
6 files changed, 129 insertions(+)
create mode 100644 lib/v2/shcstheatre/maintainer.js
create mode 100644 lib/v2/shcstheatre/programs.js
create mode 100644 lib/v2/shcstheatre/radar.js
create mode 100644 lib/v2/shcstheatre/router.js
create mode 100644 lib/v2/shcstheatre/templates/description.art
diff --git a/docs/shopping.md b/docs/shopping.md
index 85f58c397..6882eae38 100644
--- a/docs/shopping.md
+++ b/docs/shopping.md
@@ -443,6 +443,12 @@ For instance, in
+## 上海文化广场
+
+### 节目列表
+
+
+
## 什么值得买
::: tip 提示
diff --git a/lib/v2/shcstheatre/maintainer.js b/lib/v2/shcstheatre/maintainer.js
new file mode 100644
index 000000000..0cbdeea1a
--- /dev/null
+++ b/lib/v2/shcstheatre/maintainer.js
@@ -0,0 +1,3 @@
+module.exports = {
+ '/programs': ['fuzy112'],
+};
diff --git a/lib/v2/shcstheatre/programs.js b/lib/v2/shcstheatre/programs.js
new file mode 100644
index 000000000..5d3776644
--- /dev/null
+++ b/lib/v2/shcstheatre/programs.js
@@ -0,0 +1,39 @@
+const got = require('@/utils/got');
+const { art } = require('@/utils/render');
+const { parseDate } = require('@/utils/parse-date');
+const timezone = require('@/utils/timezone');
+const cheerio = require('cheerio');
+const path = require('path');
+
+module.exports = async (ctx) => {
+ const url = 'https://www.shcstheatre.com/Program/programList.aspx';
+ const res = await got.get(url);
+ const $ = cheerio.load(res.data);
+ const items = await Promise.all(
+ $('#datarow .program-name a').map((_, elem) => {
+ const link = new URL($(elem).attr('href'), url);
+ return ctx.cache.tryGet(link.toString(), async () => {
+ const id = link.searchParams.get('id');
+ const res2 = await got.post('https://www.shcstheatre.com/webapi.ashx?op=GettblprogramCache', {
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
+ form: { id },
+ });
+ const data = res2.data.data.tblprogram[0];
+ return {
+ title: data.SCS_WEB_BRIEFNAME,
+ link: link.toString(),
+ description: art(path.join(__dirname, 'templates/description.art'), data),
+ pubDate: timezone(parseDate(data.SJ_DATE_PC), +8),
+ };
+ });
+ })
+ );
+ const image = $('.menu-logo img').attr('src');
+
+ ctx.state.data = {
+ title: '上海文化广场 - 节目列表',
+ link: url,
+ image,
+ item: items,
+ };
+};
diff --git a/lib/v2/shcstheatre/radar.js b/lib/v2/shcstheatre/radar.js
new file mode 100644
index 000000000..489e9007e
--- /dev/null
+++ b/lib/v2/shcstheatre/radar.js
@@ -0,0 +1,13 @@
+module.exports = {
+ 'shcstheatre.com': {
+ _name: '上海文化广场',
+ www: [
+ {
+ title: '节目列表',
+ docs: 'https://docs.rsshub.app/shopping.html#shang-hai-wen-hua-guang-chang-jie-mu-lie-biao',
+ source: ['/Program/programList.aspx'],
+ target: '/shcstheatre/programs',
+ },
+ ],
+ },
+};
diff --git a/lib/v2/shcstheatre/router.js b/lib/v2/shcstheatre/router.js
new file mode 100644
index 000000000..7f879597f
--- /dev/null
+++ b/lib/v2/shcstheatre/router.js
@@ -0,0 +1,3 @@
+module.exports = function (router) {
+ router.get('/programs', require('./programs'));
+};
diff --git a/lib/v2/shcstheatre/templates/description.art b/lib/v2/shcstheatre/templates/description.art
new file mode 100644
index 000000000..fc5a21449
--- /dev/null
+++ b/lib/v2/shcstheatre/templates/description.art
@@ -0,0 +1,65 @@
+
+ {{ if SCS_PC_YMXQ_PIC }}
+ {{ each SCS_PC_YMXQ_PIC.split(';').map(s => s.trim() )}}
+

+ {{ /each }}
+ {{ /if }}
+
+
+ - 演出日期:{{ SCS_WEBPERCYCLE }}
+ - 入场时间:{{ SCS_EINLASSNAME }}
+ - 演出类型:{{ SCS_PERFORMANCE_TYPENAME }}
+ - 演出时长:{{ SCS_LENGTH }}分钟
+ - 演出语言:{{ SCS_PERLANGUAGENAME }}
+
+
+ {{ if SCS_PC_LUNBO_YCJS_EDITOR }}
+
演出介绍
+ {{ if SCS_PC_LUNBO_YCJS_PIC }}
+ {{ each SCS_PC_LUNBO_YCJS_PIC.split(';').map(s => s.trim()) }}
+

+ {{ /each }}
+ {{ /if }}
+
{{@ SCS_PC_LUNBO_YCJS_EDITOR }}
+ {{ /if }}
+
+ {{ if SCS_PC_LUNBO_ZCTD_EDITOR }}
+
主创团队
+ {{ if SCS_PC_LUNBO_ZCTD_PIC }}
+ {{ each SCS_PC_LUNBO_ZCTD_PIC.split(';').map(s => s.trim()) }}
+

+ {{ /each }}
+ {{ /if }}
+
{{@ SCS_PC_LUNBO_ZCTD_EDITOR }}
+ {{ /if }}
+
+ {{ if SCS_PC_LUNBO_JQGG_EDITOR }}
+
剧情梗概
+ {{ if SCS_PC_LUNBO_JQGG_PIC }}
+ {{ each SCS_PC_LUNBO_JQGG_PIC.split(';').map(s => s.trim()) }}
+

+ {{ /each }}
+ {{ /if }}
+
{{@ SCS_PC_LUNBO_JQGG_EDITOR }}
+ {{ /if }}
+
+ {{ if SCS_PC_LUNBO_HJJL_EDITOR }}
+
获奖记录
+ {{ if SCS_PC_LUNBO_HJJL_PIC }}
+ {{ each SCS_PC_LUNBO_HJJL_PIC.split(';').map(s => s.trim()) }}
+

+ {{ /each }}
+ {{ /if }}
+
{{@ SCS_PC_LUNBO_HJJL_EDITOR }}
+ {{ /if }}
+
+ {{ if SCS_PC_LUNBO_MTPL_EDITOR }}
+
媒体评论
+ {{ if SCS_PC_LUNBO_MTPL_PIC }}
+ {{ each SCS_PC_LUNBO_MTPL_PIC.split(';').map(s => s.trim()) }}
+

+ {{ /each }}
+ {{ /if }}
+
{{@ SCS_PC_LUNBO_MTPL_EDITOR }}
+ {{ /if }}
+