mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 14:07:54 +08:00
feat: 微博视频直接播放 (#2584)
This commit is contained in:
@@ -634,7 +634,7 @@ pageClass: routes
|
|||||||
|
|
||||||
### 博主
|
### 博主
|
||||||
|
|
||||||
<Route author="DIYgod" example="/weibo/user/1195230310" path="/weibo/user/:uid" :paramsDesc="['用户 id, 博主主页打开控制台执行 `$CONFIG.oid` 获取']" crawlerBadge="1"/>
|
<Route author="DIYgod iplusx" example="/weibo/user/1195230310" path="/weibo/user/:uid/:displayVideo?" :paramsDesc="['用户 id, 博主主页打开控制台执行 `$CONFIG.oid` 获取', '是否直接显示微博视频, 缺省 `0` 不显示, 若需要显示则填 `1` ']" crawlerBadge="1"/>
|
||||||
|
|
||||||
### 关键词
|
### 关键词
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ router.get('/bangumi/group/:id', require('./routes/bangumi/group/topic'));
|
|||||||
router.get('/bangumi/subject/:id', require('./routes/bangumi/subject'));
|
router.get('/bangumi/subject/:id', require('./routes/bangumi/subject'));
|
||||||
|
|
||||||
// 微博
|
// 微博
|
||||||
router.get('/weibo/user/:uid', require('./routes/weibo/user'));
|
router.get('/weibo/user/:uid/:displayVideo?', require('./routes/weibo/user'));
|
||||||
router.get('/weibo/keyword/:keyword', require('./routes/weibo/keyword'));
|
router.get('/weibo/keyword/:keyword', require('./routes/weibo/keyword'));
|
||||||
router.get('/weibo/search/hot', require('./routes/weibo/search/hot'));
|
router.get('/weibo/search/hot', require('./routes/weibo/search/hot'));
|
||||||
router.get('/weibo/super_index/:id', require('./routes/weibo/super_index'));
|
router.get('/weibo/super_index/:id', require('./routes/weibo/super_index'));
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ const date = require('@/utils/date');
|
|||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
const uid = ctx.params.uid;
|
const uid = ctx.params.uid;
|
||||||
|
const displayVideo = ctx.params.displayVideo || '0';
|
||||||
|
|
||||||
const containerResponse = await got({
|
const containerResponse = await got({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
@@ -57,14 +58,21 @@ module.exports = async (ctx) => {
|
|||||||
item.mblog.retweeted_status.text = retweetData.text;
|
item.mblog.retweeted_status.text = retweetData.text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const description = weiboUtils.format(item.mblog);
|
|
||||||
|
const link = `https://weibo.com/${uid}/${item.mblog.bid}`;
|
||||||
|
let description = weiboUtils.format(item.mblog);
|
||||||
const title = description.replace(/<img.*?>/g, '[图片]').replace(/<.*?>/g, '');
|
const title = description.replace(/<img.*?>/g, '[图片]').replace(/<.*?>/g, '');
|
||||||
const pubDate = isDataOK ? new Date(data.created_at).toUTCString() : date(item.mblog.created_at, 8);
|
const pubDate = isDataOK ? new Date(data.created_at).toUTCString() : date(item.mblog.created_at, 8);
|
||||||
|
|
||||||
|
// 视频的处理
|
||||||
|
if (displayVideo === '1') {
|
||||||
|
description = weiboUtils.formatVideo(description, item.mblog);
|
||||||
|
}
|
||||||
|
|
||||||
const it = {
|
const it = {
|
||||||
title: title,
|
title: title,
|
||||||
description: description,
|
description: description,
|
||||||
link: `https://weibo.com/${uid}/${item.mblog.bid}`,
|
link: link,
|
||||||
pubDate: pubDate,
|
pubDate: pubDate,
|
||||||
};
|
};
|
||||||
return Promise.resolve(it);
|
return Promise.resolve(it);
|
||||||
|
|||||||
@@ -50,6 +50,20 @@ const weiboUtils = {
|
|||||||
});
|
});
|
||||||
resolve(itemResponse.data.data);
|
resolve(itemResponse.data.data);
|
||||||
}),
|
}),
|
||||||
|
formatVideo: (itemDesc, status) => {
|
||||||
|
const pageInfo = status.page_info;
|
||||||
|
if (pageInfo && pageInfo.type === 'video') {
|
||||||
|
const pagePic = pageInfo.page_pic;
|
||||||
|
const mediaInfo = pageInfo.media_info;
|
||||||
|
const posterUrl = pagePic ? pagePic.url : '';
|
||||||
|
const videoUrl = mediaInfo ? mediaInfo.stream_url_hd || mediaInfo.stream_url || mediaInfo.mp4_hd_url || mediaInfo.mp4_sd_url || mediaInfo.mp4_720p_mp4 : '';
|
||||||
|
if (videoUrl) {
|
||||||
|
const video = `<br><video src="${videoUrl}" controls="controls" poster="${posterUrl}" style="width: 100%"></video>`;
|
||||||
|
itemDesc += video;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return itemDesc;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = weiboUtils;
|
module.exports = weiboUtils;
|
||||||
|
|||||||
Reference in New Issue
Block a user