Skip to content

Commit 5510678

Browse files
author
Taois
committed
fix: 百度网盘特殊链接bug
百度网盘的分享目录如果含有#这个符号会导致t4源线路和选集的解析错乱问题。另外#直接拼接到链接里被百度视为hash值干掉了,改为对路径进行url编码再拼接链接。修复失效的百度推送示例链接。
1 parent 189db1d commit 5510678

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

spider/js/设置中心.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ let quick_data = {
6464
UC: 'https://drive.uc.cn/s/59023f57d3ce4?public=1',
6565
阿里: 'https://www.alipan.com/s/vgXMcowK8pQ',
6666
天翼: 'https://cloud.189.cn/web/share?code=INJbU3NbqyUj',
67-
百度: 'https://pan.baidu.com/s/1TdbgcwaMG1dK7B5pQ1LbBg?pwd=1234',
67+
百度: 'https://pan.baidu.com/s/1L0UIv4p0X0QrbbKErJuc_w?pwd=2pwj',
6868
移动1: 'https://yun.139.com/shareweb/#/w/i/0i5CLQ7BpV7Ai',
6969
移动2: 'https://caiyun.139.com/m/i?2jexC1gcjeN7q',
7070
移动3: 'https://yun.139.com/shareweb/#/w/i/2i2MoE9ZHn9p1',

utils/pan/baidu2.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ class BaiduDrive {
135135
}
136136
return it
137137
}).join(';')
138-
ENV.set('baidu_cookie', cookie);
138+
if (cookie !== this.cookie) {
139+
ENV.set('baidu_cookie', cookie);
140+
}
139141
return randsk
140142
}
141143
}
@@ -169,7 +171,7 @@ class BaiduDrive {
169171
const fileName = item.server_filename || item.path.split('/').pop();
170172
videos.push({
171173
name: fileName, // 只使用文件名
172-
path: item.path, // 保留完整路径用于内部处理
174+
path: item.path.replaceAll('#', '\0'), // 如果路径里含有#,替换为非法文本\0,所有系统的路径都不可能存在这个文本
173175
uk: this.uk,
174176
shareid: this.shareid,
175177
fsid: item.fs_id || item.fsid
@@ -209,7 +211,7 @@ class BaiduDrive {
209211
await this.getRandsk()
210212
this.headers['cookie'] = this.cookie
211213
// 获取指定目录下的文件列表
212-
let data = (await axios.get(`${this.api}/share/list?is_from_web=true&uk=${this.uk}&shareid=${this.shareid}&order=name&desc=0&showempty=0&view_mode=${this.view_mode}&web=1&page=1&num=100&dir=${path}&channel=${this.channel}&web=1&app_id=${this.app_id}`, {
214+
let data = (await axios.get(`${this.api}/share/list?is_from_web=true&uk=${this.uk}&shareid=${this.shareid}&order=name&desc=0&showempty=0&view_mode=${this.view_mode}&web=1&page=1&num=100&dir=${encodeURIComponent(path)}&channel=${this.channel}&web=1&app_id=${this.app_id}`, {
213215
headers: this.headers
214216
})).data
215217
if (data.errno === 0 && data.list.length > 0) {
@@ -227,7 +229,7 @@ class BaiduDrive {
227229
const fileName = item.server_filename || item.path.split('/').pop();
228230
videos.push({
229231
name: fileName, // 只使用文件名
230-
path: item.path, // 保留完整路径用于内部处理
232+
path: item.path.replaceAll('#', '\0'), // 如果路径里含有#,替换为非法文本\0,所有系统的路径都不可能存在这个文本
231233
uk: this.uk,
232234
shareid: this.shareid,
233235
fsid: item.fs_id || item.fsid
@@ -259,6 +261,8 @@ class BaiduDrive {
259261
* @returns {Promise<Array>} 不同清晰度的播放链接数组
260262
*/
261263
async getShareUrl(path, uk, shareid, fsid) {
264+
path = path.replaceAll('\0', '#'); // 把真实路径还原
265+
log('[baidu2][getShareUrl] path:', path);
262266
let sign = await this.getSign()
263267
let urls = []
264268
let t = Math.floor(new Date() / 1000); // 当前时间戳
@@ -301,6 +305,8 @@ class BaiduDrive {
301305
* @returns {Promise<string>} 直链地址
302306
*/
303307
async getAppShareUrl(path, uk, shareid, fsid) {
308+
path = path.replaceAll('\0', '#'); // 把真实路径还原
309+
log('[baidu2][getAppShareUrl] path:', path);
304310
let BDCLND = await this.getRandsk()
305311
let uid = await this.getUid()
306312
// 设置移动端请求头

0 commit comments

Comments
 (0)