-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add aves art route(前身为好奇心日报) #17885
Closed
Closed
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
f99b215
[feat(routes)] Add ipsw.dev support
rien7 416603a
Merge branch 'DIYgod:master' into master
rien7 eab9805
fix(xiaohongshu): fix note fulltext
rien7 797f6e5
add config
rien7 a5ee720
feat: add fulltext with cookie
rien7 25ba2e4
feat: add fulltext with cookie
rien7 fe9df5c
Merge branch 'refs/heads/master' into xiaohongshu
rien7 c79a5e1
Merge branch 'DIYgod:master' into xiaohongshu
rien7 1018ff2
[feat(routes)] Add ipsw.dev support
rien7 fb841e9
Merge branch 'DIYgod:master' into ipswdev
rien7 637c1ec
feat: add fulltext with cookie
rien7 3434cd4
fix: config
rien7 6321a65
Merge branch 'refs/heads/xiaohongshu'
rien7 5399b18
fix: await in loop
rien7 2433d83
Merge branch 'refs/heads/xiaohongshu'
rien7 735da7c
fix: use art-template
rien7 650c858
fix: remove ipswdev in other branch
rien7 3d07a8d
Merge branch 'refs/heads/xiaohongshu'
rien7 2e2f41b
Merge branch 'refs/heads/ipswdev'
rien7 09cfcee
fix: add pubDate
rien7 9ef6ef4
Merge branch 'refs/heads/xiaohongshu'
rien7 db4d9d4
fix(route) ikea/cn/low-price
dddaniel1 7472a52
Merge branch 'master' of https://github.com/DIYgod/RSSHub
dddaniel1 00dcea2
Merge remote-tracking branch 'origin/master'
dddaniel1 35dc219
feat(route/aves-art): Add 小鸟文学
dddaniel1 378237e
feat(route/aves-art): Add 小鸟文学 (fix code review problem)
dddaniel1 b8f10aa
feat(route/aves-art): Add 小鸟文学 (fix code review problem)
dddaniel1 c958b05
feat(route/aves-art): Add 小鸟文学 (fix author display )
dddaniel1 47634f7
feat(route/aves-art): Add 小鸟文学 (添加最新文章 )
dddaniel1 084eb9a
更新 index.ts add pipe in header,fix description
dddaniel1 97009bb
更新 index.ts
dddaniel1 b2f9c67
更新 index.ts
dddaniel1 47ee28d
更新 index.ts
dddaniel1 f8aaee5
feat(route/aves-art): Add 小鸟文学 (修改緩存Key )
dddaniel1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { Route } from '@/types'; | ||
import got from '@/utils/got'; | ||
import cache from '@/utils/cache'; | ||
|
||
export const route: Route = { | ||
path: '/:category', | ||
categories: ['reading'], | ||
example: '/aves/current', | ||
parameters: { category: '分类,见下表' }, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
name: '分类', | ||
maintainers: ['dddaniel1'], | ||
handler, | ||
description: `| 诗歌 | 小说 | 专栏 | 档案 | 非虚构 | all | 最新文章 | | ||
| -------- | -------- | -------- | -------- | -------- | -------- | -------- | | ||
| 1 | 2 | 3 | 4 | 5 | all | current |`, | ||
}; | ||
|
||
async function handler(ctx) { | ||
const { category } = ctx.req.param(); | ||
const currentUrl = 'http://aves.art/'; | ||
const rootUrl = 'https://app.aves.art'; | ||
const categoryPath = '/api/lb_catalog/get_catalog_post'; | ||
const currentPath = '/api/lb_periodical/current'; | ||
const detailPath = '/api/lb_post/detail'; | ||
const cateMapping = new Map([ | ||
['1', '诗歌'], | ||
['2', '小说'], | ||
['3', '专栏'], | ||
['4', '档案'], | ||
['5', '非虚构'], | ||
['all', 'all'], | ||
['current', '最新文章'], | ||
]); | ||
const title = `小鸟文学(好奇心日报) - ${cateMapping.get(category)}`; | ||
const description = | ||
'小鸟文学是个独立 App,它的表达在不停变化,认识它的人都有不同的机缘。此前你可能会从各种短篇小说、长篇访谈,人类学田野笔记或者和它的前身《好奇心日报》的联系认识到它,如今它还在持续作出调整。不过它的价值观一以贯之:和我们所处的世界保持距离,与此同时又不会袖手旁观。'; | ||
let articleIds: any[] = []; | ||
if (category === 'all') { | ||
const allCategoryId = ['1', '2', '3', '4', '5']; | ||
const allCategory = await Promise.all(allCategoryId.map((item) => got.post(`${rootUrl}${categoryPath}`, { json: { catalogId: item } }))); | ||
for (const item of allCategory) { | ||
if (item?.data.code === 200) { | ||
articleIds.push(...item.data.result); | ||
} | ||
} | ||
articleIds = articleIds.flat().map((item) => item.id); | ||
} else if (category === 'current') { | ||
const { data } = await got.post(`${rootUrl}${currentPath}`); | ||
if (data.code === 200) { | ||
articleIds.push(...data.result.lbPostList); | ||
} | ||
articleIds = articleIds.map((item) => item.id); | ||
} else { | ||
const { data } = await got.post(`${rootUrl}${categoryPath}`, { json: { catalogId: category } }); | ||
if (data.code === 200) { | ||
articleIds.push(...data.result); | ||
} | ||
articleIds = articleIds.map((item) => item.id); | ||
} | ||
const articles: any[] = await Promise.all( | ||
articleIds.map((id) => | ||
cache.tryGet('articleId:' + id, async () => { | ||
const res: any = await got.post(`${rootUrl}${detailPath}`, { json: { id } }); | ||
if (res.data.code === 200) { | ||
return { | ||
title: res.data.result.title, | ||
description: res.data.result.content, | ||
author: JSON.parse(res.data.result.author)[0].name, | ||
pubDate: res.data.result.publishedAt, | ||
}; | ||
} | ||
return {}; | ||
}) | ||
) | ||
); | ||
return { | ||
item: articles, | ||
title, | ||
link: currentUrl, | ||
description, | ||
language: 'zh', | ||
image: 'https://imagedelivery.net/kDRCweMmqLnTPNlbum-pYA/prod/avatar/2798eec0-9a13-4a2f-85cf-27d00832aee3.jpeg/public', | ||
allowEmpty: true, | ||
}; | ||
} |
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,6 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: '小鸟文学', | ||
url: 'aves.art', | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the namespace to the cache key