mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-29 18:06:31 +08:00
fix(route): 虎扑社区比赛信息 (#10742)
This commit is contained in:
+22
-1
@@ -2,12 +2,15 @@ const got = require('@/utils/got');
|
|||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
const timezone = require('@/utils/timezone');
|
const timezone = require('@/utils/timezone');
|
||||||
const { parseDate } = require('@/utils/parse-date');
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
const { art } = require('@/utils/render');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
const id = ctx.params.id ?? '34';
|
const id = ctx.params.id ?? '34';
|
||||||
const order = ctx.params.order ?? '1';
|
const order = ctx.params.order ?? '1';
|
||||||
|
|
||||||
const rootUrl = 'https://bbs.hupu.com';
|
const rootUrl = 'https://bbs.hupu.com';
|
||||||
|
const apiRootUrl = 'https://games.mobileapi.hupu.com';
|
||||||
const currentUrl = `${rootUrl}/${id}${order === '1' ? `-postdate` : ''}`;
|
const currentUrl = `${rootUrl}/${id}${order === '1' ? `-postdate` : ''}`;
|
||||||
|
|
||||||
const response = await got({
|
const response = await got({
|
||||||
@@ -35,7 +38,7 @@ module.exports = async (ctx) => {
|
|||||||
items.map((item) =>
|
items.map((item) =>
|
||||||
ctx.cache.tryGet(item.link, async () => {
|
ctx.cache.tryGet(item.link, async () => {
|
||||||
try {
|
try {
|
||||||
const detailResponse = await got({
|
let detailResponse = await got({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: item.link,
|
url: item.link,
|
||||||
});
|
});
|
||||||
@@ -46,6 +49,24 @@ module.exports = async (ctx) => {
|
|||||||
|
|
||||||
item.author = content('.post-user-comp-info-top-name').first().text();
|
item.author = content('.post-user-comp-info-top-name').first().text();
|
||||||
item.description = content('.main-thread').first().html();
|
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) {
|
} catch (e) {
|
||||||
// no-empty
|
// no-empty
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 }}
|
||||||
Reference in New Issue
Block a user