mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 20:27:52 +08:00
fix(algocasts): 修复无法正常获取到 ID 的问题 & feat: 增加 Soul 路由 (#2818)
This commit is contained in:
@@ -330,4 +330,24 @@
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
'algocasts.io': {
|
||||||
|
_name: 'AlgoCasts',
|
||||||
|
'.': [
|
||||||
|
{
|
||||||
|
title: '视频更新',
|
||||||
|
docs: 'https://docs.rsshub.app/programming.html#algocasts',
|
||||||
|
source: '/episodes',
|
||||||
|
target: '/algocasts',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
'soulapp.cn': {
|
||||||
|
_name: 'Soul',
|
||||||
|
'.': [
|
||||||
|
{
|
||||||
|
title: '瞬间更新',
|
||||||
|
docs: 'https://docs.rsshub.app/social-media.html#soul',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -350,6 +350,12 @@ pageClass: routes
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
## Soul
|
||||||
|
|
||||||
|
### 瞬间更新
|
||||||
|
|
||||||
|
<Route author="ImSingee" example="/soul/Y2w2aTNWQVBLOU09" path="/soul:id" :paramsDesc="['用户 id, 分享用户主页时的 URL 的 userIdEcpt 参数']"></Route>
|
||||||
|
|
||||||
## Telegram
|
## Telegram
|
||||||
|
|
||||||
### 频道
|
### 频道
|
||||||
|
|||||||
@@ -1632,6 +1632,9 @@ router.get('/hanime/video', require('./routes/hanime/video'));
|
|||||||
router.get('/gouhuo/news/:category', require('./routes/gouhuo'));
|
router.get('/gouhuo/news/:category', require('./routes/gouhuo'));
|
||||||
router.get('/gouhuo/strategy', require('./routes/gouhuo/strategy'));
|
router.get('/gouhuo/strategy', require('./routes/gouhuo/strategy'));
|
||||||
|
|
||||||
|
// Soul
|
||||||
|
router.get('/soul/:id', require('./routes/soul'));
|
||||||
|
|
||||||
// 单向空间
|
// 单向空间
|
||||||
router.get('/owspace/read/:type?', require('./routes/owspace/read'));
|
router.get('/owspace/read/:type?', require('./routes/owspace/read'));
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,11 @@ const makeFull = async (ctx, infos) => {
|
|||||||
|
|
||||||
const badges = [];
|
const badges = [];
|
||||||
$('.badge').each((index, badge) => {
|
$('.badge').each((index, badge) => {
|
||||||
badges.push($(badge).text());
|
const text = $(badge).text();
|
||||||
|
|
||||||
|
if (text !== '讨论') {
|
||||||
|
badges.push(text);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
info.description = `<h1>${info.title}</h1><div>${badges.join(' | ')}</div><div>${$('#my-content p').html()}</div>`;
|
info.description = `<h1>${info.title}</h1><div>${badges.join(' | ')}</div><div>${$('#my-content p').html()}</div>`;
|
||||||
@@ -79,11 +83,9 @@ module.exports = async (ctx) => {
|
|||||||
$('tr')
|
$('tr')
|
||||||
.slice(1)
|
.slice(1)
|
||||||
.each((i, e) => {
|
.each((i, e) => {
|
||||||
const id = parseInt(
|
const id = $(e)
|
||||||
$(e)
|
.find('th')
|
||||||
.find('th')
|
.text();
|
||||||
.text()
|
|
||||||
);
|
|
||||||
const titleLabel = $(e).find('td a');
|
const titleLabel = $(e).find('td a');
|
||||||
const title = `${id}. ${titleLabel.text()}`;
|
const title = `${id}. ${titleLabel.text()}`;
|
||||||
const episode = titleLabel
|
const episode = titleLabel
|
||||||
|
|||||||
71
lib/routes/soul/index.js
Normal file
71
lib/routes/soul/index.js
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
|
||||||
|
const generateResponse = async (info, items) => ({
|
||||||
|
// 源标题
|
||||||
|
title: `「${info.name}」的瞬间`,
|
||||||
|
// 源链接
|
||||||
|
link: `https://w3.soulapp-inc.cn/activity/#/web/user?userIdEcpt=${info.id}`,
|
||||||
|
item: items.map((item) => ({
|
||||||
|
title: `「${info.name}」的新瞬间:${item.pureContent}`,
|
||||||
|
author: info.name,
|
||||||
|
description: item.content,
|
||||||
|
pubDate: new Date(item.createTime).toUTCString(),
|
||||||
|
guid: item.id,
|
||||||
|
link: `https://w3.soulapp-inc.cn/activity/#/web/topic/detail?postIdEcpt=${item.id}`,
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const userIdEcpt = ctx.params.id;
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: 'https://api.soulapp.cn/html/v2/post/homepage?userIdEcpt=' + userIdEcpt,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 瞬间信息(数组)
|
||||||
|
let items = response.data.data;
|
||||||
|
|
||||||
|
// 用户信息
|
||||||
|
const info = {
|
||||||
|
id: userIdEcpt,
|
||||||
|
name: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (items.length === 0) {
|
||||||
|
// 未发表过任何瞬间
|
||||||
|
const infoResponse = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: 'https://api.soulapp.cn/html/v2/user/info?userIdEcpt=' + userIdEcpt,
|
||||||
|
});
|
||||||
|
|
||||||
|
const infoData = infoResponse.data.data;
|
||||||
|
|
||||||
|
info.name = infoData.signature;
|
||||||
|
} else {
|
||||||
|
// 发表过瞬间 -> 直接从瞬间信息取用户名
|
||||||
|
info.name = items[0].signature;
|
||||||
|
}
|
||||||
|
|
||||||
|
items = items.map((item) => {
|
||||||
|
const pureContent = `${item.content}`;
|
||||||
|
let content = pureContent.replace(/\n/, '<br />');
|
||||||
|
|
||||||
|
if (item.attachments) {
|
||||||
|
for (const attachment of item.attachments) {
|
||||||
|
if (attachment.type === 'IMAGE') {
|
||||||
|
content += '<br />';
|
||||||
|
content += `<img src="${attachment.fileUrl}" />`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: item.postIdEcpt,
|
||||||
|
pureContent,
|
||||||
|
content,
|
||||||
|
createTime: item.createTime,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
ctx.state.data = await generateResponse(info, items);
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user