mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-29 18:06:31 +08:00
feat(rotue): 全民K歌 (#7768)
* add route&doc 全民K歌 * add route&doc 全民K歌 * add route&doc 全民K歌 * fix: update reply guid * fix: 修复 guid 和 缓存 key 不唯一的问题 * feat: migrate to v2 Co-authored-by: zhangxiang012<zhangxiang012@users.noreply.github.com> Co-authored-by: zhangxiang <zhangxiang@ffrj.net> Co-authored-by: zhangxiang012 <zhangxiang012@users.noreply.github.com>
This commit is contained in:
co-authored by
zhangxiang012
zhangxiang
parent
ee9cef02dc
commit
c110ad0502
@@ -1146,6 +1146,16 @@ YouTube 官方亦有提供频道 RSS,形如 <https://www.youtube.com/feeds/vid
|
||||
|
||||
<Route author="ihewro" example="/meipai/user/56537299" path="/meipai/user/:id" :paramsDesc="['用户 id, 可在 分享出去获得的用户主页 URL 中找到']"/>
|
||||
|
||||
## 全民 K 歌
|
||||
|
||||
### 用户作品列表
|
||||
|
||||
<Route author="zhangxiang012" example="/qq/kg/639a9a86272c308e33" path="/qq/kg/:userId" :paramsDesc="['用户 ID, 可在对应页面的 URL 中找到']" radar="1" rssaid="1" supportPodcast="1"/>
|
||||
|
||||
### 用户作品评论动态
|
||||
|
||||
<Route author="zhangxiang012" example="/qq/kg/reply/OhXHMdO1VxLWQOOm" path="/qq/kg/reply/:playId" :paramsDesc="['音频页 ID, 可在对应页面的 URL 中找到']" radar="1" rssaid="1"/>
|
||||
|
||||
## 数字尾巴
|
||||
|
||||
### 首页
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
const got = require('@/utils/got');
|
||||
const { JSDOM } = require('jsdom');
|
||||
|
||||
module.exports = {
|
||||
getPlayInfo: async (ctx, shareId, ksong_mid = '') => {
|
||||
const link = `https://node.kg.qq.com/play?s=${shareId}`;
|
||||
const cache_key = ksong_mid ? `ksong:${ksong_mid}` : link;
|
||||
const data = await ctx.cache.tryGet(cache_key, async () => {
|
||||
const response = await got(link);
|
||||
const { window } = new JSDOM(response.data, {
|
||||
runScripts: 'dangerously',
|
||||
});
|
||||
const data = window.__DATA__;
|
||||
const name = data.detail.song_name;
|
||||
const description = data.detail.content;
|
||||
const author = data.detail.nick;
|
||||
const itunes_item_image = data.detail.cover;
|
||||
|
||||
const enclosure_url = data.detail.playurl;
|
||||
ksong_mid = ksong_mid ? ksong_mid : data.detail.ksong_mid;
|
||||
const ctime = data.detail.ctime;
|
||||
const comments = data.detail.comments;
|
||||
|
||||
return { name, link, description, author, enclosure_url, ksong_mid, ctime, itunes_item_image, comments };
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
const cache = require('./cache');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const playId = ctx.params.playId;
|
||||
const url = `https://node.kg.qq.com/play?s=${playId}`;
|
||||
const play_item = await cache.getPlayInfo(ctx, playId, '');
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${play_item.name} - ${play_item.author} 的评论`,
|
||||
link: url,
|
||||
image: play_item.itunes_item_image,
|
||||
allowEmpty: true,
|
||||
item: play_item.comments.map((item) => ({
|
||||
title: `${item.nick}:${item.content}`,
|
||||
pubDate: parseDate(item.ctime * 1000),
|
||||
link: url,
|
||||
guid: `ksong:${play_item.ksong_mid}:${item.comment_id}`,
|
||||
})),
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
const got = require('@/utils/got');
|
||||
const { JSDOM } = require('jsdom');
|
||||
const cache = require('./cache');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const userId = ctx.params.userId;
|
||||
const url = `https://node.kg.qq.com/personal?uid=${userId}`;
|
||||
const response = await got(url);
|
||||
|
||||
const { window } = new JSDOM(response.data, {
|
||||
runScripts: 'dangerously',
|
||||
});
|
||||
const data = window.__DATA__;
|
||||
const author = data.data.nickname;
|
||||
const authorimg = data.data.head_img_url;
|
||||
const ugcList = data.data.ugclist;
|
||||
|
||||
const items = await Promise.all(
|
||||
ugcList.map(async (item) => {
|
||||
const link = `https://node.kg.qq.com/play?s=${item.shareid}`;
|
||||
const item_info = await cache.getPlayInfo(ctx, item.shareid, item.ksong_mid);
|
||||
|
||||
const single = {
|
||||
title: item.title || '',
|
||||
description: item_info.description,
|
||||
link,
|
||||
guid: `ksong:${item.ksong_mid}`,
|
||||
author,
|
||||
pubDate: parseDate(item_info.ctime * 1000) || parseDate(item.ctime, 'X'),
|
||||
itunes_item_image: item_info.itunes_item_image || item.avatar,
|
||||
enclosure_url: item_info.enclosure_url,
|
||||
enclosure_type: 'audio/x-m4a',
|
||||
};
|
||||
|
||||
return single;
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${author} - 全民K歌`,
|
||||
link: url,
|
||||
description: data.share.content,
|
||||
allowEmpty: true,
|
||||
item: items,
|
||||
image: authorimg,
|
||||
itunes_author: author,
|
||||
itunes_category: '全民K歌',
|
||||
};
|
||||
};
|
||||
@@ -1,5 +1,7 @@
|
||||
module.exports = {
|
||||
'/ac/comic/:id': ['nczitzk'],
|
||||
'/ac/rank/:type?/:time?': ['nczitzk'],
|
||||
'/kg/:userId': ['zhangxiang012'],
|
||||
'/kg/reply/:playId': ['zhangxiang012'],
|
||||
'/live/:id': ['nczitzk'],
|
||||
};
|
||||
|
||||
@@ -23,5 +23,19 @@ module.exports = {
|
||||
target: '/qq/live/:id',
|
||||
},
|
||||
],
|
||||
'node.kg': [
|
||||
{
|
||||
title: '用户作品列表 - 全民 K 歌',
|
||||
docs: 'https://docs.rsshub.app/live.html#qi-e-zhi-bo-zhi-bo-jian-ti-xing',
|
||||
source: ['/personal'],
|
||||
target: (_params, url) => `/qq/kg/${new URL(url).searchParams.get('uid')}`,
|
||||
},
|
||||
{
|
||||
title: '用户作品评论动态 - 全民 K 歌',
|
||||
docs: 'https://docs.rsshub.app/live.html#qi-e-zhi-bo-zhi-bo-jian-ti-xing',
|
||||
source: ['/play'],
|
||||
target: (_params, url) => `/qq/kg/${new URL(url).searchParams.get('s')}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/ac/comic/:id?', require('./ac/comic'));
|
||||
router.get('/ac/rank/:type?/:time?', require('./ac/rank'));
|
||||
router.get('/kg/:userId', require('./kg/user'));
|
||||
router.get('/kg/reply/:playId', require('./kg/reply'));
|
||||
router.get('/live/:id', require('./live'));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user