Skip to content

Commit

Permalink
feat(route): add Science Tokyo News 東京科学大学ニュース (#17550)
Browse files Browse the repository at this point in the history
* chore(deps): bump telegram from 2.26.2 to 2.26.6 (#17384)

* chore(deps): bump telegram from 2.26.2 to 2.26.6

Bumps [telegram](https://github.com/gram-js/gramjs) from 2.26.2 to 2.26.6.
- [Release notes](https://github.com/gram-js/gramjs/releases)
- [Commits](https://github.com/gram-js/gramjs/commits)

---
updated-dependencies:
- dependency-name: telegram
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: fix pnpm install

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* 基础功能实现

* Update lib/routes/isct/namespace.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/routes/isct/news.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
catyyy and dependabot[bot] authored Nov 13, 2024
1 parent dee35fa commit 489630a
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/routes/isct/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: 'Institute of Science Tokyo',
url: 'isct.ac.jp',
lang: 'ja',

ja: {
name: '東京科学大学',
},
};
66 changes: 66 additions & 0 deletions lib/routes/isct/news.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import { parseDate } from '@/utils/parse-date';
import { decode } from 'entities';

interface NewsItem {
ID: string;
TITLE: string;
PUBLISH_DATE: string;
META_DESCRIPTION: string;
MEDIA_CD: string;
}

export const route: Route = {
path: '/news/:lang',
categories: ['university'],
example: '/isct/news/ja',
parameters: { lang: 'language, could be ja or en' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['www.isct.ac.jp/:lang/news'],
target: '/news/:lang',
},
],
name: 'News',
maintainers: ['catyyy'],
handler: async (ctx) => {
const { lang = 'ja' } = ctx.req.param();
const response = await ofetch(`https://www.isct.ac.jp/expansion/get_media_list_json.php?lang_cd=${lang}`);

const decodedResponse = decode(response);
const data = JSON.parse(decodedResponse);
const itemsArray: NewsItem[] = Object.values(data);

const items = itemsArray.map((item) => ({
// 文章标题
title: item.TITLE,
// 文章链接
link: 'news/' + item.MEDIA_CD,
// 文章正文
description: item.META_DESCRIPTION,
// 文章发布日期
pubDate: parseDate(item.PUBLISH_DATE),
// 如果有的话,文章作者
// author: item.user.login,
// 如果有的话,文章分类
// category: item.labels.map((label) => label.name),
}));
return {
// 源标题
title: `ISCT News - ${lang}`,
// 源链接
link: `https://www.isct.ac.jp/${lang}/news`,
// 源文章
item: items,
};
},
};

0 comments on commit 489630a

Please sign in to comment.