mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-01 14:57:14 +08:00
feat(route): 新增得物开放平台和抖店开放平台 (#15887)
* feat(route): 新增得物开放平台文档 * feat(route): 新增抖店开放平台 * fix(route): 修正抖店参数描述错误 * fix(route): 修复得物平台时间解析的错误 * fix(route): jinritemai时间错误
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
import { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
const typeMap = {
|
||||
'1010580020': '技术变更',
|
||||
'1014821004': '服务市场规则中心',
|
||||
'1011202692': '规则变更',
|
||||
'1010568195': '维护公告',
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ctx {import('koa').Context}
|
||||
*/
|
||||
export const route: Route = {
|
||||
path: '/declaration/:categoryId?',
|
||||
categories: ['programming'],
|
||||
example: '/dewu/declaration/1010580020',
|
||||
parameters: { categoryId: '公告分类, 可在页面URL获取 默认为1010580020' },
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: false,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
name: '平台公告',
|
||||
maintainers: ['blade0910'],
|
||||
handler,
|
||||
description: `| 类型 | type |
|
||||
| ---------------- | ---------- |
|
||||
| 技术变更 | 1010580020 |
|
||||
| 服务市场规则中心 | 1014821004 |
|
||||
| 规则变更 | 1011202692 |
|
||||
| 维护公告 | 1010568195 |`,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const categoryId = ctx.req.param('categoryId') || '1010580020';
|
||||
const response = await got({
|
||||
method: 'post',
|
||||
url: 'https://open.dewu.com/api/v1/h5/merchant-study/open/document/listDocument',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
json: {
|
||||
categoryId,
|
||||
},
|
||||
});
|
||||
|
||||
const list = response.data.data.map((item) => ({
|
||||
title: item.title,
|
||||
id: item.id,
|
||||
link: `https://open.dewu.com/#/declaration/read?articleId=${item.id}`,
|
||||
pubDate: timezone(parseDate(item.publishTime), +8),
|
||||
}));
|
||||
|
||||
const result = await Promise.all(
|
||||
list.map((item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
const itemResponse = await got({
|
||||
method: 'post',
|
||||
url: 'https://open.dewu.com/api/v1/h5/merchant-study/open/document/getDocumentDetail',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
json: {
|
||||
documentId: item.id,
|
||||
},
|
||||
});
|
||||
item.description = itemResponse.data.data.content;
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
return {
|
||||
title: `得物开放平台 - ${typeMap[categoryId] ?? '平台公告'}`,
|
||||
link: 'https://open.dewu.com/#/declaration/read',
|
||||
item: result,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import type { Namespace } from '@/types';
|
||||
|
||||
export const namespace: Namespace = {
|
||||
name: '得物',
|
||||
url: 'dewu.com',
|
||||
};
|
||||
@@ -0,0 +1,74 @@
|
||||
import { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
const typeMap = {
|
||||
'5': '全部公告',
|
||||
'19': '产品发布',
|
||||
'21': '规则变更',
|
||||
'20': '维护公告',
|
||||
'22': '其他公告',
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ctx {import('koa').Context}
|
||||
*/
|
||||
export const route: Route = {
|
||||
path: '/docs/:dirId?',
|
||||
categories: ['programming'],
|
||||
example: '/jinritemai/docs/19',
|
||||
parameters: { dirId: '公告分类, 可在页面URL获取 默认为全部' },
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: false,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
name: '平台公告',
|
||||
maintainers: ['blade0910'],
|
||||
handler,
|
||||
description: `| 类型 | type |
|
||||
| --------- | ---------- |
|
||||
| 全部公告 | 5 |
|
||||
| 产品发布 | 19 |
|
||||
| 规则变更 | 21 |
|
||||
| 维护公告 | 20 |
|
||||
| 其他公告 | 22 |`,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const dirId = ctx.req.param('dirId') || '5';
|
||||
const url = `https://op.jinritemai.com/doc/external/open/queryDocArticleList?pageIndex=0&pageSize=10&status=1&dirId=${dirId}&orderType=3`;
|
||||
const response = await got({ method: 'get', url });
|
||||
|
||||
const list = response.data.data.articles.map((item) => ({
|
||||
title: item.title,
|
||||
id: item.id,
|
||||
dirName: item.dirName,
|
||||
link: `https://op.jinritemai.com/docs/notice-docs/${dirId}/${item.id}`,
|
||||
pubDate: parseDate(item.updateTime * 1000),
|
||||
}));
|
||||
|
||||
const result = await Promise.all(
|
||||
list.map((item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
const itemResponse = await got({
|
||||
method: 'get',
|
||||
url: `https://op.jinritemai.com/doc/external/open/queryDocArticleDetail?articleId=${item.id}&onlyView=false`,
|
||||
});
|
||||
item.description = itemResponse.data.data.article.content;
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
return {
|
||||
title: `抖店开放平台 - ${typeMap[dirId] ?? '平台公告'}`,
|
||||
link: `https://op.jinritemai.com/docs/notice-docs/${dirId}`,
|
||||
item: result,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import type { Namespace } from '@/types';
|
||||
|
||||
export const namespace: Namespace = {
|
||||
name: '抖店开放平台',
|
||||
url: 'op.jinritemai.com',
|
||||
};
|
||||
Reference in New Issue
Block a user