feat(route): vlive (#10063)
This commit is contained in:
parent
07819def98
commit
4849f8b202
|
|
@ -3,3 +3,9 @@ pageClass: routes
|
|||
---
|
||||
|
||||
# Live
|
||||
|
||||
## V LIVE
|
||||
|
||||
### Board
|
||||
|
||||
<RouteEn author="TonyRL" example="/vlive/channel/FD53B/board/3530" path="/vlive/channel/:channel/board/:board" :paramsDesc="['Channel ID, can be found in the URL', 'Board ID, can be found in the URL']" radar="1" rssbud="1" />
|
||||
|
|
|
|||
|
|
@ -359,7 +359,7 @@ generates
|
|||
|
||||
<RouteEn author="yindaheng98 Rongronggg9" path="/twitter/media/:id/:routeParams?" example="/twitter/media/DIYgod" :paramsDesc="['user id', 'extra parameters, see the table above.']" radar="1" rssbud="1"/>
|
||||
|
||||
## User following timeline
|
||||
### User following timeline
|
||||
|
||||
<RouteEn author="DIYgod" example="/twitter/followings/DIYgod" path="/twitter/followings/:id/:routeParams?" :paramsDesc="['user id', 'extra parameters, see the table above']" radar="1" rssbud="1" selfhost="1">
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,71 @@
|
|||
const got = require('@/utils/got');
|
||||
const { JSDOM } = require('jsdom');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
const baseUrl = 'https://www.vlive.tv';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { channel, board } = ctx.params;
|
||||
const link = `${baseUrl}/channel/${channel}/board/${board}`;
|
||||
|
||||
const response = await got(link);
|
||||
const dom = new JSDOM(response.data, {
|
||||
runScripts: 'dangerously',
|
||||
});
|
||||
const preloadedState = dom.window.__PRELOADED_STATE__;
|
||||
const channelData = preloadedState.channel.channel;
|
||||
const userCountry = preloadedState.common.userCountry;
|
||||
const userLanguage = preloadedState.common.userLanguage;
|
||||
|
||||
const apiResponse = await got(`${baseUrl}/globalv-web/vam-web/post/v1.0/board-${board}/posts`, {
|
||||
searchParams: {
|
||||
appId: '8c6cc7b45d2568fb668be6e05b6e5a3b',
|
||||
fields: 'attachments,author,availableActions,board{boardId,title,boardType,payRequired,includedCountries,excludedCountries},channel{channelName,channelCode},totalCommentCount,contentType,createdAt,emotionCount,excludedCountries,includedCountries,isCommentEnabled,isHiddenFromStar,lastModifierMember,notice,officialVideo,plainBody,postId,postVersion,reservation,starReactions,targetMember,thumbnail,title,url,writtenIn,sharedPosts,originPost,blindType',
|
||||
sortType: 'LATEST',
|
||||
limit: ctx.query.limit ? Number(ctx.query.limit) : 20,
|
||||
gcc: userCountry,
|
||||
locale: userLanguage,
|
||||
},
|
||||
headers: {
|
||||
referer: link,
|
||||
},
|
||||
});
|
||||
|
||||
const items = apiResponse.data.data.map((item) => {
|
||||
let description;
|
||||
switch (item.contentType) {
|
||||
case 'POST':
|
||||
description = art(path.join(__dirname, 'templates/post.art'), {
|
||||
post: item.plainBody?.replace(/\r\n/g, '<br><br>').replace(/\n/g, '<br>'),
|
||||
images: item.attachments.photo,
|
||||
});
|
||||
break;
|
||||
case 'VIDEO':
|
||||
description = art(path.join(__dirname, 'templates/video.art'), {
|
||||
link: item.url,
|
||||
image: item.officialVideo.thumb,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
throw `Unknown content type: ${item.contentType}`;
|
||||
}
|
||||
|
||||
return {
|
||||
title: item.title,
|
||||
description,
|
||||
link: item.url,
|
||||
author: item.author.nickname,
|
||||
pubDate: parseDate(item.createdAt),
|
||||
};
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${channelData.channelName} Channel`,
|
||||
description: channelData.channelDescription,
|
||||
link,
|
||||
image: channelData.channelProfileImage,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'vlive.tv': {
|
||||
_name: 'V LIVE',
|
||||
'.': [
|
||||
{
|
||||
title: 'Board',
|
||||
docs: 'https://docs.rsshub.app/en/live.html#v-live',
|
||||
source: '/channel/:board/board/:board',
|
||||
target: '/vlive/channel/:board/board/:board',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/channel/:channel/board/:board', require('./index'));
|
||||
};
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
{{ if post }}
|
||||
{{@ post }}
|
||||
{{ /if }}
|
||||
{{ if images }}
|
||||
{{ each images image }}
|
||||
<img src="{{ image.url }}">
|
||||
{{ /each }}
|
||||
{{ /if }}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{{ if image }}
|
||||
<a href="{{ link }}"><img src="{{ image }}"></a>
|
||||
{{ /if }}
|
||||
Loading…
Reference in New Issue