Skip to content

Commit 31b7c1e

Browse files
author
王俊杰
committed
update
1 parent 31ef372 commit 31b7c1e

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/main/java/com/baidu/disk/requester/LinkHelper.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public String verify(String shareId, String uk, String pwd, String codeStr, Stri
136136
}
137137

138138
@SuppressWarnings({"unchecked", "rawtypes"})
139-
public DownloadUrl getDLink(String fsId, String shareId, String uk, String pwd, String dir, boolean root, String codeStr, String code) throws IOException {
139+
public DownloadUrl getDLink(String shareId, String uk, String pwd, String path, boolean root, String codeStr, String code) throws IOException {
140140
String randsk = verify(shareId, uk, pwd, codeStr, code);
141141

142142
if (randsk == null) {
@@ -195,15 +195,17 @@ public DownloadUrl getDLink(String fsId, String shareId, String uk, String pwd,
195195

196196
Map resp = objectMapper.readValue(Objects.requireNonNull(client.newCall(request).execute().body()).string(), Map.class);
197197
if (!root) {
198-
dir = dir.substring(1);
199-
dir = dir.substring(dir.indexOf("/"));
198+
path = path.substring(1);
199+
path = path.substring(path.indexOf("/"));
200200

201201
String title = resp.get("title").toString();
202202
title = title.substring(1);
203203
title = title.substring(0, title.indexOf("/"));
204-
dir = "/" + title + dir;
204+
path = "/" + title + path;
205205

206-
log.info("Dir {},", dir);
206+
String dir = path.substring(0, path.lastIndexOf("/"));
207+
208+
log.info("Dir {},", path);
207209

208210
url = Objects.requireNonNull(HttpUrl.parse("https://pan.baidu.com/share/list?shareid=" + shareId)).newBuilder()
209211
.addQueryParameter("uk", uk)
@@ -240,7 +242,7 @@ public DownloadUrl getDLink(String fsId, String shareId, String uk, String pwd,
240242
String realDlink = null;
241243
log.info("Resp {}", resp);
242244
for (Map<String, Object> dlink : dlinks) {
243-
if (fsId.equalsIgnoreCase(dlink.get("fs_id").toString())) {
245+
if (path.equalsIgnoreCase(dlink.get("path").toString())) {
244246
realDlink = dlink.get("dlink").toString();
245247
}
246248
}

src/main/java/com/baidu/disk/web/BaiduYunDiskResource.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,18 @@ public class BaiduYunDiskResource {
2222
private final LinkHelper helper;
2323

2424
@GetMapping("/api/download/link")
25-
public BaseResponse<?> getDownloadLink(@RequestParam("fsId") String fsId,
26-
@RequestParam("shareId") String shareId,
25+
public BaseResponse<?> getDownloadLink(@RequestParam("shareId") String shareId,
2726
@RequestParam("uk") String uk,
2827
@RequestParam("pwd") String pwd,
29-
@RequestParam("dir") String dir,
28+
@RequestParam("path") String path,
3029
@RequestParam(value = "codeStr", required = false) String codeStr,
3130
@RequestParam(value = "code", required = false) String code) {
3231
try {
3332
boolean root = false;
34-
if (dir.split("/").length < 3) {
33+
if (path.split("/").length < 4) {
3534
root = true;
3635
}
37-
DownloadUrl downloadUrl = helper.getDLink(fsId, shareId, uk, pwd, dir, root, codeStr, code);
36+
DownloadUrl downloadUrl = helper.getDLink(shareId, uk, pwd, path, root, codeStr, code);
3837
if (downloadUrl.getCodeStr() == null) {
3938
return BaseResponse.success(downloadUrl);
4039
} else {

0 commit comments

Comments
 (0)