Skip to content

Commit 6ab9a19

Browse files
committed
update:支持分类
1 parent 1298642 commit 6ab9a19

File tree

9 files changed

+199
-32
lines changed

9 files changed

+199
-32
lines changed

Diff for: README.md

+6
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,9 @@ yarn build
4040
* 批量搜索会出问题,没法识别指定key
4141
* 暂未兼容漫画小说播放逻辑
4242
* 采王二级有问题暂未适配
43+
44+
# 更新记录
45+
46+
### 20250118
47+
48+
1. 支持通用嗅探

Diff for: nodejs/esbuild-config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as esbuild from 'esbuild';
22
import fs from 'fs';
3-
import { createHash } from 'crypto';
3+
import {createHash} from 'crypto';
44

55
esbuild.build({
66
entryPoints: ['src/index.config.js'],
@@ -12,7 +12,7 @@ esbuild.build({
1212
format: 'cjs',
1313
platform: 'node',
1414
target: 'node18',
15-
sourcemap: process.env.NODE_ENV === 'development' ? 'inline' : false,
15+
sourcemap: process.env.NODE_ENV === 'development',
1616
plugins: [genMd5()],
1717
});
1818

Diff for: nodejs/esbuild.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as esbuild from 'esbuild';
22
import fs from 'fs';
3-
import { createHash } from 'crypto';
3+
import {createHash} from 'crypto';
44

55
esbuild.build({
66
entryPoints: ['src/index.js'],
@@ -11,7 +11,7 @@ esbuild.build({
1111
format: 'cjs',
1212
platform: 'node',
1313
target: 'node18',
14-
sourcemap: process.env.NODE_ENV === 'development' ? 'inline' : false,
14+
sourcemap: process.env.NODE_ENV === 'development',
1515
plugins: [genMd5()],
1616
});
1717

Diff for: nodejs/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
"scripts": {
77
"dev": "cross-env DEV_HTTP_PORT=3006 nodemon --config nodemon.json src/dev.js",
88
"_build": "rimraf dist && node esbuild.js && node esbuild-config.js",
9-
"build": "cross-env NODE_ENV=production npm run _build",
9+
"build": "cross-env NODE_ENV=production npm run _build && node copyDist.js D:\\soft\\猫影视\\Release\\data\\flutter_assets\\asset\\js",
1010
"build:copy": "cross-env NODE_ENV=production npm run _build && node copyDist.js D:\\soft\\猫影视\\Release\\data\\flutter_assets\\asset\\js",
11+
"build:dbg:copy": "cross-env NODE_ENV=development npm run _build && node copyDist.js D:\\soft\\猫影视\\Release\\data\\flutter_assets\\asset\\js",
1112
"build:dbg": "cross-env NODE_ENV=development npm run _build",
1213
"build:config": "cross-env NODE_ENV=production node esbuild-config.js",
1314
"build:rollup(obsolete)": "rimraf dist && cross-env NODE_ENV=production node rollup.js && cross-env NODE_ENV=production node rollup-config.js",
1415
"build:rollup:config(obsolete)": "cross-env NODE_ENV=production node rollup-config.js",
15-
"build-old:copy": "rimraf dist && cross-env NODE_ENV=production node esbuild.js && cross-env NODE_ENV=production node esbuild-config.js && node copyDist.js E:\\soft\\windows_release_open_2.0.3_beta2\\Release\\data\\flutter_assets\\asset\\js"
16+
"build-old:dbg:copy": "rimraf dist && cross-env NODE_ENV=development node esbuild.js && cross-env NODE_ENV=development node esbuild-config.js && node copyDist.js D:\\soft\\猫影视\\Release\\data\\flutter_assets\\asset\\js"
1617
},
1718
"author": "道长",
1819
"devDependencies": {

Diff for: nodejs/src/dev.js

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1-
import { createServer } from 'http';
1+
import {createServer} from 'http';
22
import os from 'os';
3-
import { start } from './index.js';
3+
import {start} from './index.js';
44
import * as config from './index.config.js';
5+
import axios from "axios";
56

67
globalThis.catServerFactory = (handle) => {
78
let port = 0;
89
const server = createServer((req, res) => {
910
handle(req, res);
1011
});
1112

12-
server.on('listening', () => {
13+
// 自动 GET 请求逻辑
14+
async function autoRequest(url) {
15+
try {
16+
const response = await axios.get(url); // 替换为目标接口
17+
console.log(`Auto-request successful: ${response.data.message || ''}`);
18+
} catch (error) {
19+
console.log(`Auto-request failed: ${error.message}`);
20+
}
21+
}
22+
23+
server.on('listening', async () => {
1324
port = server.address().port;
1425

1526
// Get local IP addresses
@@ -22,13 +33,15 @@ globalThis.catServerFactory = (handle) => {
2233
}
2334
}
2435
}
36+
const localConfigUrl = `http://localhost:${port}/config`;
2537

2638
console.log(`Server is running:`);
27-
console.log(`- Local: http://localhost:${port}/config`);
39+
console.log(`- Local: ${localConfigUrl}`);
2840
if (addresses.length > 0) {
2941
console.log(`- Network: http://${addresses[0]}:${port}/config`);
3042
}
3143
console.log(`- Node.js version: ${process.version}`);
44+
await autoRequest(localConfigUrl);
3245
});
3346

3447
server.on('close', () => {

Diff for: nodejs/src/index.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export default {
44
home_site: 'http://localhost:5757/api/设置中心',
55
enable_dspush: 1,
66
enable_home_site: 0,
7+
sniffer_rule: 'http((?!http).){12,}?\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg|m4a|mp3)\\?.*|http((?!http).){12,}\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg|m4a|mp3)|http((?!http).)*?video/tos*|http((?!http).)*?obj/tos*',
78
},
89
ffm3u8: {
910
url: 'https://cj.ffzyapi.com/api.php/provide/vod/from/ffm3u8',

Diff for: nodejs/src/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fastify from 'fastify';
22
import router from './router.js';
3-
import { JsonDB, Config } from 'node-json-db';
3+
import {JsonDB, Config} from 'node-json-db';
44
import axios from 'axios';
55

66
let server = null;
@@ -59,7 +59,7 @@ export async function start(config) {
5959
server.db = new JsonDB(new Config((process.env['NODE_PATH'] || '.') + '/db.json', true, true, '/', true));
6060
server.register(router);
6161
// 注意 一定要监听ipv4地址 build后 app中使用时 端口使用0让系统自动分配可用端口
62-
server.listen({ port: process.env['DEV_HTTP_PORT'] || 0, host: '127.0.0.1' });
62+
server.listen({port: process.env['DEV_HTTP_PORT'] || 0, host: '::'});
6363
}
6464

6565
/**

Diff for: nodejs/src/router.js

+26-4
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,14 @@ export default async function router(fastify) {
6262
meta.type = 10;
6363
} else if (stags.includes('画')) {
6464
meta.type = 20;
65-
} else if (stags.includes('听')) {
66-
meta.type = 30;
67-
} else {
65+
}
66+
// else if (stags.includes('听')) {
67+
// meta.type = 30;
68+
// }
69+
// else if (stags.includes('盘')) {
70+
// meta.type = 40;
71+
// }
72+
else {
6873
meta.type = 7;
6974
}
7075
meta.key = skey === 'push_agent' ? 'push' : skey;
@@ -158,10 +163,27 @@ export default async function router(fastify) {
158163
config.pan.sites.push(meta);
159164
}
160165
}
166+
// ds源内容分类放
167+
dsSites.forEach((site) => {
168+
const stype = site.type;
169+
if (stype < 10) {
170+
config.video.sites.push(site);
171+
} else if (stype >= 10 && stype < 20) {
172+
config.read.sites.push(site);
173+
} else if (stype >= 20 && stype < 30) {
174+
config.comic.sites.push(site);
175+
} else if (stype >= 30 && stype < 40) {
176+
config.music.sites.push(site);
177+
} else if (stype >= 40 && stype < 50) {
178+
config.pan.sites.push(site);
179+
}
180+
});
161181

162-
config.video.sites = config.video.sites.concat(dsSites);
182+
// 把所有内容放影视分类里
183+
// config.video.sites = config.video.sites.concat(dsSites);
163184
drpyS.updateSiteMap(dsSites);
164185
config.parses = dsParses;
186+
drpyS.updateDsCache('parses', dsParses);
165187
console.log(JSON.stringify(config));
166188
reply.send(config);
167189
}

0 commit comments

Comments
 (0)