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.
feat(route): support medium (DIYgod#12475)
* feat(route): support medium * docs(route): support medium * feat(medium): add radar.js * Update docs/blog.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update docs/blog.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update docs/blog.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update docs/blog.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update docs/en/blog.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/medium/tag.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/medium/router.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/medium/maintainer.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update docs/en/blog.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update docs/en/blog.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update docs/en/blog.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/medium/following.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/medium/for-you.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/medium/list.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * chore(medium): update graphql --------- Co-authored-by: Tony <TonyRL@users.noreply.github.com>
- Loading branch information
Showing
15 changed files
with
551 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const config = require('@/config').value; | ||
|
||
const parseArticle = require('./parse-article.js'); | ||
const { getFollowingFeedQuery } = require('./graphql.js'); | ||
|
||
module.exports = async (ctx) => { | ||
const user = ctx.params.user; | ||
|
||
const cookie = config.medium.cookies[user]; | ||
if (cookie === undefined) { | ||
throw Error(`缺少 Medium 用户 ${user} 登录后的 Cookie 值`); | ||
} | ||
|
||
const posts = await getFollowingFeedQuery(user, cookie); | ||
ctx.state.json = posts; | ||
|
||
if (!posts) { | ||
// login failed | ||
throw Error(`Medium 用户 ${user} 的 Cookie 无效或已过期`); | ||
} | ||
|
||
const urls = posts.items.map((data) => data.post.mediumUrl); | ||
|
||
const parsedArticles = await Promise.all(urls.map((url) => parseArticle(ctx, url))); | ||
|
||
ctx.state.data = { | ||
title: `${user} Medium Following`, | ||
link: 'https://medium.com/?feed=following', | ||
item: parsedArticles, | ||
}; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const config = require('@/config').value; | ||
|
||
const parseArticle = require('./parse-article.js'); | ||
const { getWebInlineRecommendedFeedQuery } = require('./graphql.js'); | ||
|
||
module.exports = async (ctx) => { | ||
const user = ctx.params.user; | ||
|
||
const cookie = config.medium.cookies[user]; | ||
if (cookie === undefined) { | ||
throw Error(`缺少 Medium 用户 ${user} 登录后的 Cookie 值`); | ||
} | ||
|
||
const posts = await getWebInlineRecommendedFeedQuery(user, cookie); | ||
ctx.state.json = posts; | ||
|
||
if (!posts) { | ||
// login failed | ||
throw Error(`Medium 用户 ${user} 的 Cookie 无效或已过期`); | ||
} | ||
|
||
const urls = posts.items.map((data) => data.post.mediumUrl); | ||
|
||
const parsedArticles = await Promise.all(urls.map((url) => parseArticle(ctx, url))); | ||
|
||
ctx.state.data = { | ||
title: `${user} Medium For You`, | ||
link: 'https://medium.com/', | ||
item: parsedArticles, | ||
}; | ||
}; |
Oops, something went wrong.