mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2025-12-16 12:23:03 +00:00
@@ -72,6 +72,9 @@ public class FileInfo {
|
||||
//预览地址
|
||||
private String previewUrl;
|
||||
|
||||
// 文件hash默认类型为md5
|
||||
private String hash;
|
||||
|
||||
/**
|
||||
* 扩展参数
|
||||
*/
|
||||
@@ -210,6 +213,15 @@ public class FileInfo {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getHash() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
public FileInfo setHash(String hash) {
|
||||
this.hash = hash;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Map<String, Object> getExtParameters() {
|
||||
return extParameters;
|
||||
}
|
||||
|
||||
@@ -225,7 +225,6 @@ public class LzTool extends PanBase {
|
||||
.setParserUrl(getDomainName() + "/d/" + panType + "/" + id)
|
||||
.setPreviewUrl(String.format("%s/v2/view/%s/%s", getDomainName(),
|
||||
shareLinkInfo.getType(), id));
|
||||
;
|
||||
log.debug("文件信息: {}", fileInfo);
|
||||
list.add(fileInfo);
|
||||
});
|
||||
|
||||
@@ -4,10 +4,13 @@ import cn.qaiu.WebClientVertxInit;
|
||||
import cn.qaiu.entity.FileInfo;
|
||||
import cn.qaiu.entity.ShareLinkInfo;
|
||||
import cn.qaiu.parser.PanBase;
|
||||
import cn.qaiu.util.FileSizeConverter;
|
||||
import cn.qaiu.util.HeaderUtils;
|
||||
import io.vertx.core.Future;
|
||||
import io.vertx.core.MultiMap;
|
||||
import io.vertx.core.Promise;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.core.json.pointer.JsonPointer;
|
||||
import io.vertx.ext.web.client.WebClient;
|
||||
import io.vertx.uritemplate.UriTemplate;
|
||||
|
||||
@@ -75,7 +78,18 @@ public class PvyyTool extends PanBase {
|
||||
.putHeaders(header)
|
||||
.send().onSuccess(res -> {
|
||||
try {
|
||||
String id = asJson(res).getJsonObject("data").getJsonObject("data").getString("id");
|
||||
JsonObject resJson = asJson(res);
|
||||
if (!resJson.containsKey("code") || resJson.getInteger("code") != 0) {
|
||||
fail("获取文件信息失败: " + resJson.getString("message"));
|
||||
return;
|
||||
}
|
||||
JsonObject fileData = resJson.getJsonObject("data").getJsonObject("data");
|
||||
if (fileData == null) {
|
||||
fail("文件数据为空");
|
||||
return;
|
||||
}
|
||||
setFileInfo(fileData);
|
||||
String id = fileData.getString("id");
|
||||
|
||||
client.getAbs(UriTemplate.of(apiUrl))
|
||||
.setTemplateParam("key", shareLinkInfo.getShareKey())
|
||||
@@ -97,6 +111,23 @@ public class PvyyTool extends PanBase {
|
||||
});
|
||||
}
|
||||
|
||||
private void setFileInfo(JsonObject fileData) {
|
||||
JsonObject attributes = fileData.getJsonObject("attributes");
|
||||
JsonObject user = (JsonObject)(JsonPointer.from("/relationships/user/data").queryJson(fileData));
|
||||
int downCount = (Integer)(JsonPointer.from("/relationships/shared/data/attributes/down").queryJson(fileData));
|
||||
String filesize = attributes.getString("filesize");
|
||||
FileInfo fileInfo = new FileInfo()
|
||||
.setFileId(fileData.getString("id"))
|
||||
.setFileName(attributes.getString("basename"))
|
||||
.setFileType(attributes.getString("mimetype"))
|
||||
.setPanType(shareLinkInfo.getType())
|
||||
.setCreateBy(user.getString("email"))
|
||||
.setDownloadCount(downCount)
|
||||
.setSize(FileSizeConverter.convertToBytes(filesize))
|
||||
.setSizeStr(filesize);
|
||||
shareLinkInfo.getOtherParam().put("fileInfo", fileInfo);
|
||||
}
|
||||
|
||||
private static final String DIR_API = "https://www.vyuyun.com/apiv1/share/folders/809Pt6/bMjnUg?sort=created_at&direction=DESC&password={pwd}";
|
||||
private static final String SHARE_TYPE_API = "https://www.vyuyun.com/apiv1/share/info/{key}?password={pwd}";
|
||||
//
|
||||
|
||||
@@ -7,8 +7,17 @@ public class FileSizeConverter {
|
||||
throw new IllegalArgumentException("Invalid file size string");
|
||||
}
|
||||
|
||||
sizeStr = sizeStr.trim().toUpperCase();
|
||||
char unit = sizeStr.charAt(sizeStr.length() - 1);
|
||||
sizeStr = sizeStr.replace(",","").trim().toUpperCase();
|
||||
// 判断是2位单位还是1位单位
|
||||
// 判断单位是否为2位
|
||||
int unitIndex = sizeStr.length() - 1;
|
||||
char unit = sizeStr.charAt(unitIndex);
|
||||
if (Character.isLetter(sizeStr.charAt(unitIndex - 1))) {
|
||||
unit = sizeStr.charAt(unitIndex - 1);
|
||||
sizeStr = sizeStr.substring(0, unitIndex - 1);
|
||||
} else {
|
||||
sizeStr = sizeStr.substring(0, unitIndex);
|
||||
}
|
||||
double size = Double.parseDouble(sizeStr.substring(0, sizeStr.length() - 1));
|
||||
|
||||
return switch (unit) {
|
||||
|
||||
Reference in New Issue
Block a user