mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2025-12-17 04:43:02 +00:00
add onedrive
This commit is contained in:
@@ -4,6 +4,7 @@ import cn.qaiu.parser.impl.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -93,6 +94,12 @@ public enum PanDomainTemplate {
|
||||
compile("https://www\\.vyuyun\\.com/s/(?<KEY>[a-zA-Z0-9-]+)(\\?password=.*)?"),
|
||||
"https://www.vyuyun.com/s/{shareKey}",
|
||||
PvyyTool.class),
|
||||
// https://1drv.ms/w/s!Alg0feQmCv2rnRFd60DQOmMa-Oh_?e=buaRtp
|
||||
//
|
||||
POD("OneCloud",
|
||||
compile("https://1drv\\.ms/[uw]/s!(?<KEY>.+)"),
|
||||
"https://1drv.ms/w/s!{shareKey}",
|
||||
PodTool.class),
|
||||
|
||||
// =====================音乐类解析 分享链接标志->MxxS (单歌曲/普通音质)==========================
|
||||
// http://163cn.tv/xxx
|
||||
@@ -209,6 +216,12 @@ public enum PanDomainTemplate {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Matcher matcher = compile("https://1drv\\.ms/[uw]/s!(?<KEY>.+)")
|
||||
.matcher("https://1drv.ms/u/s!Alg0feQmCv2rpFvu444hg5yVqDcK?e=OggA4s");
|
||||
if (matcher.find()) {
|
||||
System.out.println(matcher.group());
|
||||
}
|
||||
// 校验重复
|
||||
Set<String> collect =
|
||||
Arrays.stream(PanDomainTemplate.values()).map(PanDomainTemplate::getRegex).collect(Collectors.toSet());
|
||||
@@ -220,8 +233,8 @@ public enum PanDomainTemplate {
|
||||
if (collect2.size()<PanDomainTemplate.values().length) {
|
||||
System.out.println("有重复枚举标准链接");
|
||||
}
|
||||
System.out.println(collect);
|
||||
System.out.println(collect2);
|
||||
// System.out.println(collect);
|
||||
// System.out.println(collect2);
|
||||
|
||||
|
||||
}
|
||||
|
||||
66
parser/src/main/java/cn/qaiu/parser/impl/PodTool.java
Normal file
66
parser/src/main/java/cn/qaiu/parser/impl/PodTool.java
Normal file
@@ -0,0 +1,66 @@
|
||||
package cn.qaiu.parser.impl;
|
||||
|
||||
import cn.qaiu.entity.ShareLinkInfo;
|
||||
import cn.qaiu.parser.PanBase;
|
||||
import io.vertx.core.Future;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.uritemplate.UriTemplate;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* <a href="https://onedrive.live.com/">onedrive分享(od)</a>
|
||||
*/
|
||||
public class PodTool extends PanBase {
|
||||
|
||||
/*
|
||||
* https://1drv.ms/w/s!Alg0feQmCv2rnRFd60DQOmMa-Oh_?e=buaRtp --302->
|
||||
* https://api.onedrive.com/v1.0/drives/abfd0a26e47d3458/items/ABFD0A26E47D3458!3729?authkey=!AF3rQNA6Yxr46H8
|
||||
* https://onedrive.live.com/redir?resid=(?<cid>)!(?<cid2>)&authkey=(?<authkey>)&e=hV98W1
|
||||
* cid: abfd0a26e47d3458, cid2: ABFD0A26E47D3458!3729 authkey: !AF3rQNA6Yxr46H8
|
||||
* -> @content.downloadUrl
|
||||
*/
|
||||
|
||||
private static final String api = "https://api.onedrive.com/v1.0/drives/{cid}/items/{cid20}?authkey={authkey}";
|
||||
private static final Pattern redirectUrlRegex =
|
||||
Pattern.compile("=(?<cid>.+)!(?<cid2>.+)&authkey=(?<authkey>.+)&e=(?<e>.+)");
|
||||
|
||||
public PodTool(ShareLinkInfo shareLinkInfo) {
|
||||
super(shareLinkInfo);
|
||||
}
|
||||
|
||||
public Future<String> parse() {
|
||||
clientNoRedirects.getAbs(shareLinkInfo.getShareUrl()).send().onSuccess(r0 -> {
|
||||
String location = r0.getHeader("Location");
|
||||
Matcher matcher = redirectUrlRegex.matcher(location);
|
||||
if (matcher.find()) {
|
||||
var cid= matcher.group("cid");
|
||||
var cid2= matcher.group("cid2");
|
||||
var authkey= matcher.group("authkey");
|
||||
client.getAbs(UriTemplate.of(api))
|
||||
.setTemplateParam("cid", cid)
|
||||
.setTemplateParam("cid20", cid + "!" + cid2)
|
||||
.setTemplateParam("authkey", authkey).send()
|
||||
.onSuccess(res -> {
|
||||
JsonObject jsonObject = asJson(res);
|
||||
// System.out.println(jsonObject);
|
||||
complete(jsonObject.getString("@content.downloadUrl"));
|
||||
})
|
||||
.onFailure(handleFail());
|
||||
}
|
||||
}).onFailure(handleFail());
|
||||
|
||||
return promise.future();
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// Matcher matcher = redirectUrlRegex.matcher("https://onedrive.live.com/redir?resid=ABFD0A26E47D3458!4698" +
|
||||
// "&authkey=!ACpvXghP5xhG_cg&e=hV98W1");
|
||||
// if (matcher.find()) {
|
||||
// System.out.println(matcher.group("cid"));
|
||||
// System.out.println(matcher.group("cid2"));
|
||||
// System.out.println(matcher.group("authkey"));
|
||||
// }
|
||||
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user