forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(route): xiaohongshu user (DIYgod#11949)
- Loading branch information
Showing
6 changed files
with
74 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
module.exports = { | ||
'/board/:board_id': ['lotosbin'], | ||
'/user/:user_id/:category': ['lotosbin'], | ||
'/user/:user_id/collect': ['lotosbin'], | ||
'/user/:user_id/notes': ['lotosbin'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,30 @@ | ||
const { parseDate } = require('@/utils/parse-date'); | ||
const timezone = require('@/utils/timezone'); | ||
const { getContent } = require('./util'); | ||
const { getUser } = require('./util'); | ||
|
||
module.exports = async (ctx) => { | ||
const userId = ctx.params.user_id; | ||
const category = ctx.params.category; | ||
const url = `https://www.xiaohongshu.com/user/profile/${userId}`; | ||
|
||
let main; | ||
try { | ||
main = await getContent(url, ctx.cache); | ||
} catch (e) { | ||
throw Error('滑块验证'); | ||
} | ||
const userDetail = main.userDetail; | ||
const description = `${userDetail.nickname} • 小红书 / RED`; | ||
if (category === 'notes') { | ||
const list = main.notesDetail; | ||
const resultItem = list.map((item) => ({ | ||
title: item.title, | ||
link: `https://www.xiaohongshu.com/discovery/item/${item.id}`, | ||
description: `<img src ="${item.cover.url.split('?imageView2')[0]}"><br>${item.title}`, | ||
author: item.user.nickname, | ||
pubDate: timezone(parseDate(item.time), 8), | ||
})); | ||
const content = await getUser(url, ctx.cache); | ||
|
||
const title = `小红书-${userDetail.nickname}-笔记`; | ||
ctx.state.data = { | ||
title, | ||
link: url, | ||
item: resultItem, | ||
description, | ||
}; | ||
} else if (category === 'album') { | ||
const list = main.albumDetail; | ||
const resultItem = list.map((item) => ({ | ||
title: item.title, | ||
link: `https://www.xiaohongshu.com/board/${item.id}`, | ||
description: item.images.map((it) => `<img src ="${it.split('?imageView2')[0]}">`).join(`<br>`), | ||
const { otherInfo, user_posted, collect } = content; | ||
const title = `${otherInfo.data.basic_info.nickname} - ${category === 'notes' ? '笔记' : '收藏'} • 小红书 / RED`; | ||
const description = otherInfo.data.basic_info.desc; | ||
const image = otherInfo.data.basic_info.imageb || otherInfo.data.basic_info.images; | ||
|
||
const items = (category, user_posted, collect) => | ||
(category === 'notes' ? user_posted : collect).data.notes.map((item) => ({ | ||
title: item.display_title, | ||
link: `${url}/${item.note_id}`, | ||
description: `<img src ="${item.cover.url}"><br>${item.display_title}`, | ||
author: item.user.nickname, | ||
})); | ||
|
||
const title = `小红书-${userDetail.nickname}-专辑`; | ||
ctx.state.data = { | ||
title, | ||
link: url, | ||
item: resultItem, | ||
description, | ||
}; | ||
} | ||
ctx.state.data = { | ||
title, | ||
description, | ||
image, | ||
link: url, | ||
item: items(category, user_posted, collect), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters