From c7cc533c79f343e77f9f9c587ec58bf1d90a891f Mon Sep 17 00:00:00 2001 From: Ethan Shen <42264778+nczitzk@users.noreply.github.com> Date: Thu, 6 Oct 2022 02:17:33 +0800 Subject: [PATCH] =?UTF-8?q?fix(route):=20=E8=99=8E=E6=89=91=E5=B8=96?= =?UTF-8?q?=E5=AD=90=E8=A7=86=E9=A2=91=E5=9B=BE=E7=89=87=20(#11009)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(route): 虎扑帖子视频图片 --- lib/v2/hupu/all.js | 16 ++++++++-------- lib/v2/hupu/bbs.js | 2 +- lib/v2/hupu/templates/description.art | 25 +++++++------------------ lib/v2/hupu/templates/match.art | 22 ++++++++++++++++++++++ 4 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 lib/v2/hupu/templates/match.art diff --git a/lib/v2/hupu/all.js b/lib/v2/hupu/all.js index 5f47020962..6e2411db3c 100644 --- a/lib/v2/hupu/all.js +++ b/lib/v2/hupu/all.js @@ -43,18 +43,18 @@ module.exports = async (ctx) => { const videos = []; - content('.thread-video-wrap').each(function () { - videos.push(content('video').attr('src')); - content(this).remove(); + content('.hupu-post-video').each(function () { + videos.push({ + source: content(this).attr('src'), + poster: content(this).attr('poster'), + }); }); - content('.bbs-user-info-time span').remove(); - - item.author = content('.bbs-user-info-name').first().text(); - item.pubDate = item.pubDate ?? timezone(parseRelativeDate(content('.bbs-user-info-time').first().text()), +8); + item.author = content('.bbs-user-wrapper-content-name-span').first().text(); + item.pubDate = item.pubDate ?? timezone(parseRelativeDate(content('.second-line-user-info').first().text()), +8); item.description = art(path.join(__dirname, 'templates/description.art'), { videos, - description: content('.bbs-thread-content').html(), + description: content('.bbs-content').first().html(), }); } catch (e) { // no-empty diff --git a/lib/v2/hupu/bbs.js b/lib/v2/hupu/bbs.js index 929c048131..50483927ca 100644 --- a/lib/v2/hupu/bbs.js +++ b/lib/v2/hupu/bbs.js @@ -60,7 +60,7 @@ module.exports = async (ctx) => { const result = detailResponse.data.result; - item.description = art(path.join(__dirname, 'templates/description.art'), { + item.description = art(path.join(__dirname, 'templates/match.art'), { image: result.img, description: result.beginContent, keyEvent: result.keyEvent, diff --git a/lib/v2/hupu/templates/description.art b/lib/v2/hupu/templates/description.art index 3d417ad52c..f019c06259 100644 --- a/lib/v2/hupu/templates/description.art +++ b/lib/v2/hupu/templates/description.art @@ -1,22 +1,11 @@ -{{ if image }} - +{{ if videos }} +{{ each videos video }} + +{{ /each }} {{ /if }} {{ if description }} -

{{ description }}

-{{ /if }} - -{{ if keyEvent }} -

关键事件

-{{ each keyEvent event }} -

{{ event.title }}

-{{ each event.gifImgs gif }} - -{{ /each }} -{{ /each }} -{{ /if }} - -{{ if playerImage }} -

球员评分

- +{{@ description }} {{ /if }} \ No newline at end of file diff --git a/lib/v2/hupu/templates/match.art b/lib/v2/hupu/templates/match.art new file mode 100644 index 0000000000..3d417ad52c --- /dev/null +++ b/lib/v2/hupu/templates/match.art @@ -0,0 +1,22 @@ +{{ if image }} + +{{ /if }} + +{{ if description }} +

{{ description }}

+{{ /if }} + +{{ if keyEvent }} +

关键事件

+{{ each keyEvent event }} +

{{ event.title }}

+{{ each event.gifImgs gif }} + +{{ /each }} +{{ /each }} +{{ /if }} + +{{ if playerImage }} +

球员评分

+ +{{ /if }} \ No newline at end of file