fix(route): 虎扑帖子视频图片 (#11009)

* fix(route): 虎扑帖子视频图片
This commit is contained in:
Ethan Shen
2022-10-06 02:17:33 +08:00
committed by GitHub
parent 49c9296e77
commit c7cc533c79
4 changed files with 38 additions and 27 deletions

View File

@@ -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

View File

@@ -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,

View File

@@ -1,22 +1,11 @@
{{ if image }}
<img src="{{ image }}">
{{ if videos }}
{{ each videos video }}
<video poster= "video.poster" controls>
<source src="{{ video.source }}" type="video/mp4">
</video>
{{ /each }}
{{ /if }}
{{ if description }}
<p>{{ description }}</p>
{{ /if }}
{{ if keyEvent }}
<h1>关键事件</h1>
{{ each keyEvent event }}
<p>{{ event.title }}</p>
{{ each event.gifImgs gif }}
<img src="{{ gif }}">
{{ /each }}
{{ /each }}
{{ /if }}
{{ if playerImage }}
<h1>球员评分</h1>
<img src="{{ playerImage }}">
{{@ description }}
{{ /if }}

View File

@@ -0,0 +1,22 @@
{{ if image }}
<img src="{{ image }}">
{{ /if }}
{{ if description }}
<p>{{ description }}</p>
{{ /if }}
{{ if keyEvent }}
<h1>关键事件</h1>
{{ each keyEvent event }}
<p>{{ event.title }}</p>
{{ each event.gifImgs gif }}
<img src="{{ gif }}">
{{ /each }}
{{ /each }}
{{ /if }}
{{ if playerImage }}
<h1>球员评分</h1>
<img src="{{ playerImage }}">
{{ /if }}