Add yt
This commit is contained in:
parent
27c83e3cdd
commit
a7da636bf0
|
|
@ -31,6 +31,7 @@ public class Push extends Ali {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String playerContent(String flag, String id, List<String> vipFlags) {
|
public String playerContent(String flag, String id, List<String> vipFlags) {
|
||||||
|
if (id.contains("youtube.com")) return Result.get().url(Youtube.fetch(id)).string();
|
||||||
if (flag.equals("直連")) return Result.get().url(id).subs(getSubs(id)).string();
|
if (flag.equals("直連")) return Result.get().url(id).subs(getSubs(id)).string();
|
||||||
if (flag.equals("嗅探")) return Result.get().parse().url(id).string();
|
if (flag.equals("嗅探")) return Result.get().parse().url(id).string();
|
||||||
if (flag.equals("解析")) return Result.get().parse().jx().url(id).string();
|
if (flag.equals("解析")) return Result.get().parse().jx().url(id).string();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.github.catvod.spider;
|
||||||
|
|
||||||
|
import com.github.catvod.net.OkHttp;
|
||||||
|
import com.github.catvod.utils.Utils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class Youtube {
|
||||||
|
|
||||||
|
private static HashMap<String, String> getHeader() {
|
||||||
|
HashMap<String, String> headers = new HashMap<>();
|
||||||
|
headers.put("User-Agent", Utils.CHROME);
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String fetch(String url) {
|
||||||
|
try {
|
||||||
|
String result = OkHttp.string(url, getHeader());
|
||||||
|
Pattern pattern = Pattern.compile("hlsManifestUrl\\S*?(https\\S*?\\.m3u8)");
|
||||||
|
Matcher matcher = pattern.matcher(result);
|
||||||
|
if (!matcher.find()) return "";
|
||||||
|
String stable = matcher.group(1);
|
||||||
|
result = OkHttp.string(stable, getHeader());
|
||||||
|
String quality = find(result);
|
||||||
|
return quality.isEmpty() ? url : quality;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String find(String result) {
|
||||||
|
String url = "";
|
||||||
|
List<String> items = Arrays.asList("301", "300", "96", "95", "94");
|
||||||
|
for (String item : items) if (!(url = find(result, "https:/.*/" + item + "/.*index.m3u8")).isEmpty()) break;
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String find(String result, String rule) {
|
||||||
|
Pattern pattern = Pattern.compile(rule);
|
||||||
|
Matcher matcher = pattern.matcher(result);
|
||||||
|
if (matcher.find()) return matcher.group();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
91c9b5707a41ef60147a684a61089966
|
00a226e422e2f3710e784601354aa8c0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue