parent
a08c2cfa22
commit
b5210ac9d9
|
|
@ -420,6 +420,8 @@ RSSHub 提供下列 API 接口:
|
|||
|
||||
<route name="话题" author="xyqfer" example="/zhihu/topic/19828946" path="/zhihu/topic/:topicId" :paramsDesc="['话题 id']"/>
|
||||
|
||||
<route name="用户想法" author="xyqfer" example="/zhihu/people/pins/kan-dan-45" path="/zhihu/people/pins/:id" :paramsDesc="['作者 id, 可在用户主页 URL 中找到']"/>
|
||||
|
||||
### pixiv
|
||||
|
||||
<route name="用户收藏" author="EYHN" example="/pixiv/user/bookmarks/15288095" path="/pixiv/user/bookmarks/:id" :paramsDesc="['用户 id, 可在用户主页 URL 中找到']"/>
|
||||
|
|
|
|||
|
|
@ -168,6 +168,7 @@ router.get('/zhihu/hotlist', require('./routes/zhihu/hotlist'));
|
|||
router.get('/zhihu/pin/hotlist', require('./routes/zhihu/pin/hotlist'));
|
||||
router.get('/zhihu/question/:questionId', require('./routes/zhihu/question'));
|
||||
router.get('/zhihu/topic/:topicId', require('./routes/zhihu/topic'));
|
||||
router.get('/zhihu/people/pins/:id', require('./routes/zhihu/pin/people'));
|
||||
|
||||
// 妹子图
|
||||
router.get('/mzitu/home/:type?', require('./routes/mzitu/home'));
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
const axios = require('../../../utils/axios');
|
||||
const { generateData } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const {
|
||||
|
|
@ -12,49 +13,6 @@ module.exports = async (ctx) => {
|
|||
title: '知乎想法热榜',
|
||||
link: 'https://www.zhihu.com/',
|
||||
description: '整点更新',
|
||||
item: data.map(({ target }) => {
|
||||
const pubDate = new Date(target.created * 1000).toUTCString();
|
||||
const author = target.author.name;
|
||||
const title = `${author}:${target.excerpt_title}`;
|
||||
const link = `https://www.zhihu.com/pin/${target.id}`;
|
||||
const description = target.content.reduce((description, item) => {
|
||||
switch (item.type) {
|
||||
case 'text':
|
||||
description += `<div>${item.content}</div>`;
|
||||
break;
|
||||
|
||||
case 'image':
|
||||
description += `<img referrerpolicy="no-referrer" src="${item.url.replace(/_.+\.jpg/g, '.jpg')}" />`;
|
||||
break;
|
||||
|
||||
case 'video':
|
||||
description += `<video
|
||||
controls="controls"
|
||||
width="${item.playlist.hd.width}"
|
||||
height="${item.playlist.hd.height}"
|
||||
poster="${item.cover_info.thumbnail}"
|
||||
src="${item.playlist.hd.play_url}"
|
||||
>`;
|
||||
break;
|
||||
|
||||
case 'link':
|
||||
description += `<div><a href="${item.url}">${item.title}</a><br><img referrerpolicy="no-referrer" src="${item.image_url}" /></div>`;
|
||||
break;
|
||||
|
||||
default:
|
||||
description += '未知类型,请点击<a href="https://github.com/DIYgod/RSSHub/issues">链接</a>提交issue';
|
||||
}
|
||||
|
||||
return description;
|
||||
}, `<a href="https://www.zhihu.com${target.author.url}">${author}</a>:`);
|
||||
|
||||
return {
|
||||
title,
|
||||
description,
|
||||
author,
|
||||
pubDate,
|
||||
link,
|
||||
};
|
||||
}),
|
||||
item: generateData(data),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
const axios = require('../../../utils/axios');
|
||||
const { generateData } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id } = ctx.params;
|
||||
|
||||
const {
|
||||
data: { data },
|
||||
} = await axios({
|
||||
method: 'get',
|
||||
url: `https://www.zhihu.com/api/v4/members/${id}/pins?offset=0&limit=20&includes=data%5B*%5D.upvoted_followees%2Cadmin_closed_comment`,
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${data[0].author.name}的知乎想法`,
|
||||
link: `https://www.zhihu.com/people/${id}/pins`,
|
||||
item: generateData(data),
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
module.exports = {
|
||||
generateData: (data) =>
|
||||
data.map((item) => {
|
||||
const target = item.target ? item.target : item;
|
||||
const pubDate = new Date(target.created * 1000).toUTCString();
|
||||
const author = target.author.name;
|
||||
const title = `${author}:${target.excerpt_title}`;
|
||||
const link = `https://www.zhihu.com/pin/${target.id}`;
|
||||
const description = target.content.reduce((description, item) => {
|
||||
switch (item.type) {
|
||||
case 'text':
|
||||
description += `<div>${item.content}</div>`;
|
||||
break;
|
||||
|
||||
case 'image':
|
||||
description += `<img referrerpolicy="no-referrer" src="${item.url.replace(/_.+\.jpg/g, '.jpg')}" />`;
|
||||
break;
|
||||
|
||||
case 'video':
|
||||
description += `<video
|
||||
controls="controls"
|
||||
width="${item.playlist.hd.width}"
|
||||
height="${item.playlist.hd.height}"
|
||||
poster="${item.cover_info.thumbnail}"
|
||||
src="${item.playlist.hd.play_url}"
|
||||
>`;
|
||||
break;
|
||||
|
||||
case 'link':
|
||||
description += `<div><a href="${item.url}">${item.title}</a><br><img referrerpolicy="no-referrer" src="${item.image_url}" /></div>`;
|
||||
break;
|
||||
|
||||
default:
|
||||
description += '未知类型,请点击<a href="https://github.com/DIYgod/RSSHub/issues">链接</a>提交issue';
|
||||
}
|
||||
|
||||
return description;
|
||||
}, `<a href="https://www.zhihu.com${target.author.url}">${author}</a>:`);
|
||||
|
||||
return {
|
||||
title,
|
||||
description,
|
||||
author,
|
||||
pubDate,
|
||||
link,
|
||||
};
|
||||
}),
|
||||
};
|
||||
Loading…
Reference in New Issue