Skip to content

Commit bf95070

Browse files
committed
update:初步兼容ds源配置
1 parent d89ebfb commit bf95070

File tree

12 files changed

+703
-802
lines changed

12 files changed

+703
-802
lines changed

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,42 @@
11
# CatPawOpen
2+
23
Continue the development of CatVodOpen.
4+
5+
# 如何运行
6+
7+
```shell
8+
yarn dev
9+
```
10+
11+
# 如何编译
12+
13+
```shell
14+
yarn build
15+
```
16+
17+
# 调试教程
18+
19+
* windows平台自定义字体支持(flutter windows平台字体渲染效果不好 换个字体有所改善),ttf文件放入data\flutter_assets\fonts\ttf目录即可
20+
* 新增运行时调试支持,基于Node.js Debugging,方便爬虫编写打包后在App内运行时定位问题,支持sourceMap加载。 sourceMap输出请参考 esbuild 打包脚本。
21+
* 调试工作流程 app内开启调试模式 -> 重启app -> 使用chrome等调试器关联进程(参考上面的nodejs官方文档) -> 发现问题 修改源码 打包js -> 应用内重载 -> 继续调试
22+
23+
# 参考资料
24+
25+
* [nodejs应用内调试教程](https://nodejs.org/en/learn/getting-started/debugging)
26+
* [谷歌浏览器调试地址](chrome://inspect)
27+
28+
# 猫配置地址
29+
30+
- assets://js/index.js.md5
31+
32+
# 已知问题
33+
34+
1. 不支持push://协议,某些网盘不可用(猫无法通过push跳转二级,虽然代码可以自动处理push,lazy却存在问题)
35+
2. 不支持设置中心动作交互
36+
37+
# 待完善
38+
39+
* 暂未兼容 push://协议,代码里有Bug
40+
* 批量搜索会出问题,没法识别指定key
41+
* 暂未兼容漫画小说播放逻辑
42+
* 采王二级有问题暂未适配

nodejs/copyDist.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Import required modules
2+
import fs from 'fs';
3+
import path from 'path';
4+
import { execSync } from 'child_process';
5+
6+
// Check if the destination path is provided
7+
if (process.argv.length < 3) {
8+
console.error('Usage: node script.js <destination_path>');
9+
process.exit(1);
10+
}
11+
12+
// Get the destination path from command-line arguments
13+
const destinationPath = process.argv[2];
14+
15+
// Resolve paths
16+
const distPath = path.resolve(process.cwd(), 'dist');
17+
const targetPath = path.resolve(destinationPath);
18+
19+
// Check if dist directory exists
20+
if (!fs.existsSync(distPath)) {
21+
console.error(`Source directory does not exist: ${distPath}`);
22+
process.exit(1);
23+
}
24+
25+
// Check if target directory exists
26+
if (!fs.existsSync(targetPath)) {
27+
console.error(`Target directory does not exist: ${targetPath}`);
28+
process.exit(1);
29+
}
30+
31+
// Copy files from dist to target
32+
const copyFiles = (srcDir, destDir) => {
33+
const entries = fs.readdirSync(srcDir, { withFileTypes: true });
34+
35+
entries.forEach((entry) => {
36+
const srcPath = path.join(srcDir, entry.name);
37+
const destPath = path.join(destDir, entry.name);
38+
39+
if (entry.isDirectory()) {
40+
// Create directory if it doesn't exist
41+
if (!fs.existsSync(destPath)) {
42+
fs.mkdirSync(destPath);
43+
}
44+
// Recursively copy files
45+
copyFiles(srcPath, destPath);
46+
} else {
47+
// Copy file and overwrite if exists
48+
fs.copyFileSync(srcPath, destPath);
49+
console.log(`Copied: ${srcPath} -> ${destPath}`);
50+
}
51+
});
52+
};
53+
54+
try {
55+
console.log(`Copying files from ${distPath} to ${targetPath}...`);
56+
copyFiles(distPath, targetPath);
57+
console.log('All files copied successfully.');
58+
} catch (error) {
59+
console.error('Error during file copy:', error);
60+
process.exit(1);
61+
}

nodejs/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"scripts": {
77
"dev": "cross-env DEV_HTTP_PORT=3006 nodemon --config nodemon.json src/dev.js",
88
"build": "rimraf dist && cross-env NODE_ENV=production node esbuild.js && cross-env NODE_ENV=production node esbuild-config.js",
9+
"build:copy": "rimraf dist && cross-env NODE_ENV=production node esbuild.js && cross-env NODE_ENV=production node esbuild-config.js && node copyDist.js \"D:\\\\soft\\\\猫影视\\\\Release\\\\data\\\\flutter_assets\\\\asset\\\\js\"",
910
"build:config": "cross-env NODE_ENV=production node esbuild-config.js",
1011
"build:rollup": "rimraf dist && cross-env NODE_ENV=production node rollup.js && cross-env NODE_ENV=production node rollup-config.js",
1112
"build:rollup:config": "cross-env NODE_ENV=production node rollup-config.js"
@@ -36,6 +37,7 @@
3637
"hls-parser": "^0.10.8",
3738
"iconv-lite": "^0.6.3",
3839
"node-json-db": "^2.3.0",
39-
"node-rsa": "^1.1.1"
40+
"node-rsa": "^1.1.1",
41+
"qs": "^6.14.0"
4042
}
41-
}
43+
}
878 KB
Binary file not shown.

nodejs/src/dev.js

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,45 @@
11
import { createServer } from 'http';
2+
import os from 'os';
3+
import { start } from './index.js';
4+
import * as config from './index.config.js';
25

36
globalThis.catServerFactory = (handle) => {
47
let port = 0;
58
const server = createServer((req, res) => {
69
handle(req, res);
710
});
11+
812
server.on('listening', () => {
913
port = server.address().port;
10-
console.log('Run on ' + port);
14+
15+
// Get local IP addresses
16+
const networkInterfaces = os.networkInterfaces();
17+
const addresses = [];
18+
for (const interfaceName in networkInterfaces) {
19+
for (const net of networkInterfaces[interfaceName]) {
20+
if (!net.internal && net.family === 'IPv4') {
21+
addresses.push(net.address);
22+
}
23+
}
24+
}
25+
26+
console.log(`Server is running:`);
27+
console.log(`- Local: http://localhost:${port}/config`);
28+
if (addresses.length > 0) {
29+
console.log(`- Network: http://${addresses[0]}:${port}/config`);
30+
}
31+
console.log(`- Node.js version: ${process.version}`);
1132
});
33+
1234
server.on('close', () => {
13-
console.log('Close on ' + port);
35+
console.log('Server closed on port ' + port);
1436
});
37+
1538
return server;
1639
};
1740

1841
globalThis.catDartServerPort = () => {
1942
return 0;
2043
};
2144

22-
import { start } from './index.js';
23-
24-
import * as config from './index.config.js';
25-
2645
start(config.default);

nodejs/src/index.config.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
export default {
2-
kunyu77: {
3-
testcfg: {
4-
bbbb: 'aaaaa',
5-
},
2+
drpyS: {
3+
config_url: 'http://127.0.0.1:5757/config/1?sub=all&pwd=',
64
},
75
ffm3u8: {
86
url: 'https://cj.ffzyapi.com/api.php/provide/vod/',

nodejs/src/router.js

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import kunyu77 from './spider/video/kunyu77.js';
2-
import kkys from './spider/video/kkys.js';
1+
import * as cfg from './index.config.js';
32
import push from './spider/video/push.js';
43
import alist from './spider/pan/alist.js';
54
import _13bqg from './spider/book/13bqg.js';
65
import copymanga from './spider/book/copymanga.js';
76
import ffm3u8 from './spider/video/ffm3u8.js';
7+
import drpyS from './spider/video/drpyS.js';
8+
import {request} from "./util/request.js";
89

9-
const spiders = [kunyu77, kkys, ffm3u8, push, alist, _13bqg, copymanga];
10+
const spiders = [ffm3u8, push, alist, _13bqg, copymanga, drpyS];
1011
const spiderPrefix = '/spider';
1112

1213
/**
@@ -19,9 +20,20 @@ export default async function router(fastify) {
1920
// register all spider router
2021
spiders.forEach((spider) => {
2122
const path = spiderPrefix + '/' + spider.meta.key + '/' + spider.meta.type;
22-
fastify.register(spider.api, { prefix: path });
23+
fastify.register(spider.api, {prefix: path});
2324
console.log('Register spider: ' + path);
2425
});
26+
// console.log(cfg.default);
27+
// if (cfg.default.drpyS && cfg.default.drpyS.config_url) {
28+
// let drpyS_config_url = cfg.default.drpyS.config_url;
29+
// if (drpyS_config_url && drpyS_config_url.startsWith('http')) {
30+
// let drpyS_data = await request(drpyS_config_url);
31+
// if (drpyS_data.sites_count && drpyS_data.homepage === 'https://github.com/hjdhnx/drpy-node') {
32+
// let drpyS_sites = drpyS_data.sites;
33+
// console.log(drpyS_sites);
34+
// }
35+
// }
36+
// }
2537
/**
2638
* @api {get} /check 检查
2739
*/
@@ -39,7 +51,7 @@ export default async function router(fastify) {
3951
* @param {import('fastify').FastifyReply} reply
4052
*/
4153
async function (_request, reply) {
42-
reply.send({ run: !fastify.stop });
54+
reply.send({run: !fastify.stop});
4355
}
4456
);
4557
fastify.get(
@@ -72,6 +84,7 @@ export default async function router(fastify) {
7284
let meta = Object.assign({}, spider.meta);
7385
meta.api = spiderPrefix + '/' + meta.key + '/' + meta.type;
7486
meta.key = 'nodejs_' + meta.key;
87+
meta.ext = '';
7588
const stype = spider.meta.type;
7689
if (stype < 10) {
7790
config.video.sites.push(meta);
@@ -85,6 +98,32 @@ export default async function router(fastify) {
8598
config.pan.sites.push(meta);
8699
}
87100
});
101+
102+
console.log(cfg.default);
103+
if (cfg.default.drpyS && cfg.default.drpyS.config_url) {
104+
let drpyS_config_url = cfg.default.drpyS.config_url;
105+
if (drpyS_config_url && drpyS_config_url.startsWith('http')) {
106+
let drpyS_data = await request(drpyS_config_url);
107+
if (drpyS_data.sites_count && drpyS_data.homepage === 'https://github.com/hjdhnx/drpy-node') {
108+
let drpyS_sites = drpyS_data.sites.filter(site => site.type === 4);
109+
console.log(drpyS_sites);
110+
const sites = drpyS_sites.map((site) => {
111+
let meta = {};
112+
meta.key = site.key;
113+
meta.name = site.name;
114+
meta.type = site.type;
115+
meta.api = '/spider/drpyS/4';
116+
meta.ext = {api: site.api, extend: site.ext};
117+
return meta;
118+
});
119+
config.video.sites = config.video.sites.concat(sites);
120+
drpyS.updateSiteMap(sites);
121+
config.parses = drpyS_data.parses;
122+
}
123+
}
124+
}
125+
126+
console.log(JSON.stringify(config));
88127
reply.send(config);
89128
}
90129
);

0 commit comments

Comments
 (0)