diff --git a/docs/en/social-media.md b/docs/en/social-media.md index e7b8c6997..4a1be53ab 100644 --- a/docs/en/social-media.md +++ b/docs/en/social-media.md @@ -75,7 +75,7 @@ These feed do not include boosts (a.k.a. reblogs). RSSHub provides a feed for us ### User Profile - + ## pixiv diff --git a/docs/social-media.md b/docs/social-media.md index af285a3fd..d54d75a2c 100644 --- a/docs/social-media.md +++ b/docs/social-media.md @@ -363,7 +363,7 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性 ### 用户 - + ## pixiv diff --git a/lib/router.js b/lib/router.js index 6792302cd..1e61f27db 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3024,7 +3024,7 @@ router.get('/furstar/archive/:lang?', require('./routes/furstar/archive')); router.get('/bwu/news', require('./routes/universities/bwu/news')); // Picuki -router.get('/picuki/profile/:id', require('./routes/picuki/profile')); +router.get('/picuki/profile/:id/:displayVideo?', require('./routes/picuki/profile')); // 新榜 router.get('/newrank/wechat/:wxid', require('./routes/newrank/wechat')); diff --git a/lib/routes/picuki/profile.js b/lib/routes/picuki/profile.js index 485c7f159..58ec1921b 100644 --- a/lib/routes/picuki/profile.js +++ b/lib/routes/picuki/profile.js @@ -4,6 +4,7 @@ const chrono = require('chrono-node'); module.exports = async (ctx) => { const id = ctx.params.id; + const displayVideo = ctx.params.displayVideo ? true : false; const url = `https://www.picuki.com/profile/${id}`; @@ -16,13 +17,16 @@ module.exports = async (ctx) => { const list = $('ul.box-photos [data-s="media"]').get(); - ctx.state.data = { - title: `${profile_name} (@${id}) - Picuki`, - link: url, - image: profile_img, - description: profile_description, - item: list.map((post) => { + async function getVideo(url) { + const response = await got.get(url); + const $ = cheerio.load(response.data); + return $('.single-photo').html(); + } + + const items = await Promise.all( + list.map(async (post) => { post = $(post); + const isVideo = post.find('.video-icon').length !== 0 && displayVideo; const post_image = post.find('.post-image').attr('src'); const post_description = post.find('.photo-description').text().trim(); const post_link = post.find('.photo > a').attr('href'); @@ -30,10 +34,18 @@ module.exports = async (ctx) => { return { title: post_description || 'Untitled', author: `@${id}`, - description: `` + (post_description.length > 100 ? `

${post_description}

` : ''), + description: (isVideo ? await getVideo(post_link) : ``) + (post_description.length > 100 ? `

${post_description}

` : ''), link: post_link, pubDate: post_time ? chrono.parseDate(post_time.text()) : new Date(), }; - }), + }) + ); + + ctx.state.data = { + title: `${profile_name} (@${id}) - Picuki`, + link: url, + image: profile_img, + description: profile_description, + item: items, }; };