mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-02 18:18:06 +08:00
fix(route): jike/topic add video (#9807)
This commit is contained in:
@@ -3,6 +3,8 @@ const got = require('@/utils/got');
|
|||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
const config = require('@/config').value;
|
const config = require('@/config').value;
|
||||||
|
|
||||||
|
const videoAPI = 'https://api.ruguoapp.com/1.0/mediaMeta/play?type=ORIGINAL_POST';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
topicDataHanding: (data) =>
|
topicDataHanding: (data) =>
|
||||||
data.posts.map((item) => {
|
data.posts.map((item) => {
|
||||||
@@ -114,6 +116,11 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 6. 视频
|
||||||
|
if (item.video) {
|
||||||
|
description += `<br><video src="${item.video.url}" controls></video>`;
|
||||||
|
}
|
||||||
|
|
||||||
// rss标题
|
// rss标题
|
||||||
// 优先将音频和视频名作为标题
|
// 优先将音频和视频名作为标题
|
||||||
// 其次将正文内容作为标题
|
// 其次将正文内容作为标题
|
||||||
@@ -136,7 +143,22 @@ module.exports = {
|
|||||||
const html = resp.data;
|
const html = resp.data;
|
||||||
const $ = cheerio.load(html);
|
const $ = cheerio.load(html);
|
||||||
const raw = $('[type = "application/json"]').html();
|
const raw = $('[type = "application/json"]').html();
|
||||||
return JSON.parse(raw).props.pageProps;
|
const data = JSON.parse(raw).props.pageProps;
|
||||||
|
data.posts = await Promise.all(
|
||||||
|
data.posts.map(async (item) => {
|
||||||
|
if (!item.video) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
const videoUrl = `${videoAPI}&id=${item.id}`;
|
||||||
|
const videoRes = await got(videoUrl);
|
||||||
|
item.video = videoRes.data;
|
||||||
|
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
return data;
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
config.cache.routeExpire
|
config.cache.routeExpire
|
||||||
|
|||||||
Reference in New Issue
Block a user