fix(route): 调整影视资源采集路由 (#16101)

* fix(route): 调整影视资源采集路由

* 限制可选域名

* 微调
This commit is contained in:
Hualiang
2024-07-11 18:31:10 +08:00
committed by GitHub
parent 157e098988
commit 32ae3c1962
7 changed files with 183 additions and 192 deletions
+72
View File
@@ -0,0 +1,72 @@
import { Result, Vod } from '@/routes/maccms/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 = (vod: Vod, link: string) => art(path.join(getCurrentPath(import.meta.url), 'templates', 'vod.art'), { vod, link });
export const route: Route = {
path: '/:domain/:type?/:size?',
categories: ['multimedia'],
example: '/maccms/moduzy.net/2',
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
parameters: {
domain: '采集站域名,可选值如下表',
type: '类别ID,不同采集站点有不同的类别规则和ID,默认为 0,代表全部类别',
size: '每次获取的数据条数,上限 100 条,默认 30 条',
},
name: '最新资源',
maintainers: ['hualiong'],
description: `
:::tip
每个采集站提供的影视类别ID是不同的,即参数中的 \`type\` 是不同的。**可以先访问一次站点提供的采集接口,然后从返回结果中的 \`class\` 字段中的 \`type_id\`获取相应的类别ID**
:::
| 站名 | 域名 | 站名 | 域名 | 站名 | 域名 |
| ------------------- | ------------------------------------------------ | ---------------- | -------------------------------------------------- | -------------- | ----------------------------------------------- |
| 魔都资源网 | [moduzy.net](https://moduzy.net) | 华为吧影视资源站 | [hw8.live](https://hw8.live) | 360 资源站 | [360zy.com](https://360zy.com) |
| jkun 爱坤联盟资源网 | [ikunzyapi.com](https://ikunzyapi.com) | 奥斯卡资源站 | [aosikazy.com](https://aosikazy.com) | 飞速资源采集网 | [www.feisuzyapi.com](http://www.feisuzyapi.com) |
| 森林资源网 | [slapibf.com](https://slapibf.com) | 天空资源采集网 | [api.tiankongapi.com](https://api.tiankongapi.com) | 百度云资源 | [api.apibdzy.com](https://api.apibdzy.com) |
| 红牛资源站 | [www.hongniuzy2.com](https://www.hongniuzy2.com) | 乐视资源网 | [leshiapi.com](https://leshiapi.com) | 暴风资源 | [bfzyapi.com](https://bfzyapi.com) |`,
handler: async (ctx) => {
const { domain, type = '0', size = '30' } = ctx.req.param();
if (!list.has(domain)) {
throw new Error('非法域名!');
}
const res = await ofetch<Result>(`https://${domain}/api.php/provide/vod`, {
parseResponse: JSON.parse,
query: { ac: 'detail', t: type, pagesize: Number.parseInt(size) > 100 ? 100 : size },
});
const items: DataItem[] = res.list.map((each) => ({
title: each.vod_name,
image: each.vod_pic,
link: `https://${domain}/vod/${each.vod_id}/`,
guid: each.vod_play_url?.match(/https:\/\/.+?\.m3u8/g)?.slice(-1)[0],
pubDate: timezone(parseDate(each.vod_time, 'YYYY-MM-DD HH:mm:ss'), +8),
category: [each.type_name, ...each.vod_class!.split(',')],
description: render(each, `https://${domain}/vod/${each.vod_id}/`) + each.vod_content,
}));
return {
title: `最新${type !== '0' && items.length ? items[0].category![0] : '资源'} - ${domain}`,
link: `https://${domain}`,
allowEmpty: true,
item: items,
};
},
};
const list = new Set(['moduzy.net', 'hw8.live', '360zy.com', 'ikunzyapi.com', 'aosikazy.com', 'www.feisuzyapi.com', 'slapibf.com', 'api.tiankongapi.com', 'api.apibdzy.com', 'www.hongniuzy2.com', 'leshiapi.com', 'bfzyapi.com']);
+9
View File
@@ -0,0 +1,9 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: '通用影视采集站视频采集接口路由',
description: `
:::tip
该路由适用于各大影视采集站对外提供的统一CMS视频采集接口,API 类似于 \`https://网站域名/api.php/provide/vod\`
:::`,
};
+102
View File
@@ -0,0 +1,102 @@
export type Result = {
code: number;
msg: string;
page: string;
pagecount: number;
limit: string;
total: number;
list: Array<Vod>;
class?: Array<Class>;
};
export type Class = {
type_id: number;
type_pid: number;
type_name: string;
};
export type Vod = {
vod_id: number;
vod_name: string;
type_id: number;
type_name: string;
vod_en: string;
vod_time: string;
vod_remarks: string;
vod_play_from: string;
type_id_1?: number;
group_id?: number;
vod_sub?: string;
vod_status?: number;
vod_letter?: string;
vod_color?: string;
vod_tag?: string;
vod_class?: string;
vod_pic?: string;
vod_pic_thumb?: string;
vod_pic_slide?: string;
vod_pic_screenshot?: string;
vod_actor?: string;
vod_director?: string;
vod_writer?: string;
vod_behind?: string;
vod_blurb?: string;
vod_pubdate?: string;
vod_total?: number;
vod_serial?: string;
vod_tv?: string;
vod_weekday?: string;
vod_area?: string;
vod_lang?: string;
vod_year?: string;
vod_version?: string;
vod_state?: string;
vod_author?: string;
vod_jumpurl?: string;
vod_tpl?: string;
vod_tpl_play?: string;
vod_tpl_down?: string;
vod_isend?: number;
vod_lock?: number;
vod_level?: number;
vod_copyright?: number;
vod_points?: number;
vod_points_play?: number;
vod_points_down?: number;
vod_hits?: number;
vod_hits_day?: number;
vod_hits_week?: number;
vod_hits_month?: number;
vod_duration?: string;
vod_up?: number;
vod_down?: number;
vod_score?: string;
vod_score_all?: number;
vod_score_num?: number;
vod_time_add?: number;
vod_time_hits?: number;
vod_time_make?: number;
vod_trysee?: number;
vod_douban_id?: number;
vod_douban_score?: string;
vod_reurl?: string;
vod_rel_vod?: string;
vod_rel_art?: string;
vod_pwd?: string;
vod_pwd_url?: string;
vod_pwd_play?: string;
vod_pwd_play_url?: string;
vod_pwd_down?: string;
vod_pwd_down_url?: string;
vod_content?: string;
vod_play_server?: string;
vod_play_note?: string;
vod_play_url?: string;
vod_down_from?: string;
vod_down_server?: string;
vod_down_note?: string;
vod_down_url?: string;
vod_plot?: number;
vod_plot_name?: string;
vod_plot_detail?: string;
};
-80
View File
@@ -1,80 +0,0 @@
import { Result, Vod } from '@/routes/moduzy/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 = (vod: Vod, link: string) => art(path.join(getCurrentPath(import.meta.url), 'templates', 'vod.art'), { vod, link });
export const route: Route = {
path: '/:type/:hours?',
categories: ['multimedia'],
example: '/moduzy/2',
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
parameters: {
type: '类别ID,具体见下表,为 0 代表全部类别',
hours: '获取截止到几小时前的数据,默认不限',
},
radar: [
{
source: ['moduzy.cc', 'moduzy.net', 'moduzy.com', 'moduzy1.com', 'moduzy2.com', 'moduzy3.com', 'moduzy4.com', 'moduzy5.com', 'moduzy6.com', 'moduzy7.com', 'moduzy8.com', 'moduzy9.com', 'moduzy10.com'],
},
],
name: '最新资源',
maintainers: ['hualiong'],
url: 'moduzy.net',
description: `
:::warning
不建议订阅**全部类别**和**国产动漫**,因为该类型每天的更新量会大幅超过单次抓取的最大上限20条而被截断(**温馨提醒**:该资源网以**动漫资源**为主,部分影视类别可能会没有资源)
:::
| 类别 | ID | 类别 | ID | 类别 | ID | 类别 | ID |
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
| 国产动漫 | 1 | 日韩动漫 | 2 | 欧美动漫 | 3 | 港台动漫 | 4 |
| 动漫电影 | 5 | 里番动漫 | 6 | 动作片 | 10 | 喜剧片 | 11 |
| 爱情片 | 12 | 科幻片 | 13 | 恐怖片 | 14 | 剧情片 | 15 |
| 战争片 | 16 | 惊悚片 | 17 | 家庭片 | 18 | 古装片 | 19 |
| 历史片 | 20 | 悬疑片 | 21 | 犯罪片 | 22 | 灾难片 | 23 |
| 记录片 | 24 | 短片 | 25 | 国产剧 | 26 | 香港剧 | 27 |
| 韩国剧 | 28 | 欧美剧 | 29 | 台湾剧 | 30 | 日本剧 | 31 |
| 海外剧 | 32 | 泰国剧 | 33 | 大陆综艺 | 34 | 港台综艺 | 35 |
| 日韩综艺 | 36 | 欧美综艺 | 37 | 全部类别 | 0 | | |`,
handler: async (ctx) => {
const { type, hours = '' } = ctx.req.param();
const query = async (pg: number) =>
await ofetch<Result>('https://moduzy.net/api.php/provide/vod', {
parseResponse: JSON.parse,
query: { ac: 'detail', t: type || '', h: hours, pg },
});
const res = await query(1);
const items: DataItem[] = res.list.map((each) => ({
title: each.vod_name,
image: each.vod_pic,
link: `https://moduzy.net/vod/${each.vod_id}/`,
guid: each.vod_play_url.match(/https:\/\/.+?\.m3u8/g)?.slice(-1)[0],
pubDate: timezone(parseDate(each.vod_time, 'YYYY-MM-DD HH:mm:ss'), +8),
category: [each.type_name, ...each.vod_class.split(',')],
description: render(each, `https://moduzy.net/vod/${each.vod_id}/`) + each.vod_content,
}));
return {
title: `最新${type && items.length ? items[0].category![0] : '资源'} - 魔都资源网`,
link: 'https://moduzy.net',
allowEmpty: true,
language: 'zh-cn',
item: items,
};
},
};
-17
View File
@@ -1,17 +0,0 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: '魔都资源网',
url: 'www.moduzy.com',
description: `
:::tip
魔都资源网有多个备用域名,路由默认使用域名 \`moduzy.net\` 确保在中国大陆内的实例也能访问。如果你想直接访问源站可以通过以下域名:
- moduzy.com(主域名,大陆内无法访问)
- moduzy.cc
- moduzy.net
- moduzy1.com - moduzy10.com(均可访问)
官方的导航页:[moduzy.vip](https://www.moduzy.vip)
:::`,
};
-95
View File
@@ -1,95 +0,0 @@
export type Result = {
code: number;
msg: string;
page: string;
pagecount: number;
limit: string;
total: number;
list: Array<Vod>;
};
export type Vod = {
vod_id: number;
type_id: number;
type_id_1: number;
group_id: number;
vod_name: string;
vod_sub: string;
vod_en: string;
vod_status: number;
vod_letter: string;
vod_color: string;
vod_tag: string;
vod_class: string;
vod_pic: string;
vod_pic_thumb: string;
vod_pic_slide: string;
vod_pic_screenshot: string;
vod_actor: string;
vod_director: string;
vod_writer: string;
vod_behind: string;
vod_blurb: string;
vod_remarks: string;
vod_pubdate: string;
vod_total: number;
vod_serial: string;
vod_tv: string;
vod_weekday: string;
vod_area: string;
vod_lang: string;
vod_year: string;
vod_version: string;
vod_state: string;
vod_author: string;
vod_jumpurl: string;
vod_tpl: string;
vod_tpl_play: string;
vod_tpl_down: string;
vod_isend: number;
vod_lock: number;
vod_level: number;
vod_copyright: number;
vod_points: number;
vod_points_play: number;
vod_points_down: number;
vod_hits: number;
vod_hits_day: number;
vod_hits_week: number;
vod_hits_month: number;
vod_duration: string;
vod_up: number;
vod_down: number;
vod_score: string;
vod_score_all: number;
vod_score_num: number;
vod_time: string;
vod_time_add: number;
vod_time_hits: number;
vod_time_make: number;
vod_trysee: number;
vod_douban_id: number;
vod_douban_score: string;
vod_reurl: string;
vod_rel_vod: string;
vod_rel_art: string;
vod_pwd: string;
vod_pwd_url: string;
vod_pwd_play: string;
vod_pwd_play_url: string;
vod_pwd_down: string;
vod_pwd_down_url: string;
vod_content: string;
vod_play_from: string;
vod_play_server: string;
vod_play_note: string;
vod_play_url: string;
vod_down_from: string;
vod_down_server: string;
vod_down_note: string;
vod_down_url: string;
vod_plot: number;
vod_plot_name: string;
vod_plot_detail: string;
type_name: string;
};