From eab38324f2489d8b324b304a55b1a2ec63b28fa3 Mon Sep 17 00:00:00 2001 From: KidLoveToPlay <63667585+Yamico@users.noreply.github.com> Date: Wed, 27 Mar 2024 01:35:24 +0800 Subject: [PATCH] feat(route): add ntdm (#14979) --- lib/routes/ntdm/namespace.ts | 6 ++++ lib/routes/ntdm/utils.ts | 3 ++ lib/routes/ntdm/video.ts | 57 ++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 lib/routes/ntdm/namespace.ts create mode 100644 lib/routes/ntdm/utils.ts create mode 100644 lib/routes/ntdm/video.ts diff --git a/lib/routes/ntdm/namespace.ts b/lib/routes/ntdm/namespace.ts new file mode 100644 index 000000000..a831c0504 --- /dev/null +++ b/lib/routes/ntdm/namespace.ts @@ -0,0 +1,6 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: 'NT动漫', + url: 'www.ntdm9.com', +}; diff --git a/lib/routes/ntdm/utils.ts b/lib/routes/ntdm/utils.ts new file mode 100644 index 000000000..080321acf --- /dev/null +++ b/lib/routes/ntdm/utils.ts @@ -0,0 +1,3 @@ +const rootUrl = 'https://www.ntdm9.com'; + +export { rootUrl }; diff --git a/lib/routes/ntdm/video.ts b/lib/routes/ntdm/video.ts new file mode 100644 index 000000000..a3187e5ab --- /dev/null +++ b/lib/routes/ntdm/video.ts @@ -0,0 +1,57 @@ +import { Route } from '@/types'; +import got from '@/utils/got'; +import { rootUrl } from './utils'; +import cheerio from 'cheerio'; + +export const route: Route = { + path: '/video/:id', + categories: ['anime'], + example: '/ntdm/video/20200035', + parameters: { id: '番剧 id,对应详情 URL 中找到' }, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['ntdm9.com/video/:id'], + }, + ], + name: '番剧详情', + maintainers: ['alexhere'], + handler, +}; + +async function handler(ctx) { + const id = ctx.req.param('id'); + const url = `${rootUrl}/video/${id}.html`; + const response = await got(url); + const $ = cheerio.load(response.data); + + const dmtitle = $('.detail_imform_name').text(); + const dmdesc = $('.detail_imform_desc_pre').text(); + + const items = $('.movurl.mod ul') + .first() + .find('li') + .toArray() + .map((item) => { + item = $(item); + const a = item.find('a'); + return { + title: a.text(), + link: `${rootUrl}${a.attr('href')}` + }; + }) + .reverse(); + return { + title: `NT动漫 - ${dmtitle}`, + link: `${rootUrl}/video/${id}.html`, + description: dmdesc, + item: items, + }; +}