mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-02-04 12:26:18 +00:00
联想乐云文件夹解析
This commit is contained in:
@@ -18,7 +18,7 @@ import java.util.UUID;
|
|||||||
* <a href="https://lecloud.lenovo.com/">联想乐云</a>
|
* <a href="https://lecloud.lenovo.com/">联想乐云</a>
|
||||||
*/
|
*/
|
||||||
public class LeTool extends PanBase {
|
public class LeTool extends PanBase {
|
||||||
private static final String API_URL_PREFIX = "https://lecloud.lenovo.com/mshare/api/clouddiskapi/share/public/v1/";
|
private static final String API_URL_PREFIX = "https://lecloud.lenovo.com/share/api/clouddiskapi/share/public/v1/";
|
||||||
private static final String DEFAULT_FILE_TYPE = "file";
|
private static final String DEFAULT_FILE_TYPE = "file";
|
||||||
private static final int FILE_TYPE_DIRECTORY = 0; // 目录类型
|
private static final int FILE_TYPE_DIRECTORY = 0; // 目录类型
|
||||||
|
|
||||||
@@ -87,24 +87,13 @@ public class LeTool extends PanBase {
|
|||||||
|
|
||||||
// 如果参数里的目录ID不为空,则直接解析目录
|
// 如果参数里的目录ID不为空,则直接解析目录
|
||||||
String dirId = (String) shareLinkInfo.getOtherParam().get("dirId");
|
String dirId = (String) shareLinkInfo.getOtherParam().get("dirId");
|
||||||
if (dirId != null && !dirId.isEmpty()) {
|
if (dirId == null || dirId.isEmpty()) {
|
||||||
parseDirectory(dirId, dataKey, listPromise);
|
// 如果没有指定目录ID,使用根目录ID "-1"
|
||||||
return listPromise.future();
|
dirId = "-1";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 先解析获取根目录ID
|
// 直接请求shareInfo接口解析目录
|
||||||
parse().onSuccess(id -> {
|
parseDirectory(dirId, dataKey, listPromise);
|
||||||
if (id != null && !id.isEmpty()) {
|
|
||||||
// 解析目录
|
|
||||||
parseDirectory(id, dataKey, listPromise);
|
|
||||||
} else {
|
|
||||||
listPromise.fail("解析目录ID失败");
|
|
||||||
}
|
|
||||||
}).onFailure(failRes -> {
|
|
||||||
log.error("解析目录失败: {}", failRes.getMessage());
|
|
||||||
listPromise.fail(failRes);
|
|
||||||
});
|
|
||||||
|
|
||||||
return listPromise.future();
|
return listPromise.future();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,21 +168,12 @@ public class LeTool extends PanBase {
|
|||||||
fileInfo.setFileType("folder");
|
fileInfo.setFileType("folder");
|
||||||
fileInfo.setSize(0L);
|
fileInfo.setSize(0L);
|
||||||
fileInfo.setSizeStr("0B");
|
fileInfo.setSizeStr("0B");
|
||||||
// 设置目录解析的URL - 注意:fileId已经是URL编码的,直接使用
|
// 设置目录解析的URL - 注意:从API返回的fileId已经是URL编码的,直接使用
|
||||||
// 使用 URLEncoder 确保特殊字符被正确编码
|
// 不需要再次编码,避免双重编码导致解析失败
|
||||||
try {
|
fileInfo.setParserUrl(String.format("%s/v2/getFileList?url=%s&dirId=%s",
|
||||||
String encodedFileId = java.net.URLEncoder.encode(fileId, "UTF-8");
|
getDomainName(),
|
||||||
fileInfo.setParserUrl(String.format("%s/v2/getFileList?url=%s&dirId=%s",
|
shareLinkInfo.getShareUrl(),
|
||||||
getDomainName(),
|
fileId));
|
||||||
shareLinkInfo.getShareUrl(),
|
|
||||||
encodedFileId));
|
|
||||||
} catch (Exception e) {
|
|
||||||
// 如果编码失败,直接使用原始fileId
|
|
||||||
fileInfo.setParserUrl(String.format("%s/v2/getFileList?url=%s&dirId=%s",
|
|
||||||
getDomainName(),
|
|
||||||
shareLinkInfo.getShareUrl(),
|
|
||||||
fileId));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// 文件类型
|
// 文件类型
|
||||||
fileInfo.setFileType(fileType != null ? String.valueOf(fileType) : DEFAULT_FILE_TYPE);
|
fileInfo.setFileType(fileType != null ? String.valueOf(fileType) : DEFAULT_FILE_TYPE);
|
||||||
@@ -211,7 +191,11 @@ public class LeTool extends PanBase {
|
|||||||
fileInfo.setParserUrl(String.format("%s/v2/redirectUrl/%s/%s",
|
fileInfo.setParserUrl(String.format("%s/v2/redirectUrl/%s/%s",
|
||||||
getDomainName(),
|
getDomainName(),
|
||||||
shareLinkInfo.getType(),
|
shareLinkInfo.getType(),
|
||||||
paramBase64));
|
paramBase64))
|
||||||
|
.setPreviewUrl(String.format("%s/v2/viewUrl/%s/%s",
|
||||||
|
getDomainName(),
|
||||||
|
shareLinkInfo.getType(),
|
||||||
|
paramBase64));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user