add - 自定义视频路径 https://dyxs13.com/paly-215645-9-1/
This commit is contained in:
@@ -7,7 +7,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.github.catvod.utils.okhttp.OkHttpUtil;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
@@ -20,12 +20,11 @@ public class SpiderReq {
|
||||
private static final String defaultTag = "sp_req_default";
|
||||
|
||||
private static OkHttpClient defaultClient = initDefaultClient();
|
||||
private static final int DEFAULT_TIMEOUT = 35;
|
||||
private static OkHttpClient initDefaultClient() {
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
builder.readTimeout(DEFAULT_TIMEOUT, TimeUnit.SECONDS);
|
||||
builder.writeTimeout(DEFAULT_TIMEOUT, TimeUnit.SECONDS);
|
||||
builder.connectTimeout(DEFAULT_TIMEOUT, TimeUnit.SECONDS);
|
||||
builder.readTimeout(OkHttpUtil.DEFAULT_TIMEOUT, TimeUnit.SECONDS);
|
||||
builder.writeTimeout(OkHttpUtil.DEFAULT_TIMEOUT, TimeUnit.SECONDS);
|
||||
builder.connectTimeout(OkHttpUtil.DEFAULT_TIMEOUT, TimeUnit.SECONDS);
|
||||
builder.retryOnConnectionFailure(true);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@@ -617,17 +617,18 @@ public class PushAgent extends Spider {
|
||||
return getAliContent(list);
|
||||
} else if (url.startsWith("http") && (!matcher.find()) && (!matcher2.find())) {
|
||||
JSONObject vodAtom = new JSONObject();
|
||||
Document doc = Jsoup.parse(OkHttpUtil.string(url, null));
|
||||
Document doc = Jsoup.parse(OkHttpUtil.string(url, Misc.Headers(0,url)));
|
||||
doc.select("div.playon").remove();
|
||||
String baseUrl = url.replaceAll("(^https?://.*?)(:\\d+)?/.*$", "$1");//https://www.dyk9.com
|
||||
String content = doc.body().html();//[\u4e00-\u9fa5]+
|
||||
String VodName = doc.select("head > title").text();
|
||||
Pattern urlder = Pattern.compile(".*-\\d+.html");
|
||||
Pattern urlder2 = Pattern.compile(".*-\\d+-\\d+");
|
||||
String uri=null,a=null,b=null,text=null,prefxs=null;
|
||||
if(urlder.matcher(url).find()){//集合多个视频
|
||||
String baseUrl = url.replaceAll("(^https?://.*?)(:\\d+)?/.*$", "$1");//https://www.dyk9.com
|
||||
String prefxUrl = url.replaceAll("(.*)-\\d+.html", "$1");
|
||||
prefxUrl = prefxUrl.replace(baseUrl, "");// /vod/play/70631-1
|
||||
String uri=null,a=null,b=null,text=null;
|
||||
String prefxs= url.replaceAll("(.*)-\\d+-\\d+.html", "$1");
|
||||
prefxs= url.replaceAll("(.*)-\\d+-\\d+.html", "$1");
|
||||
prefxs = prefxs.replace(baseUrl, "");// /vod/play/70631
|
||||
ArrayList<String> playList = new ArrayList<>();
|
||||
|
||||
@@ -670,7 +671,40 @@ public class PushAgent extends Spider {
|
||||
String vod_play_url = TextUtils.join("$$$", playList);
|
||||
vodAtom.put("vod_play_from", vod_play_from);
|
||||
vodAtom.put("vod_play_url", vod_play_url);
|
||||
}else {
|
||||
}else if(urlder2.matcher(url).find()){//https://dyxs13.com/paly-215645-9-1/
|
||||
Map<String, String> m = new LinkedHashMap<>();
|
||||
String s = "";
|
||||
if(url.endsWith("/")) s = "/";
|
||||
prefxs= url.replaceAll(baseUrl+"(.*)-\\d+"+s, "$1");
|
||||
Matcher mat = Pattern.compile("href=\"("+prefxs+"-\\d+"+s+").*?/a>").matcher(content);
|
||||
while (mat.find()){
|
||||
uri = mat.group(1);
|
||||
a = "<"+mat.group(0);
|
||||
text=a.replaceAll("<[^>]+>",""); //过滤html标签
|
||||
text = text.replaceAll("&| ", "");
|
||||
if(text.equals(""))text="其他";
|
||||
uri=baseUrl + uri;
|
||||
if(m.containsKey(uri)) m.remove(uri);
|
||||
m.put(uri, text);
|
||||
}
|
||||
if(m.containsKey(url)) {
|
||||
if(VodName.equals("")){
|
||||
b = a.replaceAll(".*title=\"(.*)\".*","$1");
|
||||
if (!b.startsWith("<")) {
|
||||
b = b.replace("播放", "");
|
||||
VodName = b;
|
||||
} else VodName = m.get(url);
|
||||
}
|
||||
}
|
||||
vodItems = new ArrayList<>();
|
||||
for (String key : m.keySet()) {
|
||||
vodItems.add(m.get(key) + "$" + key);
|
||||
}
|
||||
|
||||
String playList = TextUtils.join("#", vodItems);
|
||||
vodAtom.put("vod_play_from", "嗅探列表");
|
||||
vodAtom.put("vod_play_url", playList);
|
||||
} else{
|
||||
vodAtom.put("vod_play_from", "嗅探");
|
||||
vodAtom.put("vod_play_url", "立即播放嗅探$" + url);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.github.catvod.utils;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import com.github.catvod.crawler.SpiderDebug;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import java.util.HashMap;
|
||||
@@ -42,7 +40,6 @@ public class Misc {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isNumeric(String str){
|
||||
Pattern pattern = Pattern.compile("[0-9]*");
|
||||
return pattern.matcher(str).matches();
|
||||
@@ -194,7 +191,6 @@ public class Misc {
|
||||
return taskResult;
|
||||
}
|
||||
|
||||
|
||||
public static Charset CharsetUTF8 = Charset.forName("UTF-8");
|
||||
public static Charset CharsetIOS8859 = Charset.forName("iso-8859-1");
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.github.catvod.utils;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.github.catvod.utils.okhttp.OkHttpUtil;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
public class SpiderOKClient {
|
||||
@@ -12,9 +12,9 @@ public class SpiderOKClient {
|
||||
public static OkHttpClient noRedirectClient() {
|
||||
if (noRedirectClient == null) {
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder()
|
||||
.readTimeout(15, TimeUnit.SECONDS)
|
||||
.writeTimeout(15, TimeUnit.SECONDS)
|
||||
.connectTimeout(15, TimeUnit.SECONDS)
|
||||
.readTimeout(OkHttpUtil.DEFAULT_TIMEOUT, TimeUnit.SECONDS)
|
||||
.writeTimeout(OkHttpUtil.DEFAULT_TIMEOUT, TimeUnit.SECONDS)
|
||||
.connectTimeout(OkHttpUtil.DEFAULT_TIMEOUT, TimeUnit.SECONDS)
|
||||
.followRedirects(false)
|
||||
.followSslRedirects(false)
|
||||
.retryOnConnectionFailure(true)
|
||||
|
||||
@@ -16,7 +16,7 @@ public class OkHttpUtil {
|
||||
public static final String METHOD_GET = "GET";
|
||||
public static final String METHOD_POST = "POST";
|
||||
|
||||
private static final int DEFAULT_TIMEOUT = 35;
|
||||
private static final int DEFAULT_TIMEOUT = 25;
|
||||
|
||||
private static final Object lockO = new Object();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user