Skip to content

Commit a6d3df1

Browse files
committed
update:UC扫码及源
1 parent 010a468 commit a6d3df1

File tree

16 files changed

+861
-132
lines changed

16 files changed

+861
-132
lines changed

Diff for: README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ nodejs作为服务端的drpy实现。全面升级异步写法
1313

1414
## 更新记录
1515

16-
### 20241222
16+
### 20241223
1717

18-
更新至V1.0.18
18+
更新至V1.0.19
1919

20-
1. 夸克扫码获取cookie功能修复
20+
1. 更新源
2121

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

Diff for: apps/cookie-butler/index.html

+5-4
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,21 @@
8989
if (activeLi) {
9090
const textValue = document.getElementById("cookie-res").value || '';
9191
const active_name = activeLi.textContent.trim();
92-
const active_key = activeLi.getAttribute('data-platform').trim() + '_cookie';
93-
console.log(`准备入库cookie:${active_name} ${active_key},值为:${textValue}`);
92+
const active_key = activeLi.getAttribute('data-platform').trim();
93+
const save_key = active_key === 'ali' ? active_key + '_token' : active_key + '_cookie';
94+
console.log(`准备入库cookie:${active_name} ${save_key},值为:${textValue}`);
9495

9596
const cookie_auth_code = prompt('cookie入库功能需要管理员授权码,请你正确输入后继续');
9697
if (cookie_auth_code) {
9798
// 使用 axios 发送 POST 请求
9899
axios.post('/admin/cookie-set', {
99100
cookie_auth_code: cookie_auth_code,
100-
key: active_key,
101+
key: save_key,
101102
value: textValue.trim().replaceAll('\n', '')
102103
})
103104
.then(response => {
104105
if (response.data.success) {
105-
alert(`Cookie 入库成功:${active_name} (${active_key})`);
106+
alert(`Cookie 入库成功:${active_name} (${save_key})`);
106107
} else {
107108
alert(`入库失败:${response.data.message}`);
108109
}

Diff for: apps/cookie-butler/static/js/core.js

+49-30
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ class QRCodeHandler {
3838
} else {
3939
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
4040
const r = (Math.random() * 16) | 0,
41-
v = c == 'x' ? r : (r & 0x3) | 0x8;
41+
v = c == 'x' ? r : (r & 0x3) | 0x8;
4242
return v.toString(16);
43-
});
43+
});
4444
}
4545
}
4646

@@ -57,32 +57,32 @@ class QRCodeHandler {
5757
const result = [];
5858
let currentCookie = '';
5959
let inExpires = false;
60-
60+
6161
for (let i = 0; i < cookieString.length; i++) {
6262
const char = cookieString[i];
63-
63+
6464
// 判断是否进入或退出 `expires` 属性
6565
if (cookieString.slice(i, i + 8).toLowerCase() === 'expires=') {
66-
inExpires = true;
66+
inExpires = true;
6767
}
6868
if (inExpires && char === ';') {
69-
inExpires = false;
69+
inExpires = false;
7070
}
71-
71+
7272
// 检测到逗号分隔符并且不在 `expires` 属性中,表示一个 Cookie 条目结束
7373
if (char === ',' && !inExpires) {
74-
result.push(currentCookie.trim());
75-
currentCookie = '';
74+
result.push(currentCookie.trim());
75+
currentCookie = '';
7676
} else {
77-
currentCookie += char;
77+
currentCookie += char;
7878
}
7979
}
80-
80+
8181
// 添加最后一个 Cookie 条目
8282
if (currentCookie.trim()) {
8383
result.push(currentCookie.trim());
8484
}
85-
85+
8686
return result;
8787
};
8888

@@ -172,7 +172,7 @@ class QRCodeHandler {
172172
async _checkQuarkStatus() {
173173
const state = this.platformStates[QRCodeHandler.PLATFORM_QUARK];
174174
if (!state) {
175-
return { status: QRCodeHandler.STATUS_EXPIRED };
175+
return {status: QRCodeHandler.STATUS_EXPIRED};
176176
}
177177

178178
try {
@@ -238,9 +238,9 @@ class QRCodeHandler {
238238
};
239239
} else if (resData.data.status === 50004002) { // token过期
240240
this.platformStates[QRCodeHandler.PLATFORM_QUARK] = null;
241-
return { status: QRCodeHandler.STATUS_EXPIRED };
241+
return {status: QRCodeHandler.STATUS_EXPIRED};
242242
} else {
243-
return { status: QRCodeHandler.STATUS_NEW };
243+
return {status: QRCodeHandler.STATUS_NEW};
244244
}
245245
} catch (e) {
246246
this.platformStates[QRCodeHandler.PLATFORM_QUARK] = null;
@@ -291,7 +291,7 @@ class QRCodeHandler {
291291
async _checkAliStatus() {
292292
const state = this.platformStates[QRCodeHandler.PLATFORM_ALI];
293293
if (!state) {
294-
return { status: QRCodeHandler.STATUS_EXPIRED };
294+
return {status: QRCodeHandler.STATUS_EXPIRED};
295295
}
296296

297297
try {
@@ -325,29 +325,30 @@ class QRCodeHandler {
325325
const resData = res.data;
326326

327327
if (!resData.data.content || !resData.data.content.data) {
328-
return { status: QRCodeHandler.STATUS_EXPIRED };
328+
return {status: QRCodeHandler.STATUS_EXPIRED};
329329
}
330330

331331
const status = resData.data.content.data.qrCodeStatus;
332332

333333
if (status === "CONFIRMED") {
334334
if (resData.data.content.data.bizExt) {
335335
const bizExt = JSON.parse(atob(resData.data.content.data.bizExt));
336+
console.log(bizExt.pds_login_result);
336337
return {
337338
status: QRCodeHandler.STATUS_CONFIRMED,
338339
token: bizExt.pds_login_result.refreshToken
339340
};
340341
}
341-
return { status: QRCodeHandler.STATUS_EXPIRED };
342+
return {status: QRCodeHandler.STATUS_EXPIRED};
342343
} else if (status === "SCANED") {
343-
return { status: QRCodeHandler.STATUS_SCANED };
344+
return {status: QRCodeHandler.STATUS_SCANED};
344345
} else if (status === "CANCELED") {
345346
this.platformStates[QRCodeHandler.PLATFORM_ALI] = null;
346-
return { status: QRCodeHandler.STATUS_CANCELED };
347+
return {status: QRCodeHandler.STATUS_CANCELED};
347348
} else if (status === "NEW") {
348-
return { status: QRCodeHandler.STATUS_NEW };
349+
return {status: QRCodeHandler.STATUS_NEW};
349350
} else {
350-
return { status: QRCodeHandler.STATUS_EXPIRED };
351+
return {status: QRCodeHandler.STATUS_EXPIRED};
351352
}
352353
} catch (e) {
353354
this.platformStates[QRCodeHandler.PLATFORM_ALI] = null;
@@ -401,7 +402,7 @@ class QRCodeHandler {
401402
async _checkUCStatus() {
402403
const state = this.platformStates[QRCodeHandler.PLATFORM_UC];
403404
if (!state) {
404-
return { status: QRCodeHandler.STATUS_EXPIRED };
405+
return {status: QRCodeHandler.STATUS_EXPIRED};
405406
}
406407

407408
try {
@@ -445,17 +446,35 @@ class QRCodeHandler {
445446
const cookieResData = cookieRes.data;
446447
const cookies = cookieResData.headers['set-cookie'];
447448
const cookies2array = this.formatCookiesToList(cookies);
448-
const mainCookies = this.formatCookie(cookies2array);
449+
let mainCookies = this.formatCookie(cookies2array);
450+
const cookieSelfRes = await axios({
451+
url: "/http",
452+
method: "POST",
453+
data: {
454+
url: "https://pc-api.uc.cn/1/clouddrive/config?pr=UCBrowser&fr=pc",
455+
headers: {
456+
...QRCodeHandler.HEADERS,
457+
Origin: 'https://drive.uc.cn',
458+
Referer: 'https://drive.uc.cn/',
459+
Cookie: mainCookies
460+
}
461+
}
462+
});
463+
const cookieResDataSelf = cookieSelfRes.data;
464+
const cookiesSelf = Array.isArray(cookieResDataSelf.headers['set-cookie']) ? cookieResDataSelf.headers['set-cookie'].join('; ') : cookieResDataSelf.headers['set-cookie'];
465+
const cookies2arraySelf = this.formatCookiesToList(cookiesSelf);
466+
const mainCookiesSelf = this.formatCookie(cookies2arraySelf);
467+
if (mainCookiesSelf) mainCookies += ';' + mainCookiesSelf;
449468
this.platformStates[QRCodeHandler.PLATFORM_UC] = null;
450469
return {
451470
status: QRCodeHandler.STATUS_CONFIRMED,
452471
cookie: mainCookies
453472
};
454473
} else if (resData.data.status === 50004002) { // token过期
455474
this.platformStates[QRCodeHandler.PLATFORM_UC] = null;
456-
return { status: QRCodeHandler.STATUS_EXPIRED };
475+
return {status: QRCodeHandler.STATUS_EXPIRED};
457476
} else {
458-
return { status: QRCodeHandler.STATUS_NEW };
477+
return {status: QRCodeHandler.STATUS_NEW};
459478
}
460479
} catch (e) {
461480
this.platformStates[QRCodeHandler.PLATFORM_UC] = null;
@@ -505,7 +524,7 @@ class QRCodeHandler {
505524
async _checkBiliStatus() {
506525
const state = this.platformStates[QRCodeHandler.PLATFORM_BILI];
507526
if (!state) {
508-
return { status: QRCodeHandler.STATUS_EXPIRED };
527+
return {status: QRCodeHandler.STATUS_EXPIRED};
509528
}
510529

511530
try {
@@ -530,9 +549,9 @@ class QRCodeHandler {
530549
}
531550

532551
if (resData.data.data.code === 86101) { // 未扫码
533-
return { status: QRCodeHandler.STATUS_NEW };
552+
return {status: QRCodeHandler.STATUS_NEW};
534553
} else if (resData.data.data.code === 86090) { // 已扫码未确认
535-
return { status: QRCodeHandler.STATUS_SCANED };
554+
return {status: QRCodeHandler.STATUS_SCANED};
536555
} else if (resData.data.data.code === 0) { // 已确认
537556
const url = resData.data.data.url;
538557
let cookie = "";
@@ -547,7 +566,7 @@ class QRCodeHandler {
547566
};
548567
} else { // 二维码过期
549568
this.platformStates[QRCodeHandler.PLATFORM_BILI] = null;
550-
return { status: QRCodeHandler.STATUS_EXPIRED };
569+
return {status: QRCodeHandler.STATUS_EXPIRED};
551570
}
552571
} catch (e) {
553572
this.platformStates[QRCodeHandler.PLATFORM_BILI] = null;

Diff for: config/env.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2-
"ali_cookie": "test",
2+
"ali_token": "",
3+
"ali_refresh_token": "",
34
"quark_cookie": "__pus=; __puus=",
4-
"uc_cookie": "test",
5+
"uc_cookie": "__pus=; __puus=",
56
"bili_cookie": "test"
67
}

Diff for: controllers/web.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default (fastify, options, done) => {
4949
let cookie_obj = COOKIE.parse(value);
5050
let cookie_str = value;
5151

52-
if (key === 'quark_cookie') {
52+
if (['quark_cookie', 'uc_cookie'].includes(key)) {
5353
// console.log(cookie_obj);
5454
cookie_str = COOKIE.stringify({
5555
__pus: cookie_obj.__pus || '',

Diff for: custom.json

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"sites_count": 28,
2+
"sites_count": 30,
33
"sites": [
44
{
55
"key": "drpyS_哔哩直播[官]",
@@ -151,6 +151,16 @@
151151
"quickSearch": 0,
152152
"ext": ""
153153
},
154+
{
155+
"key": "drpyS_闪电优汐[盘]",
156+
"name": "闪电优汐[盘](DS)",
157+
"type": 4,
158+
"api": "http://192.168.31.49:5757/api/闪电优汐[盘]",
159+
"searchable": 1,
160+
"filterable": 1,
161+
"quickSearch": 0,
162+
"ext": ""
163+
},
154164
{
155165
"key": "drpyS_素白白",
156166
"name": "素白白(DS)",
@@ -241,6 +251,16 @@
241251
"quickSearch": 0,
242252
"ext": ""
243253
},
254+
{
255+
"key": "drpyS_MP4电影[磁]",
256+
"name": "MP4电影[磁](DS)",
257+
"type": 4,
258+
"api": "http://192.168.31.49:5757/api/MP4电影[磁]",
259+
"searchable": 1,
260+
"filterable": 1,
261+
"quickSearch": 0,
262+
"ext": ""
263+
},
244264
{
245265
"key": "drpyS_OmoFun[漫]",
246266
"name": "OmoFun[漫](DS)",

Diff for: docs/updateRecord.md

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

3+
### 20241223
4+
5+
更新至V1.0.19
6+
7+
1. 更新部分源
8+
2. 更新扫码入库代码,支持UC扫码入库可播`闪电优汐[盘]`
9+
310
### 20241222
411

512
更新至V1.0.18

Diff for: index.json

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"sites_count": 28,
2+
"sites_count": 30,
33
"sites": [
44
{
55
"key": "drpyS_哔哩直播[官]",
@@ -151,6 +151,16 @@
151151
"quickSearch": 0,
152152
"ext": ""
153153
},
154+
{
155+
"key": "drpyS_闪电优汐[盘]",
156+
"name": "闪电优汐[盘](DS)",
157+
"type": 4,
158+
"api": "http://127.0.0.1:5757/api/闪电优汐[盘]",
159+
"searchable": 1,
160+
"filterable": 1,
161+
"quickSearch": 0,
162+
"ext": ""
163+
},
154164
{
155165
"key": "drpyS_素白白",
156166
"name": "素白白(DS)",
@@ -241,6 +251,16 @@
241251
"quickSearch": 0,
242252
"ext": ""
243253
},
254+
{
255+
"key": "drpyS_MP4电影[磁]",
256+
"name": "MP4电影[磁](DS)",
257+
"type": 4,
258+
"api": "http://127.0.0.1:5757/api/MP4电影[磁]",
259+
"searchable": 1,
260+
"filterable": 1,
261+
"quickSearch": 0,
262+
"ext": ""
263+
},
244264
{
245265
"key": "drpyS_OmoFun[漫]",
246266
"name": "OmoFun[漫](DS)",

0 commit comments

Comments
 (0)