diff --git a/lib/routes/bilibili/dynamic.ts b/lib/routes/bilibili/dynamic.ts index be3c3e8d797412..101c1c34f35bf4 100644 --- a/lib/routes/bilibili/dynamic.ts +++ b/lib/routes/bilibili/dynamic.ts @@ -23,6 +23,7 @@ export const route: Route = { | useAvid | 视频链接使用 AV 号 (默认为 BV 号) | 0/1/true/false | false | | directLink | 使用内容直链 | 0/1/true/false | false | | hideGoods | 隐藏带货动态 | 0/1/true/false | false | +| offset | 偏移状态 | string | "" | 用例:\`/bilibili/user/dynamic/2267573/showEmoji=1&embed=0&useAvid=1\``, }, @@ -232,13 +233,14 @@ async function handler(ctx) { const showEmoji = fallback(undefined, queryToBoolean(routeParams.showEmoji), false); const embed = fallback(undefined, queryToBoolean(routeParams.embed), true); const displayArticle = ctx.req.query('mode') === 'fulltext'; + const offset = fallback(undefined, routeParams.offset, ''); const useAvid = fallback(undefined, queryToBoolean(routeParams.useAvid), false); const directLink = fallback(undefined, queryToBoolean(routeParams.directLink), false); const hideGoods = fallback(undefined, queryToBoolean(routeParams.hideGoods), false); const cookie = await cacheIn.getCookie(); - const params = utils.addDmVerifyInfo(`host_mid=${uid}&platform=web&features=itemOpusStyle,listOnlyfans,opusBigCover,onlyfansVote`, utils.getDmImgList()); + const params = utils.addDmVerifyInfo(`offset=${offset}&host_mid=${uid}&platform=web&features=itemOpusStyle,listOnlyfans,opusBigCover,onlyfansVote`, utils.getDmImgList()); const response = await got(`https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space?${params}`, { headers: { Referer: `https://space.bilibili.com/${uid}/`, diff --git a/lib/routes/ifanr/category.ts b/lib/routes/ifanr/category.ts new file mode 100644 index 00000000000000..348d23e587d4cb --- /dev/null +++ b/lib/routes/ifanr/category.ts @@ -0,0 +1,71 @@ +import { Route } from '@/types'; +import got from '@/utils/got'; +import { parseDate } from '@/utils/parse-date'; + +const PATH_LIST = { + 早报: 'ifanrnews', + 评测: 'review', + 糖纸众测: 'tangzhi-evaluation', + 产品: 'product', +}; + +export const route: Route = { + path: '/category/:name', + categories: ['new-media'], + example: '/ifanr/category/早报', + parameters: { name: '分类名称' }, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: true, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['www.ifanr.com/category/:name'], + }, + ], + name: '分类', + maintainers: ['donghongfei'], + handler, + description: `支持分类:早报、评测、糖纸众测、产品`, +}; + +async function handler(ctx) { + const name = ctx.req.param('name'); + const nameEncode = encodeURIComponent(decodeURIComponent(name)); + const apiUrl = `https://sso.ifanr.com/api/v5/wp/article/?post_category=${nameEncode}&limit=20&offset=0`; + const resp = await got({ + method: 'get', + url: apiUrl, + }); + const items = await Promise.all( + resp.data.objects.map((item) => { + let description = ''; + + const banner = item.post_cover_image; + + if (banner) { + description = `Article Cover Image
`; + } + description += item.post_content; + + return { + title: item.post_title.trim(), + description, + link: item.post_url, + pubDate: parseDate(item.published_at * 1000), + author: item.created_by.name, + }; + }) + ); + + return { + title: `#${name} - iFanr 爱范儿`, + link: `https://www.ifanr.com/category/${PATH_LIST[name]}`, + description: `${name} 更新推送`, + item: items, + }; +} diff --git a/lib/routes/ifanr/index.ts b/lib/routes/ifanr/index.ts new file mode 100644 index 00000000000000..34f94268137b0f --- /dev/null +++ b/lib/routes/ifanr/index.ts @@ -0,0 +1,70 @@ +import { Route, ViewType } from '@/types'; +import cache from '@/utils/cache'; +import got from '@/utils/got'; +import { parseDate } from '@/utils/parse-date'; + +export const route: Route = { + path: '/index', + categories: ['new-media'], + view: ViewType.Articles, + example: '/ifanr/index', + parameters: {}, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['www.ifanr.com/index'], + }, + ], + name: '首页', + maintainers: ['donghongfei'], + handler, + url: 'www.ifanr.com/index', +}; + +async function handler() { + const apiUrl = 'https://sso.ifanr.com/api/v5/wp/web-feed/?limit=20&offset=0'; + const resp = await got({ + method: 'get', + url: apiUrl, + }); + const items = await Promise.all( + resp.data.objects.map((item) => { + const link = `https://sso.ifanr.com/api/v5/wp/article/?post_id=${item.post_id}`; + let description = ''; + + const key = `ifanr:${item.id}`; + + return cache.tryGet(key, async () => { + const response = await got({ method: 'get', url: link }); + const articleData = response.data.objects[0]; + const banner = articleData.post_cover_image; + if (banner) { + description = `Article Cover Image
`; + } + description += articleData.post_content; + + return { + title: item.post_title.trim(), + description, + link: item.post_url, + pubDate: parseDate(item.created_at * 1000), + author: item.created_by.name, + }; + }); + }) + ); + + return { + title: '爱范儿', + link: 'https://www.ifanr.com', + description: '爱范儿首页', + item: items, + }; +} diff --git a/lib/routes/ifanr/namespace.ts b/lib/routes/ifanr/namespace.ts new file mode 100644 index 00000000000000..b06f5927e11adf --- /dev/null +++ b/lib/routes/ifanr/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '爱范儿', + url: 'www.ifanr.com', + description: '', + lang: 'zh-CN', +}; diff --git a/package.json b/package.json index 4c66336fe11e1d..2e6818febdc132 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,7 @@ "currency-symbol-map": "5.1.0", "dayjs": "1.11.8", "destr": "2.0.3", - "directory-import": "3.3.1", + "directory-import": "3.3.2", "dotenv": "16.4.7", "entities": "6.0.0", "etag": "1.8.1", @@ -122,7 +122,7 @@ "simplecc-wasm": "1.1.0", "socks-proxy-agent": "8.0.5", "source-map": "0.7.4", - "telegram": "2.26.8", + "telegram": "2.26.16", "tiny-async-pool": "2.1.0", "title": "4.0.1", "tldts": "6.1.70", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2ea52544afcc47..dca75811baaab5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -97,8 +97,8 @@ importers: specifier: 2.0.3 version: 2.0.3 directory-import: - specifier: 3.3.1 - version: 3.3.1 + specifier: 3.3.2 + version: 3.3.2 dotenv: specifier: 16.4.7 version: 16.4.7 @@ -232,8 +232,8 @@ importers: specifier: 0.7.4 version: 0.7.4 telegram: - specifier: 2.26.8 - version: 2.26.8 + specifier: 2.26.16 + version: 2.26.16 tiny-async-pool: specifier: 2.1.0 version: 2.1.0 @@ -2759,8 +2759,8 @@ packages: resolution: {tarball: https://codeload.github.com/postlight/difflib.js/tar.gz/32e8e38c7fcd935241b9baab71bb432fd9b166ed} version: 0.2.6 - directory-import@3.3.1: - resolution: {integrity: sha512-d9paCbverdqmuwR+B40phSqiHhgPKiP8dpsMz5WT9U6ug2VVQ3tqXNCedpa6iGHg6mgv9lHaoq5DJUu2IXMjsQ==} + directory-import@3.3.2: + resolution: {integrity: sha512-dSApZXgx29qO/6AVigdsoC6HSvaHWinJ4HTRPKrlMAxX71FgPzn/WEWbgM+aB1PlKD9IfSC3Ir2ouYYQR1uy+g==} engines: {node: '>=18.17.0'} discord-api-types@0.37.114: @@ -5140,8 +5140,8 @@ packages: resolution: {integrity: sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==} engines: {node: '>=18'} - telegram@2.26.8: - resolution: {integrity: sha512-5sIb43Fd7HxjXQZqKWMhNTmdMOlG3QkuhR2xPleUA5B8BxOZl9IwrDwFdiC7aezGVTcD6oJ1d4cloUySjmCX/A==} + telegram@2.26.16: + resolution: {integrity: sha512-5tqL9HicCxRqEi+9JjXBteVDnoZ+1ggsBFxLQTO49aXwTI2d7To7xb2vOU/ahLwgKuE+Db9ra5xDJZ76Kk0NEA==} test-exclude@7.0.1: resolution: {integrity: sha512-pFYqmTw68LXVjeWJMST4+borgQP2AyMNbg1BpZh9LbyhUeNkeaPF9gzfPGUAnSMV3qPYdWUwDIjjCLiSDOl7vg==} @@ -8197,7 +8197,7 @@ snapshots: dependencies: heap: 0.2.7 - directory-import@3.3.1: {} + directory-import@3.3.2: {} discord-api-types@0.37.114: {} @@ -10966,7 +10966,7 @@ snapshots: mkdirp: 3.0.1 yallist: 5.0.0 - telegram@2.26.8: + telegram@2.26.16: dependencies: '@cryptography/aes': 0.1.1 async-mutex: 0.3.2