Skip to content

Commit b7b8099

Browse files
committed
update:升级AI支持
1 parent c812f19 commit b7b8099

28 files changed

+2312
-61
lines changed

.env.development

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@ LOG_WITH_FILE = 1
88
# trace/debug/info/warn/error/fatal
99
LOG_LEVEL = info
1010
COOKIE_AUTH_CODE = drpys
11+
API_AUTH_NAME = admin
12+
API_AUTH_CODE = drpys
13+
API_PWD = dzyyds
1114
LIVE_URL = 'https://livetv.wqwqwq.sbs/tv.m3u'
1215
# LIVE_URL = './lives/tv.m3u'

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,24 @@
33
nodejs作为服务端的drpy实现。全面升级异步写法
44
积极开发中,每日一更,当前进度 `23%`
55

6-
* [本地配置接口-动态本地](/config)
7-
* [本地配置接口-动态外网/局域网](/config/1)
6+
* [本地配置接口-动态本地](/config?pwd=)
7+
* [本地配置接口-动态外网/局域网](/config/1?pwd=)
88
* [其他配置接口-订阅过滤](/docs/sub.md)
99
* [代码加解密工具](/admin/encoder)
1010
* [V我50支付凭证生成器](/authcoder?len=10&number=1)
1111
* [接口压测教程](/docs/httpTest.md)
1212
* [央视点播解析工具](/proxy/央视大全[官]/index.html)
1313
* [cookie管理插件](/apps/cookie-butler/index.html)
14+
* [本站防止爬虫协议](/robots.txt)
1415

1516
## 更新记录
1617

17-
### 20241230
18+
### 20241231
1819

19-
更新至V1.0.26
20+
更新至V1.0.27
2021

21-
1. 设置中心优化,样式适配装逼壳。并支持全局站源动作
22-
2. 新增AI动作交互,用设置中心的连续对话即可测试
22+
1. Ai多样化
23+
2. 接口授权支持
2324

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

@@ -46,6 +47,7 @@ todo:
4647
* [crypto-js-wasm使用教程](docs/crypto-js-wasm/readme-CN.md)
4748
* [puppeteer使用教程](docs/pupInstall.md)
4849
* [drpyS源属性说明](docs/ruleAttr.md)
50+
* [drpy2写源简述](docs/ruleDesc.md)
4951
* [讯飞星火开放平台](https://console.xfyun.cn/services/bm4)
5052
* [讯飞星火智能体数据集](https://xinghuo.xfyun.cn/botcenter/private-dataset)
5153

controllers/api.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import {existsSync} from 'fs';
33
import {base64Decode} from '../libs_drpy/crypto-util.js';
44
import * as drpy from '../libs/drpyS.js';
55
import {ENV} from "../utils/env.js";
6+
import {validatePwd} from "../utils/api_validate.js";
67

78
export default (fastify, options, done) => {
89
// 动态加载模块并根据 query 执行不同逻辑
910
fastify.route({
1011
method: ['GET', 'POST'], // 同时支持 GET 和 POST
1112
url: '/api/:module',
13+
preHandler: validatePwd,
1214
schema: {
1315
consumes: ['application/json', 'application/x-www-form-urlencoded'], // 声明支持的内容类型
1416
},

controllers/config.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import path from 'path';
33
import * as drpy from '../libs/drpyS.js';
44
import {naturalSort, urljoin} from '../utils/utils.js'
55
import {ENV} from "../utils/env.js";
6+
import {validatePwd} from "../utils/api_validate.js";
67

78
// 工具函数:生成 JSON 数据
8-
async function generateSiteJSON(jsDir, requestHost, sub, subFilePath) {
9+
async function generateSiteJSON(jsDir, requestHost, sub, subFilePath, pwd) {
910
const files = readdirSync(jsDir);
1011
let valid_files = files.filter((file) => file.endsWith('.js') && !file.startsWith('_')); // 筛选出不是 "_" 开头的 .js 文件
1112
let sort_list = [];
@@ -42,7 +43,10 @@ async function generateSiteJSON(jsDir, requestHost, sub, subFilePath) {
4243
const baseName = path.basename(file, '.js'); // 去掉文件扩展名
4344
let key = `drpyS_${baseName}`;
4445
let name = `${baseName}(DS)`;
45-
const api = `${requestHost}/api/${baseName}`; // 使用请求的 host 地址,避免硬编码端口
46+
let api = `${requestHost}/api/${baseName}`; // 使用请求的 host 地址,避免硬编码端口
47+
if (pwd) {
48+
api += `?pwd=${pwd}`;
49+
}
4650
let ruleObject = {
4751
searchable: 0, // 固定值
4852
filterable: 0, // 固定值
@@ -168,7 +172,7 @@ function getSubs(subFilePath) {
168172

169173
export default (fastify, options, done) => {
170174

171-
fastify.get('/index', async (request, reply) => {
175+
fastify.get('/index', {preHandler: validatePwd}, async (request, reply) => {
172176
if (!existsSync(options.indexFilePath)) {
173177
reply.code(404).send({error: 'index.json not found'});
174178
return;
@@ -179,9 +183,10 @@ export default (fastify, options, done) => {
179183
});
180184

181185
// 接口:返回配置 JSON,同时写入 index.json
182-
fastify.get('/config*', async (request, reply) => {
186+
fastify.get('/config*', {preHandler: validatePwd}, async (request, reply) => {
183187
let t1 = (new Date()).getTime();
184188
const query = request.query; // 获取 query 参数
189+
const pwd = query.pwd || '';
185190
const sub_code = query.sub || '';
186191
const cfg_path = request.params['*']; // 捕获整个路径
187192
try {
@@ -201,7 +206,7 @@ export default (fastify, options, done) => {
201206
}
202207
}
203208

204-
const siteJSON = await generateSiteJSON(options.jsDir, requestHost, sub, options.subFilePath);
209+
const siteJSON = await generateSiteJSON(options.jsDir, requestHost, sub, options.subFilePath, pwd);
205210
const parseJSON = generateParseJSON(options.jxDir, requestHost);
206211
const livesJSON = generateLivesJSON(requestHost);
207212
const playerJSON = generatePlayerJSON(options.configDir, requestHost);

controllers/root.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import path from 'path';
22
import {readdirSync, readFileSync, writeFileSync, existsSync} from 'fs';
33
import '../utils/marked.min.js';
44
import {computeHash} from '../utils/utils.js';
5+
import {validateBasicAuth} from "../utils/api_validate.js";
56

67
export default (fastify, options, done) => {
78
// 添加 / 接口
8-
fastify.get('/', async (request, reply) => {
9+
fastify.get('/', {preHandler: validateBasicAuth}, async (request, reply) => {
910
let readmePath = null;
1011
const indexHtmlPath = path.join(options.rootDir, 'public/index.html');
1112
// console.log(`indexHtmlPath:${indexHtmlPath}`);
@@ -62,6 +63,11 @@ export default (fastify, options, done) => {
6263
reply.type('text/html;charset=utf-8').send(indexHtml);
6364
});
6465

66+
// 新增 /robots.txt 路由
67+
fastify.get('/robots.txt', (request, reply) => {
68+
reply.type('text/plain;charset=utf-8').sendFile('robots.txt', path.join(options.rootDir, 'public'));
69+
});
70+
6571
// 新增 /favicon.ico 路由
6672
fastify.get('/favicon.ico', async (request, reply) => {
6773
try {

custom.json

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"sites_count": 37,
2+
"sites_count": 40,
33
"sites": [
44
{
55
"key": "drpyS_设置中心",
@@ -14,7 +14,7 @@
1414
"actions": [
1515
{
1616
"name": "连续对话",
17-
"action": "{\"actionId\":\"连续对话\",\"id\":\"talk\",\"type\":\"input\",\"title\":\"连续对话\",\"tip\":\"请输入消息\",\"value\":\"\",\"msg\":\"开始新的对话\",\"button\":3,\"imageUrl\":\"https://img2.baidu.com/it/u=1206278833,3265480730&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=800\",\"imageHeight\":200,\"imageType\":\"card_pic_3\",\"keep\":true}"
17+
"action": "{\"actionId\":\"连续对话\",\"id\":\"talk\",\"type\":\"input\",\"title\":\"连续对话\",\"tip\":\"请输入消息\",\"value\":\"\",\"msg\":\"开始新的对话\",\"button\":3,\"imageUrl\":\"https://img2.baidu.com/it/u=1206278833,3265480730&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=800\",\"imageHeight\":200,\"imageType\":\"card_pic_3\",\"keep\":true,\"width\":680,\"height\":800,\"msgType\":\"long_text\",\"httpTimeout\":60,\"canceledOnTouchOutside\":false}"
1818
},
1919
{
2020
"name": "查看夸克cookie",
@@ -156,6 +156,16 @@
156156
"quickSearch": 0,
157157
"ext": ""
158158
},
159+
{
160+
"key": "drpyS_火车太堵",
161+
"name": "火车太堵(DS)",
162+
"type": 4,
163+
"api": "http://localhost:5757/api/火车太堵",
164+
"searchable": 1,
165+
"filterable": 0,
166+
"quickSearch": 0,
167+
"ext": ""
168+
},
159169
{
160170
"key": "drpyS_荐片",
161171
"name": "荐片(DS)",
@@ -256,6 +266,16 @@
256266
"quickSearch": 0,
257267
"ext": ""
258268
},
269+
{
270+
"key": "drpyS_团长资源[盘]",
271+
"name": "团长资源[盘](DS)",
272+
"type": 4,
273+
"api": "http://localhost:5757/api/团长资源[盘]",
274+
"searchable": 1,
275+
"filterable": 0,
276+
"quickSearch": 1,
277+
"ext": ""
278+
},
259279
{
260280
"key": "push_agent",
261281
"name": "推送(DS)",
@@ -326,6 +346,16 @@
326346
"quickSearch": 0,
327347
"ext": ""
328348
},
349+
{
350+
"key": "drpyS_专享影视",
351+
"name": "专享影视(DS)",
352+
"type": 4,
353+
"api": "http://localhost:5757/api/专享影视",
354+
"searchable": 1,
355+
"filterable": 0,
356+
"quickSearch": 0,
357+
"ext": ""
358+
},
329359
{
330360
"key": "drpyS_ACG漫画网[画]",
331361
"name": "ACG漫画网[画](DS)",

0 commit comments

Comments
 (0)