diff --git a/parser/src/main/java/cn/qaiu/parser/PanDomainTemplate.java b/parser/src/main/java/cn/qaiu/parser/PanDomainTemplate.java index 5800f55..7d0e036 100644 --- a/parser/src/main/java/cn/qaiu/parser/PanDomainTemplate.java +++ b/parser/src/main/java/cn/qaiu/parser/PanDomainTemplate.java @@ -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/(?[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!(?.+)"), + "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!(?.+)") + .matcher("https://1drv.ms/u/s!Alg0feQmCv2rpFvu444hg5yVqDcK?e=OggA4s"); + if (matcher.find()) { + System.out.println(matcher.group()); + } // 校验重复 Set collect = Arrays.stream(PanDomainTemplate.values()).map(PanDomainTemplate::getRegex).collect(Collectors.toSet()); @@ -220,8 +233,8 @@ public enum PanDomainTemplate { if (collect2.size()onedrive分享(od) + */ +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=(?)!(?)&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("=(?.+)!(?.+)&authkey=(?.+)&e=(?.+)"); + + public PodTool(ShareLinkInfo shareLinkInfo) { + super(shareLinkInfo); + } + + public Future 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")); +// } + +// } +} diff --git a/web-front/public/index.html b/web-front/public/index.html index 57a2339..e5d2978 100644 --- a/web-front/public/index.html +++ b/web-front/public/index.html @@ -9,6 +9,10 @@ content="Netdisk fast download,网盘直链解析工具"> + + +