update: 获取下载状态
This commit is contained in:
@@ -2,6 +2,7 @@ package cn.montaro.aria2;
|
||||
|
||||
import cn.montaro.aria2.annotation.Aria2Method;
|
||||
import cn.montaro.aria2.constants.Aria2MethodName;
|
||||
import cn.montaro.aria2.resp.Aria2Status;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -64,7 +65,7 @@ public interface Aria2Client {
|
||||
|
||||
// TODO: define return type
|
||||
@Aria2Method(Aria2MethodName.TELL_STATUS)
|
||||
String tellStatus(String gid, String... keys);
|
||||
Aria2Status tellStatus(String gid, String... keys);
|
||||
|
||||
@Aria2Method(Aria2MethodName.GET_URIS)
|
||||
String getUris(String gid);
|
||||
|
||||
@@ -80,9 +80,12 @@ public class Aria2HttpProxy implements InvocationHandler {
|
||||
|
||||
private Object deserialize(String json, Type resultType) {
|
||||
JsonObject jsonObject = JsonParser.parseString(json).getAsJsonObject();
|
||||
String result = jsonObject.get("result").getAsString();
|
||||
JsonElement result = jsonObject.get("result");
|
||||
if (result instanceof JsonObject && resultType.equals(String.class)) {
|
||||
return result.toString();
|
||||
}
|
||||
if (resultType.equals(String.class)) {
|
||||
return result;
|
||||
return result.getAsString();
|
||||
}
|
||||
return gson.fromJson(result, resultType);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.montaro.aria2.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
*
|
||||
* @author ZhangJiaYu
|
||||
* @date 2022/9/16
|
||||
*/
|
||||
@Data
|
||||
public class Aria2File {
|
||||
private Long completedLength;
|
||||
private Integer index;
|
||||
private Long length;
|
||||
private String path;
|
||||
private Boolean selected;
|
||||
private List<String> uris;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package cn.montaro.aria2.resp;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
*
|
||||
* @author ZhangJiaYu
|
||||
* @date 2022/9/16
|
||||
*/
|
||||
@Data
|
||||
public class Aria2Status {
|
||||
private String bitfield;
|
||||
private Bittorrent bittorrent;
|
||||
private Long completedLength;
|
||||
private Integer connections;
|
||||
private String dir;
|
||||
private Long downloadSpeed;
|
||||
private Integer errorCode;
|
||||
private String errorMessage;
|
||||
private List<Aria2File> files;
|
||||
private String following;
|
||||
private List<String> followedBy;
|
||||
private String gid;
|
||||
private String infoHash;
|
||||
private Integer numPieces;
|
||||
private Integer numSeeders;
|
||||
private Long pieceLength;
|
||||
private Boolean seeder;
|
||||
private String status;
|
||||
private Long totalLength;
|
||||
private Long uploadLength;
|
||||
private Long uploadSpeed;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.montaro.aria2.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
*
|
||||
* @author ZhangJiaYu
|
||||
* @date 2022/9/16
|
||||
*/
|
||||
@Data
|
||||
public class Bittorrent {
|
||||
private List<List<String>> announceList;
|
||||
}
|
||||
Reference in New Issue
Block a user