From 58156eaa50f7e5fd39a5fbc37e827db8d2dba420 Mon Sep 17 00:00:00 2001
From: Ethan Shen <42264778+nczitzk@users.noreply.github.com>
Date: Thu, 8 Sep 2022 18:32:01 +0800
Subject: [PATCH] =?UTF-8?q?fix(route):=20=E8=99=8E=E6=89=91=E7=A4=BE?=
=?UTF-8?q?=E5=8C=BA=E6=AF=94=E8=B5=9B=E4=BF=A1=E6=81=AF=20(#10742)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
lib/v2/hupu/bbs.js | 23 ++++++++++++++++++++++-
lib/v2/hupu/templates/description.art | 22 ++++++++++++++++++++++
2 files changed, 44 insertions(+), 1 deletion(-)
create mode 100644 lib/v2/hupu/templates/description.art
diff --git a/lib/v2/hupu/bbs.js b/lib/v2/hupu/bbs.js
index 334ea0cca..929c04813 100644
--- a/lib/v2/hupu/bbs.js
+++ b/lib/v2/hupu/bbs.js
@@ -2,12 +2,15 @@ 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 id = ctx.params.id ?? '34';
const order = ctx.params.order ?? '1';
const rootUrl = 'https://bbs.hupu.com';
+ const apiRootUrl = 'https://games.mobileapi.hupu.com';
const currentUrl = `${rootUrl}/${id}${order === '1' ? `-postdate` : ''}`;
const response = await got({
@@ -35,7 +38,7 @@ module.exports = async (ctx) => {
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
try {
- const detailResponse = await got({
+ let detailResponse = await got({
method: 'get',
url: item.link,
});
@@ -46,6 +49,24 @@ module.exports = async (ctx) => {
item.author = content('.post-user-comp-info-top-name').first().text();
item.description = content('.main-thread').first().html();
+
+ const matches = detailResponse.data.match(/matchId=(\d+)-BATTLE_REPORT/);
+
+ if (matches) {
+ detailResponse = await got({
+ method: 'get',
+ url: `${apiRootUrl}/1/7.5.36/basketballapi/news/battleReport?relationId=${matches[1]}&relationType=BATTLE_REPORT`,
+ });
+
+ const result = detailResponse.data.result;
+
+ item.description = art(path.join(__dirname, 'templates/description.art'), {
+ image: result.img,
+ description: result.beginContent,
+ keyEvent: result.keyEvent,
+ playerImage: result.playerScoreImg,
+ });
+ }
} catch (e) {
// no-empty
}
diff --git a/lib/v2/hupu/templates/description.art b/lib/v2/hupu/templates/description.art
new file mode 100644
index 000000000..3d417ad52
--- /dev/null
+++ b/lib/v2/hupu/templates/description.art
@@ -0,0 +1,22 @@
+{{ if image }}
+
+{{ /if }}
+
+{{ if description }}
+
{{ description }}
+{{ /if }} + +{{ if keyEvent }} +{{ event.title }}
+{{ each event.gifImgs gif }} +