Skip to content

Commit

Permalink
feat(route): 新增钛媒体快报 (DIYgod#18173)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Update lib/routes/tmtpost/nictation.ts

Co-authored-by: Tony <[email protected]>

* Update lib/routes/tmtpost/nictation.ts

Co-authored-by: Tony <[email protected]>

---------
  • Loading branch information
defp authored Jan 22, 2025
1 parent 35e7b8e commit eed318c
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/routes/tmtpost/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: '钛媒体',
url: 'tmtpost.com',
categories: ['new-media'],
description: '钛媒体是一家专注于新媒体领域的科技媒体',
lang: 'zh-CN',
};
59 changes: 59 additions & 0 deletions lib/routes/tmtpost/nictation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Route } from '@/types';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';

export const route: Route = {
path: '/nictation',
categories: ['new-media'],
example: '/tmtpost/word',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: {
source: ['www.tmtpost.com'],
},
name: '快报',
maintainers: ['defp'],
handler,
url: 'www.tmtpost.com/nictation',
};

async function handler() {
const currentTime = Math.floor(Date.now() / 1000);
const oneHourAgo = currentTime - 3600;
const url = 'https://api.tmtpost.com/v1/word/list';

const response = await got({
method: 'get',
url,
searchParams: {
time_start: oneHourAgo,
time_end: currentTime,
limit: 40,
fields: ['share_description', 'share_image', 'word_comments', 'stock_list', 'is_important', 'duration', 'word_classify', 'share_link'].join(';'),
},
headers: {
'app-version': 'web1.0',
},
});

const data = response.data.data;

return {
title: '钛媒体 - 快报',
link: 'https://www.tmtpost.com/nictation',
item: data.map((item) => ({
title: item.title,
description: item.detail,
pubDate: parseDate(item.time_published, 'X'),
link: item.share_link || `https://www.tmtpost.com/nictation/${item.guid}.html`,
author: item.author_name,
})),
};
}

0 comments on commit eed318c

Please sign in to comment.