From 1291f366114d302d819c50e127a4b6ce0920e623 Mon Sep 17 00:00:00 2001 From: Hualiang <78242797+hualiong@users.noreply.github.com> Date: Sat, 29 Jun 2024 03:04:20 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20=E6=96=B0=E5=A2=9E=20ASMR=20Onli?= =?UTF-8?q?ne=20(#16027)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(route): 新增 ASMR Online * null --- lib/routes/asmr-200/index.ts | 67 ++++++++++++++++++ lib/routes/asmr-200/namespace.ts | 6 ++ lib/routes/asmr-200/templates/work.art | 7 ++ lib/routes/asmr-200/type.ts | 96 ++++++++++++++++++++++++++ 4 files changed, 176 insertions(+) create mode 100644 lib/routes/asmr-200/index.ts create mode 100644 lib/routes/asmr-200/namespace.ts create mode 100644 lib/routes/asmr-200/templates/work.art create mode 100644 lib/routes/asmr-200/type.ts diff --git a/lib/routes/asmr-200/index.ts b/lib/routes/asmr-200/index.ts new file mode 100644 index 000000000..dd04bdd36 --- /dev/null +++ b/lib/routes/asmr-200/index.ts @@ -0,0 +1,67 @@ +import { Result, Work } from '@/routes/asmr-200/type'; +import { DataItem, Route } from '@/types'; +import ofetch from '@/utils/ofetch'; +import path from 'node:path'; +import { parseDate } from '@/utils/parse-date'; +import { art } from '@/utils/render'; +import timezone from '@/utils/timezone'; +import { getCurrentPath } from '@/utils/helpers'; + +const render = (work: Work, link: string) => art(path.join(getCurrentPath(import.meta.url), 'templates', 'work.art'), { work, link }); + +export const route: Route = { + path: '/works/:order?/:subtitle?/:sort?', + categories: ['multimedia'], + example: '/works', + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: true, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + parameters: { + order: '排序字段,默认按照资源的收录日期来排序,详见下表', + sort: '排序方式,可选 `asc` 和 `desc` ,默认倒序', + subtitle: '筛选带字幕音频,可选 `0` 和 `1` ,默认关闭', + }, + radar: [ + { + source: ['asmr-200.com'], + target: 'asmr-200/works', + }, + ], + name: '最新资源', + maintainers: ['hualiong'], + url: 'asmr-200.com', + description: `| 发售日期 | 收录日期 | 销量 | 价格 | 评价 | 随机 | RJ号 | +| ---- | ---- | ---- | ---- | ---- | ---- | ---- | +| release | create_date | dl_count | price | rate_average_2dp | random | id |`, + handler: async (ctx) => { + const { order = 'create_date', sort = 'desc', subtitle = '0' } = ctx.req.param(); + const res = await ofetch('https://api.asmr-200.com/api/works', { query: { order, sort, page: 1, subtitle } }); + + const items: DataItem[] = res.works.map((each) => { + const category = each.tags.map((tag) => tag.name); + each.category = category.join(','); + each.cv = each.vas.map((cv) => cv.name).join(','); + return { + title: each.title, + image: each.mainCoverUrl, + author: each.name, + link: `https://asmr-200.com/work/${each.source_id}`, + pubDate: timezone(parseDate(each.release, 'YYYY-MM-DD'), +8), + category, + description: render(each, `https://asmr-200.com/work/${each.source_id}`), + }; + }); + + return { + title: '最新收录 - ASMR Online', + link: 'https://asmr-200.com/', + language: 'zh-cn', + item: items, + }; + }, +}; diff --git a/lib/routes/asmr-200/namespace.ts b/lib/routes/asmr-200/namespace.ts new file mode 100644 index 000000000..97a605def --- /dev/null +++ b/lib/routes/asmr-200/namespace.ts @@ -0,0 +1,6 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: 'ASMR Online', + url: 'asmr-200.com', +}; diff --git a/lib/routes/asmr-200/templates/work.art b/lib/routes/asmr-200/templates/work.art new file mode 100644 index 000000000..759ad749f --- /dev/null +++ b/lib/routes/asmr-200/templates/work.art @@ -0,0 +1,7 @@ +{{ work.title }} +

{{ work.title }} {{ work.source_id }}

+

发布者:{{ work.name }}

+

评分:{{ work.rate_average_2dp }} | 评论数:{{ work.review_count }} | 总时长:{{ work.duration }} | 音频来源:{{ work.source_type }}

+

价格:{{ work.price }} JPY | 销量:{{ work.dl_count }}

+

分类:{{ work.category }}

+

声优:{{ work.cv }}

\ No newline at end of file diff --git a/lib/routes/asmr-200/type.ts b/lib/routes/asmr-200/type.ts new file mode 100644 index 000000000..8036204af --- /dev/null +++ b/lib/routes/asmr-200/type.ts @@ -0,0 +1,96 @@ +export interface Result { + pagination: { + currentPage: number; + pageSize: number; + totalCount: number; + }; + works: Work[]; +} + +export interface Work { + age_category_string: string; + circle: { + id: number; + name: string; + source_id: string; + source_type: string; + }; + circle_id: number; + create_date: string; + dl_count: number; + duration: number; + has_subtitle: boolean; + id: number; + language_editions: { + display_order: number; + edition_id: number; + edition_type: string; + label: string; + lang: string; + workno: string; + }[]; + mainCoverUrl: string; + name: string; + nsfw: boolean; + original_workno: null | string; + other_language_editions_in_db: { + id: number; + is_original: boolean; + lang: string; + source_id: string; + source_type: string; + title: string; + }[]; + playlistStatus: any; + price: number; + rank: + | { + category: string; + rank: number; + rank_date: string; + term: string; + }[] + | null; + rate_average_2dp: number | number; + rate_count: number; + rate_count_detail: { + count: number; + ratio: number; + review_point: number; + }[]; + release: string; + review_count: number; + samCoverUrl: string; + source_id: string; + source_type: string; + source_url: string; + tags: { + i18n: any; + id: number; + name: string; + }[]; + category: string; + thumbnailCoverUrl: string; + title: string; + translation_info: { + child_worknos: string[]; + is_child: boolean; + is_original: boolean; + is_parent: boolean; + is_translation_agree: boolean; + is_translation_bonus_child: boolean; + is_volunteer: boolean; + lang: null | string; + original_workno: null | string; + parent_workno: null | string; + production_trade_price_rate: number; + translation_bonus_langs: string[]; + }; + userRating: null; + vas: { + id: string; + name: string; + }[]; + cv: string; + work_attributes: string; +}