Skip to content

Commit 886ecc4

Browse files
committed
fix: 123和推送
更新版本
1 parent 120e53e commit 886ecc4

File tree

7 files changed

+100
-69
lines changed

7 files changed

+100
-69
lines changed

Diff for: README.md

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ nodejs作为服务端的drpy实现。全面升级异步写法
1919

2020
## 更新记录
2121

22+
### 20250227
23+
24+
更新至V1.1.22
25+
2226
### 20250226
2327

2428
更新至V1.1.21

Diff for: docs/updateRecord.md

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

3+
### 20250227
4+
5+
更新至V1.1.22
6+
7+
1. 优化123网盘的逻辑和推送示例
8+
2. 优化sqlite3库兼容装逼壳
9+
310
### 20250226
411

512
更新至V1.1.21

Diff for: js/push_agent.js

+25-27
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ var rule = {
2525
let vod = {
2626
vod_pic: icon,
2727
vod_id: orId,
28-
vod_content: orId || '温馨提醒:宝子们,推送的时候记得确保ids存在哟~',
29-
vod_name: 'DS推送:道长&秋秋倾情打造',
28+
vod_content: 'DS推送:道长&秋秋倾情打造',
3029
}
3130
let playPans = [];
3231
if (/^[\[{]/.test(input.trim())) {
@@ -56,7 +55,7 @@ var rule = {
5655
let list = input.split('@');
5756
// log(list);
5857
for (let i = 0; i < list.length; i++) {
59-
if (/pan.quark.cn|drive.uc.cn|www.alipan.com|www.aliyundrive.com|cloud.189.cn|yun.139.com|www.123684.com/.test(list[i])) {
58+
if (/pan.quark.cn|drive.uc.cn|www.alipan.com|www.aliyundrive.com|cloud.189.cn|yun.139.com|www.123684.com|www.123865.com|www.123912.com|www.123pan.com|www.123pan.cn|www.123592.com/.test(list[i])) {
6059
if (/pan.quark.cn/.test(list[i])) {
6160
playPans.push(list[i]);
6261
const shareData = Quark.getShareData(list[i]);
@@ -127,24 +126,24 @@ var rule = {
127126
playurls.push(urls);
128127
})
129128
}
130-
131-
if(/www.123684.com/.test(list[i])) {
129+
if(/www.123684.com|www.123865.com|www.123912.com/.test(list[i])) {
132130
playPans.push(list[i]);
133-
let shareData = Pan.getShareData(list[i])
131+
let shareData = await Pan.getShareData(list[i])
134132
let videos = await Pan.getFilesByShareUrl(shareData)
135133
if (videos.length > 0) {
136134
playform.push('Pan123-' + shareData);
137-
const urls = videos.map(item => item.FileName + "$" + [item.ShareKey, item.FileId, item.S3KeyFlag, item.Size, item.Etag].join('*')).join('#');
138-
playurls.push(urls);
135+
playurls.push(videos.map((v) => {
136+
const list = [v.ShareKey, v.FileId, v.S3KeyFlag, v.Size, v.Etag];
137+
return v.FileName + '$' + list.join('*');
138+
}).join('#'))
139139
}
140140
}
141-
142141
} else {
143142
playform.push('推送');
144143
playurls.push("推送" + '$' + list[i])
145144
}
146145
}
147-
} else if (/pan.quark.cn|drive.uc.cn|www.alipan.com|www.aliyundrive.com|cloud.189.cn|yun.139.com|www.123684.com/.test(input)) {
146+
} else if (/pan.quark.cn|drive.uc.cn|www.alipan.com|www.aliyundrive.com|cloud.189.cn|yun.139.com|www.123684.com|www.123865.com|www.123912.com|www.123pan.com|www.123pan.cn|www.123592.com/.test(input)) {
148147
if (/pan.quark.cn/.test(input)) {
149148
playPans.push(input);
150149
const shareData = Quark.getShareData(input);
@@ -184,6 +183,7 @@ var rule = {
184183
const shareData = Ali.getShareData(input);
185184
if (shareData) {
186185
const videos = await Ali.getFilesByShareUrl(shareData);
186+
log(videos);
187187
if (videos.length > 0) {
188188
playform.push('Ali-' + shareData.shareId);
189189
playurls.push(videos.map((v) => {
@@ -214,16 +214,18 @@ var rule = {
214214
playurls.push(urls);
215215
})
216216
}
217-
218-
if(/www.123684.com/.test(input)) {
217+
if(/www.123684.com|www.123865.com|www.123912.com|www.123pan.com|www.123pan.cn|www.123592.com/.test(input)) {
219218
playPans.push(input);
220-
let shareData = Pan.getShareData(input)
219+
let shareData = await Pan.getShareData(input)
221220
let videos = await Pan.getFilesByShareUrl(shareData)
222-
if (videos.length > 0) {
223-
playform.push('Pan123-' + shareData);
224-
const urls = videos.map(item => item.FileName + "$" + [item.ShareKey, item.FileId, item.S3KeyFlag, item.Size, item.Etag].join('*')).join('#');
221+
Object.keys(videos).forEach(it => {
222+
playform.push('Pan123-' + it)
223+
const urls = videos[it].map(v => {
224+
const list = [v.ShareKey, v.FileId, v.S3KeyFlag, v.Size, v.Etag];
225+
return v.FileName + '$' + list.join('*');
226+
}).join('#');
225227
playurls.push(urls);
226-
}
228+
})
227229
}
228230
} else {
229231
playform.push('推送');
@@ -328,23 +330,19 @@ var rule = {
328330
}
329331
if(flag.startsWith('Pan123-')) {
330332
log('盘123解析开始')
331-
const url = await Pan.getDownload(ids[0], ids[1], ids[2], ids[3], ids[4])
332-
urls.push("原画", url + "#isVideo=true#")
333-
log('jj:',url)
334-
let data = await Pan.getLiveTranscoding(ids[0], ids[1], ids[2], ids[3], ids[4])
333+
const url = await Pan.getDownload(ids[0],ids[1],ids[2],ids[3],ids[4])
334+
urls.push("原画",url)
335+
let data = await Pan.getLiveTranscoding(ids[0],ids[1],ids[2],ids[3],ids[4])
335336
data.forEach((item) => {
336-
urls.push(item.name, item.url)
337+
urls.push(item.name,item.url)
337338
})
338339
return {
339340
parse: 0,
340-
url: urls,
341-
header: {
342-
'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',
343-
}
341+
url: urls
344342
}
345343
}
346344
} else {
347345
return input
348346
}
349347
},
350-
}
348+
}

Diff for: libs/drpyS.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,20 @@ globalThis.simplecc = simplecc;
167167
let DataBase = null;
168168
let database = null;
169169
try {
170-
const sqliteUtil = await import('../utils/database.js'); // 使用动态 import
171-
DataBase = sqliteUtil.DataBase;
172-
database = sqliteUtil.database;
170+
if (typeof fetchByHiker !== 'undefined' && typeof globalThis.import === 'function') {
171+
const sqliteUtil = await globalThis.import('../utils/database.js'); // 海阔放在globalThis里去动态引入
172+
DataBase = sqliteUtil.DataBase;
173+
database = sqliteUtil.database;
174+
} else {
175+
const sqliteUtil = await import('../utils/database.js'); // 使用动态 import
176+
DataBase = sqliteUtil.DataBase;
177+
database = sqliteUtil.database;
178+
}
173179
console.log('sqlite3 database imported successfully');
174180
} catch (error) {
175181
console.log(`Failed to import sqlite3:${error.message}`);
176182
}
183+
177184
globalThis.DataBase = DataBase;
178185
globalThis.database = database;
179186

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "drpy-node",
3-
"version": "1.1.21",
3+
"version": "1.1.22",
44
"main": "index.js",
55
"type": "module",
66
"scripts": {

Diff for: public/index.html

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ <h1 id="drpysdrpy-node">drpyS(drpy-node)</h1>
2424
<li><a href="/cat/index.html">在线猫ds源主页</a></li>
2525
</ul>
2626
<h2 id="更新记录">更新记录</h2>
27+
<h3 id="20250227">20250227</h3>
28+
<p>更新至V1.1.22</p>
2729
<h3 id="20250226">20250226</h3>
2830
<p>更新至V1.1.21</p>
2931
<h3 id="20250225">20250225</h3>

Diff for: utils/pan123.js

+51-38
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import axios from "axios";
22
import {ENV} from "./env.js";
3+
import {base64Decode} from "../libs_drpy/crypto-util.js";
34

45

56
class Pan123 {
67
constructor() {
7-
this.regex = /https:\/\/www.123684.com\/s\/([^\\/]+)/
8+
this.regex = /https:\/\/(www.123684.com|www.123865.com|www.123912.com|www.123pan.com|www.123pan.cn|www.123592.com)\/s\/([^\\/]+)/
89
this.api = 'https://www.123684.com/b/api/share/';
910
this.loginUrl = 'https://login.123pan.com/api/user/sign_in';
11+
this.cate = ''
1012
}
1113

1214
async init() {
@@ -72,32 +74,51 @@ class Pan123 {
7274
console.log(this.SharePwd)
7375
}
7476
if (matches) {
75-
if(matches[1].indexOf('?') > 0){
76-
return matches[1].split('?')[0]
77+
if(matches[2].indexOf('?') > 0){
78+
return matches[2].split('?')[0]
7779
}else {
78-
return matches[1]
80+
return matches[2].match(/www/g)?matches[1]:matches[2];
7981
}
8082

8183
}
8284
return null;
8385
}
8486

8587
async getFilesByShareUrl(shareKey){
86-
return await this.getShareInfo(shareKey, this.SharePwd, 0, 0)
88+
let file = {}
89+
let cate = await this.getShareInfo(shareKey, this.SharePwd, 0, 0)
90+
if(cate && Array.isArray(cate)){
91+
await Promise.all(cate.map(async (item) => {
92+
if (!(item.filename in file)) {
93+
file[item.filename] = [];
94+
}
95+
const fileData = await this.getShareList(item.shareKey,item.SharePwd,item.next, item.fileId);
96+
if (fileData && fileData.length > 0) {
97+
file[item.filename].push(...fileData);
98+
}
99+
}));
100+
}
101+
// 过滤掉空数组
102+
for (let key in file) {
103+
if (file[key].length === 0) {
104+
delete file[key];
105+
}
106+
}
107+
return file;
87108
}
88109

89110
async getShareInfo(shareKey,SharePwd,next,ParentFileId) {
90-
let filelist = []
111+
let cate = []
91112
let list = await axios.get(this.api+"get",{
92113
headers: {},
93114
params: {
94115
"limit": "100",
95-
"next": "0",
116+
"next": next,
96117
"orderBy": "file_name",
97118
"orderDirection": "asc",
98119
"shareKey": shareKey,
99120
"SharePwd": SharePwd,
100-
"ParentFileId": "0",
121+
"ParentFileId": ParentFileId,
101122
"Page": "1"
102123
}
103124
});
@@ -108,24 +129,20 @@ class Pan123 {
108129
let info = list.data.data;
109130
let next = info.Next;
110131
let infoList = info.InfoList
111-
for (let i = 0; i < infoList.length; i++) {
112-
let data = infoList[i];
113-
if(data.Category === 2){
114-
filelist.push({
115-
ShareKey: shareKey,
116-
FileId: data.FileId,
117-
S3KeyFlag: data.S3KeyFlag,
118-
Size: data.Size,
119-
Etag: data.Etag,
120-
FileName: data.FileName,
121-
})
132+
infoList.forEach(item => {
133+
if(item.Category === 0){
134+
cate.push({
135+
filename:item.FileName,
136+
shareKey:shareKey,
137+
SharePwd:SharePwd,
138+
next:next,
139+
fileId:item.FileId
140+
});
122141
}
123-
let FileId = data.FileId
124-
let file = await this.getShareList(shareKey,SharePwd,next,FileId);
125-
filelist.push(...file)
126-
}
127-
128-
return filelist;
142+
})
143+
let result = await Promise.all(cate.map(async (it)=> this.getShareInfo(shareKey,SharePwd,next, it.fileId)));
144+
result = result.filter(item => item !== undefined && item !== null);
145+
return [...cate,...result.flat()];
129146
}
130147
}
131148
}
@@ -145,22 +162,18 @@ class Pan123 {
145162
"Page": "1"
146163
}
147164
})).data.data.InfoList;
148-
for (let i = 0; i < infoList.length; i++) {
149-
let data = infoList[i];
150-
if(data.Category === 2){
165+
infoList.forEach(it=>{
166+
if(it.Category === 2){
151167
video.push({
152168
ShareKey: shareKey,
153-
FileId: data.FileId,
154-
S3KeyFlag: data.S3KeyFlag,
155-
Size: data.Size,
156-
Etag: data.Etag,
157-
FileName: data.FileName,
169+
FileId: it.FileId,
170+
S3KeyFlag: it.S3KeyFlag,
171+
Size: it.Size,
172+
Etag: it.Etag,
173+
FileName: it.FileName,
158174
})
159-
}else {
160-
let FileId = data.FileId
161-
return await this.getShareList(shareKey, SharePwd, next, FileId)
162175
}
163-
}
176+
})
164177
return video;
165178
}
166179

@@ -185,7 +198,7 @@ class Pan123 {
185198
data: data
186199
};
187200
let down = (await axios.request(config)).data.data
188-
return down.DownloadURL;
201+
return base64Decode((new URL(down.DownloadURL)).searchParams.get('params'));
189202
}
190203

191204
async getLiveTranscoding(shareKey,FileId,S3KeyFlag,Size,Etag){

0 commit comments

Comments
 (0)