Skip to content

Commit eed318c

Browse files
authored
feat(route): 新增钛媒体快报 (#18173)
* feat(pencilnews): 新增铅笔道文章列表 * 📝 docs(pencilnews/index.ts): 更新维护者信息 * feat(route): 新增钛媒体快讯 新增了钛媒体(TMTPost)的命名空间定义和快讯路由支持。通过 `nictation.ts` 文件实现了从钛媒体 API 获取最新快讯数据的功能 * ✨ feat(tmtpost/nictation.ts): 添加 `share_link` 字段并更新链接格式 在请求字段中添加 `share_link` 以确保获取分享链接数据。同时,更新文章链接的生成逻辑,使用 `guid` 替代 `id`,以匹配 TMTPost 的最新 URL 格式。这些更改确保数据完整性和链接的准确性,提升用户体验。 * Update lib/routes/tmtpost/nictation.ts Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/routes/tmtpost/nictation.ts Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/routes/tmtpost/nictation.ts Co-authored-by: Tony <TonyRL@users.noreply.github.com> ---------
1 parent 35e7b8e commit eed318c

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

lib/routes/tmtpost/namespace.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { Namespace } from '@/types';
2+
3+
export const namespace: Namespace = {
4+
name: '钛媒体',
5+
url: 'tmtpost.com',
6+
categories: ['new-media'],
7+
description: '钛媒体是一家专注于新媒体领域的科技媒体',
8+
lang: 'zh-CN',
9+
};

lib/routes/tmtpost/nictation.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { Route } from '@/types';
2+
import got from '@/utils/got';
3+
import { parseDate } from '@/utils/parse-date';
4+
5+
export const route: Route = {
6+
path: '/nictation',
7+
categories: ['new-media'],
8+
example: '/tmtpost/word',
9+
parameters: {},
10+
features: {
11+
requireConfig: false,
12+
requirePuppeteer: false,
13+
antiCrawler: false,
14+
supportBT: false,
15+
supportPodcast: false,
16+
supportScihub: false,
17+
},
18+
radar: {
19+
source: ['www.tmtpost.com'],
20+
},
21+
name: '快报',
22+
maintainers: ['defp'],
23+
handler,
24+
url: 'www.tmtpost.com/nictation',
25+
};
26+
27+
async function handler() {
28+
const currentTime = Math.floor(Date.now() / 1000);
29+
const oneHourAgo = currentTime - 3600;
30+
const url = 'https://api.tmtpost.com/v1/word/list';
31+
32+
const response = await got({
33+
method: 'get',
34+
url,
35+
searchParams: {
36+
time_start: oneHourAgo,
37+
time_end: currentTime,
38+
limit: 40,
39+
fields: ['share_description', 'share_image', 'word_comments', 'stock_list', 'is_important', 'duration', 'word_classify', 'share_link'].join(';'),
40+
},
41+
headers: {
42+
'app-version': 'web1.0',
43+
},
44+
});
45+
46+
const data = response.data.data;
47+
48+
return {
49+
title: '钛媒体 - 快报',
50+
link: 'https://www.tmtpost.com/nictation',
51+
item: data.map((item) => ({
52+
title: item.title,
53+
description: item.detail,
54+
pubDate: parseDate(item.time_published, 'X'),
55+
link: item.share_link || `https://www.tmtpost.com/nictation/${item.guid}.html`,
56+
author: item.author_name,
57+
})),
58+
};
59+
}

0 commit comments

Comments
 (0)