Skip to content

Commit 818ea9b

Browse files
committed
update:增加源加密功能
1 parent c3f4854 commit 818ea9b

19 files changed

+520
-68
lines changed

Diff for: .nomedia

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hjdhnx

Diff for: README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ nodejs作为服务端的drpy实现。全面升级异步写法
55
* [本地配置接口-动态本地](/config)
66
* [本地配置接口-动态外网/局域网](/config/1)
77
* [本地配置接口-静态](/index)
8+
* [代码加密工具](/admin/encoder)
89

910
## 更新记录
1011

11-
### 20241205
12+
### 20241206
1213

13-
1. 完善本地代理功能
14+
1. 增加源加密功能
1415

1516
[点此查看完整更新记录](docs/updateRecord.md)
1617

Diff for: controllers/encoder.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import {jsEncoder} from '../libs/drpyS.js';
2+
3+
// 仅仅支持json post 如: {"type":"gzip","code":"xxx"}
4+
export default (fastify, options, done) => {
5+
// 注册 POST 路由
6+
fastify.post('/encoder', async (request, reply) => {
7+
const {code, type} = request.body;
8+
9+
if (!code || !type) {
10+
return reply.status(400).send({error: 'Missing required parameters: code and type'});
11+
}
12+
13+
try {
14+
let result;
15+
16+
switch (type) {
17+
case 'base64':
18+
result = jsEncoder.base64Encode(code);
19+
break;
20+
case 'gzip':
21+
result = jsEncoder.gzip(code);
22+
break;
23+
case 'aes':
24+
result = jsEncoder.aes_encrypt(code);
25+
break;
26+
case 'rsa':
27+
result = jsEncoder.rsa_encode(code);
28+
break;
29+
default:
30+
throw new Error(`Unsupported type: ${type}`);
31+
}
32+
33+
reply.send({success: true, result});
34+
} catch (error) {
35+
reply.status(500).send({error: error.message});
36+
}
37+
});
38+
done();
39+
};

Diff for: controllers/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ import docsController from './docs.js';
22
import configController from './config.js';
33
import apiController from './api.js';
44
import rootController from './root.js';
5+
import encoderController from './encoder.js';
6+
import webController from './web.js';
57

68
export const registerRoutes = (fastify, options) => {
79
fastify.register(docsController, options);
810
fastify.register(configController, options);
911
fastify.register(apiController, options);
1012
fastify.register(rootController, options);
13+
fastify.register(encoderController, options);
14+
fastify.register(webController, options);
1115
};

Diff for: controllers/web.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {readFileSync, existsSync} from 'fs';
2+
import path from 'path';
3+
4+
export default (fastify, options, done) => {
5+
// 读取 views 目录下的 encoder.html 文件并返回
6+
fastify.get('/admin/encoder', async (request, reply) => {
7+
const encoderFilePath = path.join(options.viewsDir, 'encoder.html'); // 获取 encoder.html 文件的路径
8+
9+
// 检查文件是否存在
10+
if (!existsSync(encoderFilePath)) {
11+
return reply.status(404).send({error: 'encoder.html not found'});
12+
}
13+
14+
try {
15+
// 读取 HTML 文件内容
16+
const htmlContent = readFileSync(encoderFilePath, 'utf-8');
17+
reply.type('text/html').send(htmlContent); // 返回 HTML 文件内容
18+
} catch (error) {
19+
fastify.log.error(`Failed to read encoder.html: ${error.message}`);
20+
return reply.status(500).send({error: 'Failed to load encoder page'});
21+
}
22+
});
23+
24+
done();
25+
};

Diff for: docs/updateRecord.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# drpyS更新记录
22

3+
### 20241206
4+
5+
更新至V1.0.3
6+
7+
1. 完善图片代理相关函数与功能
8+
2. 增加加密源的数据解析
9+
3. crypto-js-wasm.js兼容海阔调用CryptoJSW对象
10+
4. 更新金牌影视,本地代理修复播放问题
11+
5. 暴露更多函数给drpyS源使用。如gzip、ungzip等等
12+
6. 增加源加密功能
13+
7. 根目录增加.nomedia规避手机相册识别ts文件为媒体图片问题
14+
315
### 20241205
416

517
更新至V1.0.2

Diff for: index.js

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ registerRoutes(fastify, {
2424
rootDir: __dirname,
2525
docsDir: path.join(__dirname, 'docs'),
2626
jsDir: path.join(__dirname, 'js'),
27+
viewsDir: path.join(__dirname, 'views'),
2728
PORT,
2829
indexFilePath: path.join(__dirname, 'index.json'),
2930
customFilePath: path.join(__dirname, 'custom.json'),

Diff for: index.json

+28-4
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,55 @@
44
"key": "drpyS_人人视频",
55
"name": "人人视频(drpyS)",
66
"type": 4,
7-
"api": "http://localhost:5757/api/人人视频",
7+
"api": "http://127.0.0.1:5757/api/人人视频",
88
"searchable": 1,
99
"ext": ""
1010
},
1111
{
1212
"key": "drpyS_星芽短剧",
1313
"name": "星芽短剧(drpyS)",
1414
"type": 4,
15-
"api": "http://localhost:5757/api/星芽短剧",
15+
"api": "http://127.0.0.1:5757/api/星芽短剧",
1616
"searchable": 1,
1717
"ext": ""
1818
},
1919
{
2020
"key": "drpyS_番茄小说[书]",
2121
"name": "番茄小说[书](drpyS)",
2222
"type": 4,
23-
"api": "http://localhost:5757/api/番茄小说[书]",
23+
"api": "http://127.0.0.1:5757/api/番茄小说[书]",
24+
"searchable": 1,
25+
"ext": ""
26+
},
27+
{
28+
"key": "drpyS_色花堂[密+]",
29+
"name": "色花堂[密+](drpyS)",
30+
"type": 4,
31+
"api": "http://127.0.0.1:5757/api/色花堂[密+]",
32+
"searchable": 1,
33+
"ext": ""
34+
},
35+
{
36+
"key": "drpyS_草榴社区[密]",
37+
"name": "草榴社区[密](drpyS)",
38+
"type": 4,
39+
"api": "http://127.0.0.1:5757/api/草榴社区[密]",
2440
"searchable": 1,
2541
"ext": ""
2642
},
2743
{
2844
"key": "drpyS_金牌影院",
2945
"name": "金牌影院(drpyS)",
3046
"type": 4,
31-
"api": "http://localhost:5757/api/金牌影院",
47+
"api": "http://127.0.0.1:5757/api/金牌影院",
48+
"searchable": 1,
49+
"ext": ""
50+
},
51+
{
52+
"key": "drpyS_黑料不打烊[密]",
53+
"name": "黑料不打烊[密](drpyS)",
54+
"type": 4,
55+
"api": "http://127.0.0.1:5757/api/黑料不打烊[密]",
3256
"searchable": 1,
3357
"ext": ""
3458
}

Diff for: js/色花堂[密+].js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: js/草榴社区[密].js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: js/金牌影院.js

+34-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// http://localhost:5757/api/金牌影院?ac=list&t=1&pg=1
22
// http://localhost:5757/api/金牌影院?ac=detail&ids=/detail/131374
33
// http://localhost:5757/api/金牌影院?wd=我的&pg=1
4-
// http://localhost:5757/api/金牌影院?play=&flag=金牌影院
4+
// http://localhost:5757/api/金牌影院?play=/vod/play/131374/sid/1125278&flag=金牌影院
55
var rule = {
66
类型: '影视',
77
title: '金牌影院',
88
desc: '金牌影院纯js版本',
9-
host: 'https://www.cfkj86.com/',
9+
host: 'https://www.cfkj86.com',
1010
homeUrl:'',
1111
url: 'https://m.cfkj86.com/api/mw-movie/anonymous/video/list?pageNum=fypage&pageSize=30&sort=1&sortBy=1&type1=fyclass',
1212
searchUrl: '/api/mw-movie/anonymous/video/searchByWordPageable?keyword=**&pageNum=fypage&pageSize=12&type=false',
@@ -49,7 +49,7 @@ var rule = {
4949
headers:{
5050
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36',
5151
'Accept': 'application/json, text/plain, */*',
52-
'deviceId': misc.randUUID(),
52+
'deviceId': '58a80c52-138c-48fd-8edb-138fd74d12c8',
5353
'sign': key,
5454
't': t
5555
}
@@ -68,7 +68,6 @@ var rule = {
6868
return setResult(d)
6969
},
7070
二级: async function (ids) {
71-
log(this)
7271
let {input} = this;
7372
const html = (await req(`${input}`)).content;
7473
const $ = pq(html)
@@ -102,7 +101,7 @@ var rule = {
102101
headers:{
103102
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36',
104103
'Accept': 'application/json, text/plain, */*',
105-
'deviceId': misc.randUUID(),
104+
'deviceId': '58a80c52-138c-48fd-8edb-138fd74d12c8',
106105
'sign': key,
107106
't': t
108107
}
@@ -130,14 +129,40 @@ var rule = {
130129
const html = JSON.parse((await req(relurl,
131130
{
132131
headers:{
133-
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36',
132+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
134133
'Accept': 'application/json, text/plain, */*',
135-
'deviceId': misc.randUUID(),
134+
'Accept-Encoding': 'gzip, deflate, br, zstd',
135+
'sec-ch-ua-platform': '"Windows"',
136+
'deviceId': '58a80c52-138c-48fd-8edb-138fd74d12c8',
136137
'sign': key,
137-
't': t
138+
't': t,
139+
'referer': `${rule.host}${input}`,
140+
'authorization': '',
138141
}
139142
})).content)
140-
return {parse: 0, url: html.data.playUrl, js: ''}
143+
return {parse: 0, url: getProxyUrl()+'&url='+html.data.playUrl, js: ''}
144+
},
145+
proxy_rule: async function() {
146+
let {input} = this
147+
if (input) {
148+
let m3u8 = (await req(input)).content;
149+
const lines = m3u8.split('\n');
150+
const tsUrls = [];
151+
let link_start = ''
152+
lines.forEach(line => {
153+
if (line.trim().startsWith('http') && line.endsWith('.ts')) {
154+
tsUrls.push(/line/,link_start + line.trim())
155+
}
156+
if (line.indexOf('.ts') > 0) { // 确保只匹配 TS 片段的 URL
157+
link_start = input.split('?')[0].replace(/([^/]+)(?=\.m3u8(?:$|[\?#]))/, '').replace('.m3u8', '')
158+
tsUrls.push(link_start + line.trim())
159+
}else {
160+
tsUrls.push(line)
161+
}
162+
})
163+
m3u8_text = tsUrls.join('\n')
164+
return [200,'application/vnd.apple.mpegurl', m3u8_text];
165+
}
141166
},
142167
};
143168

0 commit comments

Comments
 (0)