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 }} +