rsshub 1.0.0-master.f9ec483 → 1.0.0-master.fa1dcc5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/config.ts +42 -1
- package/lib/middleware/access-control.ts +3 -3
- package/lib/middleware/cache.ts +5 -3
- package/lib/middleware/template.test.ts +6 -0
- package/lib/middleware/template.tsx +3 -1
- package/lib/router.js +0 -6
- package/lib/routes/141jav/index.ts +1 -1
- package/lib/routes/141ppv/index.ts +1 -1
- package/lib/routes/36kr/hot-list.ts +1 -1
- package/lib/routes/36kr/index.ts +1 -1
- package/lib/routes/78dm/index.ts +429 -43
- package/lib/routes/78dm/namespace.ts +2 -0
- package/lib/routes/78dm/templates/description.art +17 -0
- package/lib/routes/abc/index.ts +10 -9
- package/lib/routes/aeon/category.ts +1 -1
- package/lib/routes/aeon/type.ts +1 -1
- package/lib/routes/afr/latest.ts +69 -0
- package/lib/routes/afr/namespace.ts +7 -0
- package/lib/routes/afr/navigation.ts +75 -0
- package/lib/routes/afr/query.ts +349 -0
- package/lib/routes/afr/utils.ts +80 -0
- package/lib/routes/aibase/discover.ts +1 -1
- package/lib/routes/aibase/news.ts +1 -1
- package/lib/routes/aibase/topic.ts +1 -1
- package/lib/routes/air-level/index.ts +49 -0
- package/lib/routes/air-level/levelrank.ts +65 -0
- package/lib/routes/air-level/namespace.ts +12 -0
- package/lib/routes/ajcass/namespace.ts +11 -0
- package/lib/routes/ajcass/shxyj.ts +73 -0
- package/lib/routes/alpinelinux/pkgs.ts +2 -2
- package/lib/routes/anime1/anime.ts +1 -1
- package/lib/routes/apnews/utils.ts +6 -2
- package/lib/routes/appleinsider/index.ts +1 -1
- package/lib/routes/aqara/region.ts +1 -1
- package/lib/routes/asus/bios.ts +0 -1
- package/lib/routes/baoyu/index.ts +57 -0
- package/lib/routes/baoyu/namespace.ts +8 -0
- package/lib/routes/bilibili/article.ts +37 -14
- package/lib/routes/bilibili/dynamic.ts +15 -7
- package/lib/routes/bilibili/followings-dynamic.ts +2 -2
- package/lib/routes/bilibili/manga-update.ts +3 -0
- package/lib/routes/bilibili/ranking.ts +188 -117
- package/lib/routes/bilibili/reply.ts +2 -0
- package/lib/routes/bilibili/templates/description.art +2 -0
- package/lib/routes/bing/daily-wallpaper.ts +5 -1
- package/lib/routes/bsky/posts.ts +0 -1
- package/lib/routes/bsky/templates/post.art +8 -1
- package/lib/routes/buaa/lib/space/newbook.ts +1 -1
- package/lib/routes/c114/namespace.ts +2 -0
- package/lib/routes/c114/roll.ts +71 -42
- package/lib/routes/cags/edu/index.ts +84 -0
- package/lib/routes/cags/namespace.ts +9 -0
- package/lib/routes/caixin/article.ts +1 -1
- package/lib/routes/caixin/blog.ts +2 -3
- package/lib/routes/caixin/category.ts +1 -1
- package/lib/routes/caixin/latest.ts +12 -16
- package/lib/routes/caixin/namespace.ts +1 -1
- package/lib/routes/caixin/utils-fulltext.ts +51 -0
- package/lib/routes/caixin/utils.ts +37 -37
- package/lib/routes/cara/likes.ts +1 -1
- package/lib/routes/cara/portfolio.ts +1 -1
- package/lib/routes/cara/timeline.ts +1 -1
- package/lib/routes/ccfa/index.ts +11 -11
- package/lib/routes/chub/characters.ts +1 -1
- package/lib/routes/cnbeta/namespace.ts +1 -1
- package/lib/routes/cngold/index.ts +195 -0
- package/lib/routes/cngold/namespace.ts +9 -0
- package/lib/routes/cnki/author.ts +120 -48
- package/lib/routes/cnki/utils.ts +4 -4
- package/lib/routes/coomer/artist.ts +1 -1
- package/lib/routes/coomer/namespace.ts +1 -1
- package/lib/routes/coomer/posts.ts +2 -2
- package/lib/routes/coomer/utils.ts +1 -1
- package/lib/routes/cpcaauto/index.ts +22 -22
- package/lib/routes/cs/zzkx.ts +1 -1
- package/lib/routes/csdn/blog.ts +17 -13
- package/lib/routes/cybersecurityventures/namespace.ts +7 -0
- package/lib/routes/cybersecurityventures/news.ts +121 -0
- package/lib/routes/cybersecurityventures/types.ts +17 -0
- package/lib/routes/daily/discussed.ts +22 -21
- package/lib/routes/daily/index.ts +14 -11
- package/lib/routes/daily/namespace.ts +1 -1
- package/lib/routes/daily/source.ts +186 -0
- package/lib/routes/daily/upvoted.ts +17 -17
- package/lib/routes/daily/user.ts +6 -23
- package/lib/routes/daily/utils.ts +27 -32
- package/lib/routes/dataguidance/index.ts +19 -30
- package/lib/routes/dcfever/news.ts +1 -1
- package/lib/routes/dcfever/reviews.ts +1 -1
- package/lib/routes/dcfever/trading-search.ts +1 -1
- package/lib/routes/dcfever/trading.ts +1 -1
- package/lib/routes/deeplearning/namespace.ts +3 -1
- package/lib/routes/deeplearning/templates/description.art +21 -0
- package/lib/routes/deeplearning/the-batch.ts +296 -0
- package/lib/routes/deepmind/blog.ts +1 -1
- package/lib/routes/digitalcameraworld/news.ts +1 -1
- package/lib/routes/discord/discord-api.ts +44 -2
- package/lib/routes/discord/search.ts +106 -0
- package/lib/routes/dn/news.ts +1 -1
- package/lib/routes/dockerhub/repositories.ts +42 -0
- package/lib/routes/dongqiudi/daily.ts +1 -1
- package/lib/routes/dw/namespace.ts +6 -0
- package/lib/routes/dw/news.ts +89 -0
- package/lib/routes/dw/rss.ts +62 -0
- package/lib/routes/dw/templates/description.art +23 -0
- package/lib/routes/dw/templates/liveblog.art +13 -0
- package/lib/routes/dw/templates/video.art +14 -0
- package/lib/routes/dw/utils.ts +172 -0
- package/lib/routes/ecnu/jwc.ts +5 -1
- package/lib/routes/espn/news.ts +1 -1
- package/lib/routes/fashionnetwork/namespace.ts +1 -1
- package/lib/routes/flyert/forum.ts +99 -0
- package/lib/routes/flyert/namespace.ts +1 -0
- package/lib/routes/flyert/templates/description.art +21 -0
- package/lib/routes/flyert/util.ts +188 -0
- package/lib/routes/follow/profile.ts +2 -2
- package/lib/routes/foresightnews/article.ts +1 -1
- package/lib/routes/foresightnews/column.ts +1 -1
- package/lib/routes/foresightnews/index.ts +3 -1
- package/lib/routes/foresightnews/news.ts +1 -1
- package/lib/routes/freecomputerbooks/index.ts +0 -10
- package/lib/routes/ftm/index.ts +1 -1
- package/lib/routes/furaffinity/art.ts +85 -0
- package/lib/routes/furaffinity/browse.ts +58 -0
- package/lib/routes/furaffinity/commissions.ts +55 -0
- package/lib/routes/furaffinity/home.ts +80 -0
- package/lib/routes/furaffinity/journal-comments.ts +64 -0
- package/lib/routes/furaffinity/journals.ts +56 -0
- package/lib/routes/furaffinity/namespace.ts +7 -0
- package/lib/routes/furaffinity/search.ts +72 -0
- package/lib/routes/furaffinity/shouts.ts +56 -0
- package/lib/routes/furaffinity/status.ts +58 -0
- package/lib/routes/furaffinity/submission-comments.ts +64 -0
- package/lib/{routes-deprecated/furaffinity/user.js → routes/furaffinity/user.ts} +53 -41
- package/lib/routes/furaffinity/watchers.ts +62 -0
- package/lib/routes/furaffinity/watching.ts +62 -0
- package/lib/routes/google/developers.ts +71 -0
- package/lib/routes/google/news.ts +26 -6
- package/lib/routes/gov/cbirc/index.ts +35 -35
- package/lib/routes/hamel/index.ts +81 -0
- package/lib/routes/hamel/namespace.ts +7 -0
- package/lib/routes/hellogithub/volume.ts +3 -0
- package/lib/routes/hket/index.ts +13 -1
- package/lib/routes/hostmonit/cloudflareyesv6.ts +1 -1
- package/lib/routes/hrbeu/sec/list.ts +80 -0
- package/lib/routes/hrbust/jwzx.ts +6 -0
- package/lib/routes/hunau/gfxy/index.ts +1 -1
- package/lib/routes/hunau/ied.ts +1 -1
- package/lib/routes/hunau/jwc.ts +1 -1
- package/lib/routes/hunau/xky/index.ts +1 -1
- package/lib/routes/hust/gs.ts +4 -3
- package/lib/routes/idolmaster/namespace.ts +7 -0
- package/lib/routes/idolmaster/news.ts +112 -0
- package/lib/routes/ieee/author.ts +95 -0
- package/lib/routes/ikea/cn/low-price.ts +2 -1
- package/lib/routes/imdb/chart.ts +1 -1
- package/lib/routes/inspirehep/author.ts +9 -1
- package/lib/routes/isct/namespace.ts +11 -0
- package/lib/routes/isct/news.ts +66 -0
- package/lib/routes/javtrailers/casts.ts +41 -0
- package/lib/routes/javtrailers/categories.ts +40 -0
- package/lib/routes/javtrailers/namespace.ts +7 -0
- package/lib/routes/javtrailers/studios.ts +39 -0
- package/lib/routes/javtrailers/templates/description.art +31 -0
- package/lib/routes/javtrailers/types.ts +59 -0
- package/lib/routes/javtrailers/utils.ts +48 -0
- package/lib/routes/jiemian/list.ts +1 -1
- package/lib/routes/jiuyangongshe/community.ts +1 -1
- package/lib/routes/jlu/phy/index.ts +55 -0
- package/lib/routes/joins/chinese.ts +13 -13
- package/lib/routes/kcna/news.ts +7 -5
- package/lib/routes/keep/user.ts +1 -1
- package/lib/routes/langchain/index.ts +74 -0
- package/lib/routes/langchain/namespace.ts +7 -0
- package/lib/routes/last-origin/namespace.ts +7 -0
- package/lib/routes/last-origin/news.ts +65 -0
- package/lib/routes/linkresearcher/index.ts +108 -46
- package/lib/routes/linkresearcher/namespace.ts +8 -2
- package/lib/routes/linkresearcher/templates/bilingual.art +7 -0
- package/lib/routes/linkresearcher/types.ts +103 -0
- package/lib/routes/liulinblog/itnews.ts +1 -1
- package/lib/routes/lofter/collection.ts +1 -1
- package/lib/routes/lofter/tag.ts +1 -1
- package/lib/routes/logrocket/index.ts +71 -0
- package/lib/routes/logrocket/namespace.ts +7 -0
- package/lib/routes/m-78/namespace.ts +7 -0
- package/lib/routes/m-78/news.ts +115 -0
- package/lib/routes/m-78/types.ts +13 -0
- package/lib/routes/mastodon/account-id.ts +1 -1
- package/lib/routes/mastodon/acct.ts +1 -1
- package/lib/routes/mastodon/timeline-local.ts +2 -2
- package/lib/routes/mastodon/timeline-remote.ts +2 -2
- package/lib/routes/mastodon/utils.ts +1 -1
- package/lib/routes/metacritic/index.ts +1 -1
- package/lib/routes/mi/utils.ts +1 -1
- package/lib/routes/mihoyo/bbs/official.ts +2 -1
- package/lib/routes/misskey/utils.ts +19 -1
- package/lib/routes/mittrchina/index.ts +2 -2
- package/lib/routes/natgeo/natgeo.ts +25 -24
- package/lib/routes/nbd/daily.ts +1 -1
- package/lib/routes/nielsberglund/index.ts +78 -0
- package/lib/routes/nielsberglund/namespace.ts +7 -0
- package/lib/routes/nytimes/rss.ts +57 -0
- package/lib/routes/openrice/chart.ts +68 -0
- package/lib/routes/openrice/templates/chart.art +9 -0
- package/lib/routes/openrice/voting.ts +84 -0
- package/lib/routes/oschina/news.ts +26 -7
- package/lib/routes/patreon/feed.ts +126 -0
- package/lib/routes/patreon/namespace.ts +7 -0
- package/lib/routes/patreon/templates/description.art +39 -0
- package/lib/routes/patreon/types.ts +387 -0
- package/lib/routes/pixiv/api/get-illust-detail.ts +22 -0
- package/lib/routes/pixiv/novel-api/content/nsfw.ts +73 -0
- package/lib/routes/pixiv/novel-api/content/sfw.ts +63 -0
- package/lib/routes/pixiv/novel-api/content/types.ts +254 -0
- package/lib/routes/pixiv/novel-api/content/utils.ts +133 -0
- package/lib/routes/pixiv/novel-api/series/nsfw.ts +84 -0
- package/lib/routes/pixiv/novel-api/series/sfw.ts +70 -0
- package/lib/routes/pixiv/novel-api/series/types.ts +94 -0
- package/lib/routes/pixiv/novel-api/user-novels/nsfw.ts +82 -0
- package/lib/routes/pixiv/novel-api/user-novels/sfw.ts +74 -0
- package/lib/routes/pixiv/novel-api/user-novels/types.ts +133 -0
- package/lib/routes/pixiv/novel-series.ts +52 -0
- package/lib/routes/pixiv/novels.ts +69 -44
- package/lib/routes/pixiv/utils.ts +3 -0
- package/lib/routes/plurk/anonymous.ts +1 -1
- package/lib/routes/plurk/hotlinks.ts +1 -1
- package/lib/routes/plurk/news.ts +1 -1
- package/lib/routes/plurk/search.ts +1 -1
- package/lib/routes/qstheory/index.ts +121 -0
- package/lib/routes/qstheory/magazine.ts +64 -0
- package/lib/routes/qstheory/namespace.ts +7 -0
- package/lib/routes/qstheory/utils.ts +25 -0
- package/lib/routes/ruc/ai.ts +1 -1
- package/lib/routes/scmp/coronavirus.ts +1 -1
- package/lib/routes/scu/jwc/tzgg.ts +75 -0
- package/lib/routes/scu/namespace.ts +7 -0
- package/lib/routes/scu/scupi/_utils.ts +62 -0
- package/lib/routes/scu/scupi/notice.ts +41 -0
- package/lib/routes/solidot/namespace.ts +1 -1
- package/lib/routes/stbu/jsjxy.ts +4 -1
- package/lib/routes/steam/search.ts +7 -0
- package/lib/routes/sycl/feeds.ts +1 -1
- package/lib/routes/syosetu/dev.ts +67 -0
- package/lib/routes/syosetu/index.ts +85 -0
- package/lib/routes/syosetu/namespace.ts +2 -2
- package/lib/routes/syosetu/ranking-isekai.ts +93 -0
- package/lib/routes/syosetu/ranking-r18.ts +192 -0
- package/lib/routes/syosetu/ranking.ts +285 -0
- package/lib/routes/syosetu/search.ts +161 -0
- package/lib/routes/syosetu/templates/description.art +73 -0
- package/lib/routes/syosetu/types/ranking-r18.ts +60 -0
- package/lib/routes/syosetu/types/ranking.ts +67 -0
- package/lib/routes/syosetu/types/search.ts +138 -0
- package/lib/routes/syosetu/utils.ts +50 -0
- package/lib/routes/telegram/channel.ts +31 -1
- package/lib/routes/telegram/scripts/get-telegram-session.mjs +16 -6
- package/lib/routes/telegram/stickerpack.ts +1 -1
- package/lib/routes/telegram/tglib/channel.ts +12 -9
- package/lib/routes/telegram/tglib/client.ts +13 -9
- package/lib/routes/test/index.ts +4 -0
- package/lib/routes/theblockbeats/index.ts +1 -1
- package/lib/routes/thegradient/index.ts +80 -0
- package/lib/routes/thegradient/namespace.ts +7 -0
- package/lib/routes/theinitium/app.ts +4 -0
- package/lib/routes/thepaper/channel.ts +1 -1
- package/lib/routes/thepaper/factpaper.ts +1 -1
- package/lib/routes/thepaper/featured.ts +1 -1
- package/lib/routes/thepaper/list.ts +1 -1
- package/lib/routes/thepaper/user.ts +174 -0
- package/lib/routes/tongji/sem/_utils.ts +65 -0
- package/lib/routes/tongji/sem/notice.ts +58 -0
- package/lib/routes/toutiao/a-bogus.ts +540 -0
- package/lib/routes/toutiao/namespace.ts +7 -0
- package/lib/routes/toutiao/templates/video.art +7 -0
- package/lib/routes/toutiao/types.ts +443 -0
- package/lib/routes/toutiao/user.ts +127 -0
- package/lib/routes/twitter/api/mobile-api/api.ts +8 -0
- package/lib/routes/twitter/api/web-api/utils.ts +21 -9
- package/lib/routes/twitter/namespace.ts +1 -0
- package/lib/routes/twitter/utils.ts +7 -1
- package/lib/routes/vertikal/latest.ts +73 -0
- package/lib/routes/vertikal/namespace.ts +7 -0
- package/lib/routes/vice/topic.ts +1 -1
- package/lib/routes/vocus/publication.ts +1 -1
- package/lib/routes/vocus/user.ts +1 -1
- package/lib/routes/wallstreetcn/calendar.ts +90 -0
- package/lib/routes/wallstreetcn/hot.ts +2 -2
- package/lib/routes/wallstreetcn/live.ts +1 -1
- package/lib/routes/wallstreetcn/news.ts +5 -3
- package/lib/routes/weibo/timeline.ts +3 -2
- package/lib/routes/wellcee/rent.ts +1 -1
- package/lib/routes/wufazhuce/namespace.ts +7 -0
- package/lib/routes/wufazhuce/one.ts +90 -0
- package/lib/routes/xiaoheihe/discount.ts +72 -28
- package/lib/routes/xiaohongshu/user.ts +40 -3
- package/lib/routes/xiaohongshu/util.ts +112 -105
- package/lib/routes/xsijishe/rank.ts +33 -7
- package/lib/routes/xueqiu/cookies.ts +13 -18
- package/lib/routes/yahoo/news/listid.ts +4 -1
- package/lib/routes/yahoo/news/provider-helper.ts +4 -1
- package/lib/routes/yahoo/news/provider.ts +4 -1
- package/lib/routes/yande/post.ts +13 -3
- package/lib/routes/youtube/user.ts +37 -25
- package/lib/routes/zhonglun/index.ts +5 -6
- package/lib/routes/zjut/cs/index.ts +1 -1
- package/lib/utils/got.ts +2 -1
- package/lib/utils/helpers.test.ts +13 -1
- package/lib/utils/helpers.ts +10 -0
- package/lib/utils/ofetch.ts +3 -0
- package/lib/utils/request-rewriter/fetch.test.ts +94 -0
- package/lib/utils/request-rewriter/fetch.ts +14 -1
- package/lib/views/error.tsx +1 -1
- package/package.json +40 -37
- package/lib/routes/78dm/templates/image.art +0 -1
- package/lib/routes/deeplearning/thebatch.ts +0 -74
- package/lib/routes/syosetu/chapter.ts +0 -87
- package/lib/routes/xiaohongshu/notes.ts +0 -39
- package/lib/routes-deprecated/furaffinity/browse.js +0 -44
- package/lib/routes-deprecated/furaffinity/commissions.js +0 -39
- package/lib/routes-deprecated/furaffinity/favorites.js +0 -56
- package/lib/routes-deprecated/furaffinity/gallery.js +0 -56
- package/lib/routes-deprecated/furaffinity/home.js +0 -72
- package/lib/routes-deprecated/furaffinity/journal-comments.js +0 -50
- package/lib/routes-deprecated/furaffinity/journals.js +0 -49
- package/lib/routes-deprecated/furaffinity/scraps.js +0 -56
- package/lib/routes-deprecated/furaffinity/search.js +0 -56
- package/lib/routes-deprecated/furaffinity/shouts.js +0 -40
- package/lib/routes-deprecated/furaffinity/status.js +0 -38
- package/lib/routes-deprecated/furaffinity/submission-comments.js +0 -50
- package/lib/routes-deprecated/furaffinity/watchers.js +0 -47
- package/lib/routes-deprecated/furaffinity/watching.js +0 -47
- package/lib/routes-deprecated/ieee/author.js +0 -30
- package/lib/routes-deprecated/qstheory/index.js +0 -122
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import got from '../../pixiv-got';
|
|
2
|
+
import { maskHeader } from '../../constants';
|
|
3
|
+
import queryString from 'query-string';
|
|
4
|
+
import { config } from '@/config';
|
|
5
|
+
import pixivUtils from '../../utils';
|
|
6
|
+
import { getNSFWNovelContent } from '../content/nsfw';
|
|
7
|
+
import { parseDate } from '@/utils/parse-date';
|
|
8
|
+
import { convertPixivProtocolExtended } from '../content/utils';
|
|
9
|
+
import type { NSFWNovelsResponse, NovelList } from './types';
|
|
10
|
+
import ConfigNotFoundError from '@/errors/types/config-not-found';
|
|
11
|
+
import cache from '@/utils/cache';
|
|
12
|
+
import { getToken } from '../../token';
|
|
13
|
+
import InvalidParameterError from '@/errors/types/invalid-parameter';
|
|
14
|
+
|
|
15
|
+
function getNovels(user_id: string, token: string): Promise<NSFWNovelsResponse> {
|
|
16
|
+
return got('https://app-api.pixiv.net/v1/user/novels', {
|
|
17
|
+
headers: {
|
|
18
|
+
...maskHeader,
|
|
19
|
+
Authorization: 'Bearer ' + token,
|
|
20
|
+
},
|
|
21
|
+
searchParams: queryString.stringify({
|
|
22
|
+
user_id,
|
|
23
|
+
filter: 'for_ios',
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function getNSFWUserNovels(id: string, fullContent: boolean = false, limit: number = 100): Promise<NovelList> {
|
|
29
|
+
if (!config.pixiv || !config.pixiv.refreshToken) {
|
|
30
|
+
throw new ConfigNotFoundError('This user is an R18 creator, PIXIV_REFRESHTOKEN is required.\npixiv RSS is disabled due to the lack of relevant config.\n該用戶爲 R18 創作者,需要 PIXIV_REFRESHTOKEN。');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const token = await getToken(cache.tryGet);
|
|
34
|
+
if (!token) {
|
|
35
|
+
throw new ConfigNotFoundError('pixiv not login');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const response = await getNovels(id, token);
|
|
39
|
+
const novels = limit ? response.data.novels.slice(0, limit) : response.data.novels;
|
|
40
|
+
|
|
41
|
+
if (novels.length === 0) {
|
|
42
|
+
throw new InvalidParameterError(`${id} is not a valid user ID, or the user has no novels.\n${id} 不是有效的用戶 ID,或者該用戶沒有小說作品。`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const username = novels[0].user.name;
|
|
46
|
+
|
|
47
|
+
const items = await Promise.all(
|
|
48
|
+
novels.map(async (novel) => {
|
|
49
|
+
const baseItem = {
|
|
50
|
+
title: novel.series?.title ? `${novel.series.title} - ${novel.title}` : novel.title,
|
|
51
|
+
description: `
|
|
52
|
+
<img src="${pixivUtils.getProxiedImageUrl(novel.image_urls.large)}" />
|
|
53
|
+
<div>
|
|
54
|
+
<p>${convertPixivProtocolExtended(novel.caption)}</p>
|
|
55
|
+
</div>`,
|
|
56
|
+
author: novel.user.name,
|
|
57
|
+
pubDate: parseDate(novel.create_date),
|
|
58
|
+
link: `https://www.pixiv.net/novel/show.php?id=${novel.id}`,
|
|
59
|
+
category: novel.tags.map((t) => t.name),
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
if (!fullContent) {
|
|
63
|
+
return baseItem;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const { content } = await getNSFWNovelContent(novel.id, token);
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
...baseItem,
|
|
70
|
+
description: `${baseItem.description}<hr>${content}`,
|
|
71
|
+
};
|
|
72
|
+
})
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
title: `${username}'s novels - pixiv`,
|
|
77
|
+
description: `${username} 的 pixiv 最新小说`,
|
|
78
|
+
image: pixivUtils.getProxiedImageUrl(novels[0].user.profile_image_urls.medium),
|
|
79
|
+
link: `https://www.pixiv.net/users/${id}/novels`,
|
|
80
|
+
item: items,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import got from '@/utils/got';
|
|
2
|
+
import { parseDate } from '@/utils/parse-date';
|
|
3
|
+
import pixivUtils from '../../utils';
|
|
4
|
+
import { getSFWNovelContent } from '../content/sfw';
|
|
5
|
+
import type { SFWNovelsResponse, NovelList } from './types';
|
|
6
|
+
|
|
7
|
+
const baseUrl = 'https://www.pixiv.net';
|
|
8
|
+
|
|
9
|
+
export async function getSFWUserNovels(id: string, fullContent: boolean = false, limit: number = 100): Promise<NovelList> {
|
|
10
|
+
const url = `${baseUrl}/users/${id}/novels`;
|
|
11
|
+
const { data: allData } = await got(`${baseUrl}/ajax/user/${id}/profile/all`, {
|
|
12
|
+
headers: {
|
|
13
|
+
referer: url,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const novels = Object.keys(allData.body.novels)
|
|
18
|
+
.sort((a, b) => Number(b) - Number(a))
|
|
19
|
+
.slice(0, Number.parseInt(String(limit), 10));
|
|
20
|
+
|
|
21
|
+
if (novels.length === 0) {
|
|
22
|
+
throw new Error('No novels found for this user, or is an R18 creator, fallback to ConfigNotFoundError');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const searchParams = new URLSearchParams();
|
|
26
|
+
for (const novel of novels) {
|
|
27
|
+
searchParams.append('ids[]', novel);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const { data } = (await got(`${baseUrl}/ajax/user/${id}/profile/novels`, {
|
|
31
|
+
headers: {
|
|
32
|
+
referer: url,
|
|
33
|
+
},
|
|
34
|
+
searchParams,
|
|
35
|
+
})) as SFWNovelsResponse;
|
|
36
|
+
|
|
37
|
+
const items = await Promise.all(
|
|
38
|
+
Object.values(data.body.works).map(async (item) => {
|
|
39
|
+
const baseItem = {
|
|
40
|
+
title: item.title,
|
|
41
|
+
description: `
|
|
42
|
+
<img src=${pixivUtils.getProxiedImageUrl(item.url)} />
|
|
43
|
+
<div>
|
|
44
|
+
<p>${item.description}</p>
|
|
45
|
+
</div>
|
|
46
|
+
`,
|
|
47
|
+
link: `${baseUrl}/novel/show.php?id=${item.id}`,
|
|
48
|
+
author: item.userName,
|
|
49
|
+
pubDate: parseDate(item.createDate),
|
|
50
|
+
updated: parseDate(item.updateDate),
|
|
51
|
+
category: item.tags,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
if (!fullContent) {
|
|
55
|
+
return baseItem;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const { content } = await getSFWNovelContent(item.id);
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
...baseItem,
|
|
62
|
+
description: `${baseItem.description}<hr>${content}`,
|
|
63
|
+
};
|
|
64
|
+
})
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
title: data.body.extraData.meta.title,
|
|
69
|
+
description: data.body.extraData.meta.ogp.description,
|
|
70
|
+
image: pixivUtils.getProxiedImageUrl(Object.values(data.body.works)[0].profileImageUrl),
|
|
71
|
+
link: url,
|
|
72
|
+
item: items,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
export interface SFWNovelsResponse {
|
|
2
|
+
data: {
|
|
3
|
+
error: boolean;
|
|
4
|
+
message: string;
|
|
5
|
+
body: {
|
|
6
|
+
works: Record<string, SFWNovelWork>;
|
|
7
|
+
extraData: {
|
|
8
|
+
meta: {
|
|
9
|
+
title: string;
|
|
10
|
+
description: string;
|
|
11
|
+
canonical: string;
|
|
12
|
+
ogp: {
|
|
13
|
+
description: string;
|
|
14
|
+
image: string;
|
|
15
|
+
title: string;
|
|
16
|
+
type: string;
|
|
17
|
+
};
|
|
18
|
+
twitter: {
|
|
19
|
+
description: string;
|
|
20
|
+
image: string;
|
|
21
|
+
title: string;
|
|
22
|
+
card: string;
|
|
23
|
+
};
|
|
24
|
+
alternateLanguages: {
|
|
25
|
+
ja: string;
|
|
26
|
+
en: string;
|
|
27
|
+
};
|
|
28
|
+
descriptionHeader: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface SFWNovelWork {
|
|
36
|
+
id: string;
|
|
37
|
+
title: string;
|
|
38
|
+
genre: string;
|
|
39
|
+
xRestrict: number;
|
|
40
|
+
restrict: number;
|
|
41
|
+
url: string;
|
|
42
|
+
tags: string[];
|
|
43
|
+
userId: string;
|
|
44
|
+
userName: string;
|
|
45
|
+
profileImageUrl: string;
|
|
46
|
+
textCount: number;
|
|
47
|
+
wordCount: number;
|
|
48
|
+
readingTime: number;
|
|
49
|
+
useWordCount: boolean;
|
|
50
|
+
description: string;
|
|
51
|
+
isBookmarkable: boolean;
|
|
52
|
+
bookmarkData: null;
|
|
53
|
+
bookmarkCount: number;
|
|
54
|
+
isOriginal: boolean;
|
|
55
|
+
marker: null;
|
|
56
|
+
titleCaptionTranslation: {
|
|
57
|
+
workTitle: null;
|
|
58
|
+
workCaption: null;
|
|
59
|
+
};
|
|
60
|
+
createDate: string;
|
|
61
|
+
updateDate: string;
|
|
62
|
+
isMasked: boolean;
|
|
63
|
+
aiType: number;
|
|
64
|
+
seriesId: string;
|
|
65
|
+
seriesTitle: string;
|
|
66
|
+
isUnlisted: boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface NSFWNovelsResponse {
|
|
70
|
+
data: {
|
|
71
|
+
user: {
|
|
72
|
+
id: number;
|
|
73
|
+
name: string;
|
|
74
|
+
account: string;
|
|
75
|
+
profile_image_urls: {
|
|
76
|
+
medium: string;
|
|
77
|
+
};
|
|
78
|
+
is_followed: boolean;
|
|
79
|
+
is_access_blocking_user: boolean;
|
|
80
|
+
};
|
|
81
|
+
novels: NSFWNovelWork[];
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface NSFWNovelWork {
|
|
86
|
+
id: string;
|
|
87
|
+
title: string;
|
|
88
|
+
caption: string;
|
|
89
|
+
restrict: number;
|
|
90
|
+
x_restrict: number;
|
|
91
|
+
image_urls: {
|
|
92
|
+
square_medium: string;
|
|
93
|
+
medium: string;
|
|
94
|
+
large: string;
|
|
95
|
+
};
|
|
96
|
+
create_date: string;
|
|
97
|
+
tags: Array<{
|
|
98
|
+
name: string;
|
|
99
|
+
translated_name: string | null;
|
|
100
|
+
added_by_uploaded_user: boolean;
|
|
101
|
+
}>;
|
|
102
|
+
text_length: number;
|
|
103
|
+
user: {
|
|
104
|
+
id: number;
|
|
105
|
+
name: string;
|
|
106
|
+
account: string;
|
|
107
|
+
profile_image_urls: {
|
|
108
|
+
medium: string;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
series?: {
|
|
112
|
+
id?: number;
|
|
113
|
+
title?: string;
|
|
114
|
+
};
|
|
115
|
+
total_bookmarks: number;
|
|
116
|
+
total_view: number;
|
|
117
|
+
total_comments: number;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface NovelList {
|
|
121
|
+
title: string;
|
|
122
|
+
description: string;
|
|
123
|
+
image: string;
|
|
124
|
+
link: string;
|
|
125
|
+
item: Array<{
|
|
126
|
+
title: string;
|
|
127
|
+
description: string;
|
|
128
|
+
author: string;
|
|
129
|
+
pubDate: Date;
|
|
130
|
+
link: string;
|
|
131
|
+
category: string[];
|
|
132
|
+
}>;
|
|
133
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Data, Route } from '@/types';
|
|
2
|
+
import { config } from '@/config';
|
|
3
|
+
import { getNSFWSeriesNovels } from './novel-api/series/nsfw';
|
|
4
|
+
import { getSFWSeriesNovels } from './novel-api/series/sfw';
|
|
5
|
+
|
|
6
|
+
export const route: Route = {
|
|
7
|
+
path: '/novel/series/:id',
|
|
8
|
+
categories: ['social-media'],
|
|
9
|
+
example: '/pixiv/novel/series/11586857',
|
|
10
|
+
parameters: {
|
|
11
|
+
id: 'Series id, can be found in URL',
|
|
12
|
+
},
|
|
13
|
+
features: {
|
|
14
|
+
requireConfig: [
|
|
15
|
+
{
|
|
16
|
+
name: 'PIXIV_REFRESHTOKEN',
|
|
17
|
+
optional: true,
|
|
18
|
+
description: `
|
|
19
|
+
refresh_token after Pixiv login, required for accessing R18 novels
|
|
20
|
+
Pixiv 登錄後的 refresh_token,用於獲取 R18 小說
|
|
21
|
+
[https://docs.rsshub.app/deploy/config#pixiv](https://docs.rsshub.app/deploy/config#pixiv)`,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
requirePuppeteer: false,
|
|
25
|
+
antiCrawler: false,
|
|
26
|
+
supportBT: false,
|
|
27
|
+
supportPodcast: false,
|
|
28
|
+
supportScihub: false,
|
|
29
|
+
},
|
|
30
|
+
name: 'Novel Series',
|
|
31
|
+
maintainers: ['SnowAgar25', 'keocheung'],
|
|
32
|
+
handler,
|
|
33
|
+
radar: [
|
|
34
|
+
{
|
|
35
|
+
source: ['www.pixiv.net/novel/series/:id'],
|
|
36
|
+
target: '/novel/series/:id',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const hasPixivAuth = () => Boolean(config.pixiv && config.pixiv.refreshToken);
|
|
42
|
+
|
|
43
|
+
async function handler(ctx): Promise<Data> {
|
|
44
|
+
const id = ctx.req.param('id');
|
|
45
|
+
const { limit } = ctx.req.query();
|
|
46
|
+
|
|
47
|
+
if (hasPixivAuth()) {
|
|
48
|
+
return await getNSFWSeriesNovels(id, limit);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return await getSFWSeriesNovels(id, limit);
|
|
52
|
+
}
|
|
@@ -1,15 +1,37 @@
|
|
|
1
|
-
import { Route } from '@/types';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { Data, Route, ViewType } from '@/types';
|
|
2
|
+
import { fallback, queryToBoolean } from '@/utils/readable-social';
|
|
3
|
+
import { config } from '@/config';
|
|
4
|
+
import { getNSFWUserNovels } from './novel-api/user-novels/nsfw';
|
|
5
|
+
import { getSFWUserNovels } from './novel-api/user-novels/sfw';
|
|
6
|
+
import ConfigNotFoundError from '@/errors/types/config-not-found';
|
|
5
7
|
|
|
6
8
|
export const route: Route = {
|
|
7
|
-
path: '/user/novels/:id',
|
|
9
|
+
path: '/user/novels/:id/:full_content?',
|
|
8
10
|
categories: ['social-media'],
|
|
11
|
+
view: ViewType.Articles,
|
|
9
12
|
example: '/pixiv/user/novels/27104704',
|
|
10
|
-
parameters: {
|
|
13
|
+
parameters: {
|
|
14
|
+
id: "User id, available in user's homepage URL",
|
|
15
|
+
full_content: {
|
|
16
|
+
description: 'Enable or disable the display of full content. ',
|
|
17
|
+
options: [
|
|
18
|
+
{ value: 'true', label: 'true' },
|
|
19
|
+
{ value: 'false', label: 'false' },
|
|
20
|
+
],
|
|
21
|
+
default: 'false',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
11
24
|
features: {
|
|
12
|
-
requireConfig:
|
|
25
|
+
requireConfig: [
|
|
26
|
+
{
|
|
27
|
+
name: 'PIXIV_REFRESHTOKEN',
|
|
28
|
+
optional: true,
|
|
29
|
+
description: `
|
|
30
|
+
Pixiv 登錄後的 refresh_token,用於獲取 R18 小說
|
|
31
|
+
refresh_token after Pixiv login, required for accessing R18 novels
|
|
32
|
+
[https://docs.rsshub.app/deploy/config#pixiv](https://docs.rsshub.app/deploy/config#pixiv)`,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
13
35
|
requirePuppeteer: false,
|
|
14
36
|
antiCrawler: false,
|
|
15
37
|
supportBT: false,
|
|
@@ -18,54 +40,57 @@ export const route: Route = {
|
|
|
18
40
|
},
|
|
19
41
|
radar: [
|
|
20
42
|
{
|
|
21
|
-
|
|
43
|
+
title: 'User Novels (簡介 Basic info)',
|
|
44
|
+
source: ['www.pixiv.net/users/:id/novels', 'www.pixiv.net/users/:id'],
|
|
45
|
+
target: '/user/novels/:id',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
title: 'User Novels (全文 Full text)',
|
|
49
|
+
source: ['www.pixiv.net/users/:id/novels', 'www.pixiv.net/users/:id'],
|
|
50
|
+
target: '/user/novels/:id/true',
|
|
22
51
|
},
|
|
23
52
|
],
|
|
24
53
|
name: 'User Novels',
|
|
25
|
-
maintainers: ['TonyRL'],
|
|
54
|
+
maintainers: ['TonyRL', 'SnowAgar25'],
|
|
26
55
|
handler,
|
|
56
|
+
description: `
|
|
57
|
+
| 小說類型 Novel Type | full_content | PIXIV_REFRESHTOKEN | 返回內容 Content |
|
|
58
|
+
|-------------------|--------------|-------------------|-----------------|
|
|
59
|
+
| Non R18 | false | 不需要 Not Required | 簡介 Basic info |
|
|
60
|
+
| Non R18 | true | 不需要 Not Required | 全文 Full text |
|
|
61
|
+
| R18 | false | 需要 Required | 簡介 Basic info |
|
|
62
|
+
| R18 | true | 需要 Required | 全文 Full text |
|
|
63
|
+
|
|
64
|
+
Default value for \`full_content\` is \`false\` if not specified.
|
|
65
|
+
|
|
66
|
+
Example:
|
|
67
|
+
- \`/pixiv/user/novels/79603797\` → 簡介 Basic info
|
|
68
|
+
- \`/pixiv/user/novels/79603797/true\` → 全文 Full text`,
|
|
27
69
|
};
|
|
28
70
|
|
|
29
|
-
|
|
71
|
+
const hasPixivAuth = () => Boolean(config.pixiv && config.pixiv.refreshToken);
|
|
72
|
+
|
|
73
|
+
async function handler(ctx): Promise<Data> {
|
|
30
74
|
const id = ctx.req.param('id');
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const { data: allData } = await got(`${baseUrl}/ajax/user/${id}/profile/all`, {
|
|
34
|
-
headers: {
|
|
35
|
-
referer: url,
|
|
36
|
-
},
|
|
37
|
-
});
|
|
75
|
+
const fullContent = fallback(undefined, queryToBoolean(ctx.req.param('full_content')), false);
|
|
76
|
+
const { limit } = ctx.req.query();
|
|
38
77
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
.slice(0, Number.parseInt(limit, 10));
|
|
42
|
-
const searchParams = new URLSearchParams();
|
|
43
|
-
for (const novel of novels) {
|
|
44
|
-
searchParams.append('ids[]', novel);
|
|
78
|
+
if (hasPixivAuth()) {
|
|
79
|
+
return await getNSFWUserNovels(id, fullContent, limit);
|
|
45
80
|
}
|
|
46
81
|
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
82
|
+
const nonR18Result = await getSFWUserNovels(id, fullContent, limit).catch((error) => {
|
|
83
|
+
if (error.name === 'Error') {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
throw error;
|
|
52
87
|
});
|
|
53
88
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
link: `${baseUrl}/novel/series/${item.id}`,
|
|
58
|
-
author: item.userName,
|
|
59
|
-
pubDate: parseDate(item.createDate),
|
|
60
|
-
updated: parseDate(item.updateDate),
|
|
61
|
-
category: item.tags,
|
|
62
|
-
}));
|
|
89
|
+
if (nonR18Result) {
|
|
90
|
+
return nonR18Result;
|
|
91
|
+
}
|
|
63
92
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
image: Object.values(data.body.works)[0].profileImageUrl,
|
|
68
|
-
link: url,
|
|
69
|
-
item: items,
|
|
70
|
-
};
|
|
93
|
+
throw new ConfigNotFoundError(
|
|
94
|
+
'This user may not have any novel works, or is an R18 creator, PIXIV_REFRESHTOKEN is required.\npixiv RSS is disabled due to the lack of relevant config.\n該用戶可能沒有小說作品,或者該用戶爲 R18 創作者,需要 PIXIV_REFRESHTOKEN。'
|
|
95
|
+
);
|
|
71
96
|
}
|
package/lib/routes/plurk/news.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { baseUrl, fetchFriends, getPlurk } from './utils';
|
|
|
5
5
|
|
|
6
6
|
export const route: Route = {
|
|
7
7
|
path: '/news/:lang?',
|
|
8
|
-
categories: ['social-media'],
|
|
8
|
+
categories: ['social-media', 'popular'],
|
|
9
9
|
example: '/plurk/news/:lang?',
|
|
10
10
|
parameters: { lang: 'Language, see the table above, `en` by default' },
|
|
11
11
|
features: {
|
|
@@ -6,7 +6,7 @@ import { baseUrl, getPlurk } from './utils';
|
|
|
6
6
|
|
|
7
7
|
export const route: Route = {
|
|
8
8
|
path: '/search/:keyword',
|
|
9
|
-
categories: ['social-media'],
|
|
9
|
+
categories: ['social-media', 'popular'],
|
|
10
10
|
example: '/plurk/search/FGO',
|
|
11
11
|
parameters: { keyword: 'Search keyword' },
|
|
12
12
|
features: {
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Route } from '@/types';
|
|
2
|
+
|
|
3
|
+
import ofetch from '@/utils/ofetch';
|
|
4
|
+
import * as cheerio from 'cheerio';
|
|
5
|
+
import cache from '@/utils/cache';
|
|
6
|
+
import { baseUrl as rootUrl, getItem } from './utils';
|
|
7
|
+
|
|
8
|
+
const config = {
|
|
9
|
+
toutiao: {
|
|
10
|
+
title: '头条',
|
|
11
|
+
url: `${rootUrl}/v9zhuanqu/toutiao/index.htm`,
|
|
12
|
+
},
|
|
13
|
+
qswp: {
|
|
14
|
+
title: '网评',
|
|
15
|
+
url: `${rootUrl}/qswp.htm`,
|
|
16
|
+
},
|
|
17
|
+
qssp: {
|
|
18
|
+
title: '视频',
|
|
19
|
+
url: `${rootUrl}/qssp/index.htm`,
|
|
20
|
+
},
|
|
21
|
+
qslgxd: {
|
|
22
|
+
title: '原创',
|
|
23
|
+
url: `${rootUrl}/qslgxd/index.htm`,
|
|
24
|
+
},
|
|
25
|
+
economy: {
|
|
26
|
+
title: '经济',
|
|
27
|
+
url: `${rootUrl}/economy/index.htm`,
|
|
28
|
+
},
|
|
29
|
+
politics: {
|
|
30
|
+
title: '政治',
|
|
31
|
+
url: `${rootUrl}/politics/index.htm`,
|
|
32
|
+
},
|
|
33
|
+
culture: {
|
|
34
|
+
title: '文化',
|
|
35
|
+
url: `${rootUrl}/culture/index.htm`,
|
|
36
|
+
},
|
|
37
|
+
society: {
|
|
38
|
+
title: '社会',
|
|
39
|
+
url: `${rootUrl}/society/index.htm`,
|
|
40
|
+
},
|
|
41
|
+
cpc: {
|
|
42
|
+
title: '党建',
|
|
43
|
+
url: `${rootUrl}/cpc/index.htm`,
|
|
44
|
+
},
|
|
45
|
+
science: {
|
|
46
|
+
title: '科教',
|
|
47
|
+
url: `${rootUrl}/science/index.htm`,
|
|
48
|
+
},
|
|
49
|
+
zoology: {
|
|
50
|
+
title: '生态',
|
|
51
|
+
url: `${rootUrl}/zoology/index.htm`,
|
|
52
|
+
},
|
|
53
|
+
defense: {
|
|
54
|
+
title: '国防',
|
|
55
|
+
url: `${rootUrl}/defense/index.htm`,
|
|
56
|
+
},
|
|
57
|
+
international: {
|
|
58
|
+
title: '国际',
|
|
59
|
+
url: `${rootUrl}/international/index.htm`,
|
|
60
|
+
},
|
|
61
|
+
books: {
|
|
62
|
+
title: '图书',
|
|
63
|
+
url: `${rootUrl}/books/index.htm`,
|
|
64
|
+
},
|
|
65
|
+
xxbj: {
|
|
66
|
+
title: '学习笔记',
|
|
67
|
+
url: `${rootUrl}/qszq/xxbj/index.htm`,
|
|
68
|
+
},
|
|
69
|
+
llwx: {
|
|
70
|
+
title: '理论文选',
|
|
71
|
+
url: `${rootUrl}/qszq/llwx/index.htm`,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const route: Route = {
|
|
76
|
+
path: '/:category?',
|
|
77
|
+
categories: ['traditional-media'],
|
|
78
|
+
example: '/qstheory',
|
|
79
|
+
parameters: { industry: '分类,见下表' },
|
|
80
|
+
radar: [
|
|
81
|
+
{
|
|
82
|
+
source: ['www.qstheory.cn/v9zhuanqu/:category/index.htm', 'www.qstheory.cn/qszq/:category/index.htm', 'www.qstheory.cn/:category/index.htm'],
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
name: '分类',
|
|
86
|
+
maintainers: ['nczitzk'],
|
|
87
|
+
handler,
|
|
88
|
+
description: `
|
|
89
|
+
| 头条 | 网评 | 视频 | 原创 | 经济 | 政治 | 文化 | 社会 | 党建 | 科教 | 生态 | 国防 | 国际 | 图书 | 学习笔记 | 理论文选 |
|
|
90
|
+
| ------- | ---- | ---- | ------ | ------- | -------- | ------- | ------- | ---- | ------- | ------- | ------- | ------------- | ----- | -------- | -------- |
|
|
91
|
+
| toutiao | qswp | qssp | qslgxd | economy | politics | culture | society | cpc | science | zoology | defense | international | books | xxbj | llwx |`,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
async function handler(ctx) {
|
|
95
|
+
const { category = 'toutiao' } = ctx.req.param();
|
|
96
|
+
const limit = Number.parseInt(ctx.req.query('limit')) || 50;
|
|
97
|
+
|
|
98
|
+
const currentUrl = config[category].url;
|
|
99
|
+
const response = await ofetch(currentUrl);
|
|
100
|
+
|
|
101
|
+
const $ = cheerio.load(response);
|
|
102
|
+
|
|
103
|
+
const list = $('.list-style1 ul li a, .text h2 a, .no-pic ul li a')
|
|
104
|
+
.slice(0, limit)
|
|
105
|
+
.toArray()
|
|
106
|
+
.map((item) => {
|
|
107
|
+
const $item = $(item);
|
|
108
|
+
return {
|
|
109
|
+
title: $item.text(),
|
|
110
|
+
link: $item.attr('href')!,
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => getItem(item))));
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
title: $('title').text(),
|
|
118
|
+
link: currentUrl,
|
|
119
|
+
item: items,
|
|
120
|
+
};
|
|
121
|
+
}
|