Skip to content
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
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f99b215
[feat(routes)] Add ipsw.dev support
rien7 Sep 30, 2024
416603a
Merge branch 'DIYgod:master' into master
rien7 Oct 9, 2024
eab9805
fix(xiaohongshu): fix note fulltext
rien7 Oct 9, 2024
797f6e5
add config
rien7 Oct 9, 2024
a5ee720
feat: add fulltext with cookie
rien7 Oct 10, 2024
25ba2e4
feat: add fulltext with cookie
rien7 Oct 10, 2024
fe9df5c
Merge branch 'refs/heads/master' into xiaohongshu
rien7 Oct 10, 2024
c79a5e1
Merge branch 'DIYgod:master' into xiaohongshu
rien7 Oct 10, 2024
1018ff2
[feat(routes)] Add ipsw.dev support
rien7 Sep 30, 2024
fb841e9
Merge branch 'DIYgod:master' into ipswdev
rien7 Oct 10, 2024
637c1ec
feat: add fulltext with cookie
rien7 Oct 10, 2024
3434cd4
fix: config
rien7 Oct 10, 2024
6321a65
Merge branch 'refs/heads/xiaohongshu'
rien7 Oct 10, 2024
5399b18
fix: await in loop
rien7 Oct 10, 2024
2433d83
Merge branch 'refs/heads/xiaohongshu'
rien7 Oct 10, 2024
735da7c
fix: use art-template
rien7 Oct 11, 2024
650c858
fix: remove ipswdev in other branch
rien7 Oct 11, 2024
3d07a8d
Merge branch 'refs/heads/xiaohongshu'
rien7 Oct 11, 2024
2e2f41b
Merge branch 'refs/heads/ipswdev'
rien7 Oct 11, 2024
09cfcee
fix: add pubDate
rien7 Oct 14, 2024
9ef6ef4
Merge branch 'refs/heads/xiaohongshu'
rien7 Oct 14, 2024
db4d9d4
fix(route) ikea/cn/low-price
dddaniel1 Nov 24, 2024
7472a52
Merge branch 'master' of https://github.com/DIYgod/RSSHub
dddaniel1 Dec 13, 2024
00dcea2
Merge remote-tracking branch 'origin/master'
dddaniel1 Dec 13, 2024
35dc219
feat(route/aves-art): Add 小鸟文学
dddaniel1 Dec 13, 2024
378237e
feat(route/aves-art): Add 小鸟文学 (fix code review problem)
dddaniel1 Dec 14, 2024
b8f10aa
feat(route/aves-art): Add 小鸟文学 (fix code review problem)
dddaniel1 Dec 14, 2024
c958b05
feat(route/aves-art): Add 小鸟文学 (fix author display )
dddaniel1 Dec 14, 2024
47634f7
feat(route/aves-art): Add 小鸟文学 (添加最新文章 )
dddaniel1 Dec 14, 2024
084eb9a
更新 index.ts add pipe in header,fix description
dddaniel1 Dec 16, 2024
97009bb
更新 index.ts
dddaniel1 Dec 19, 2024
b2f9c67
更新 index.ts
dddaniel1 Dec 19, 2024
47ee28d
更新 index.ts
dddaniel1 Dec 19, 2024
f8aaee5
feat(route/aves-art): Add 小鸟文学 (修改緩存Key )
dddaniel1 Dec 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions lib/routes/aves/index.ts
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: ['other'],
example: '/aves',
dddaniel1 marked this conversation as resolved.
Show resolved Hide resolved
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(String(id), async () => {
dddaniel1 marked this conversation as resolved.
Show resolved Hide resolved
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,
};
}
6 changes: 6 additions & 0 deletions lib/routes/aves/namespace.ts
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',
};
Loading