Fix dm84
This commit is contained in:
parent
334ab4c1bc
commit
598982bf5b
|
|
@ -2,6 +2,7 @@ package com.github.catvod.net;
|
||||||
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.github.catvod.crawler.SpiderDebug;
|
||||||
import com.github.catvod.utils.Utils;
|
import com.github.catvod.utils.Utils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -76,8 +77,12 @@ class OkRequest {
|
||||||
Response response = client.newCall(request).execute();
|
Response response = client.newCall(request).execute();
|
||||||
if (respHeader != null) respHeader.clear();
|
if (respHeader != null) respHeader.clear();
|
||||||
if (respHeader != null) respHeader.putAll(response.headers().toMultimap());
|
if (respHeader != null) respHeader.putAll(response.headers().toMultimap());
|
||||||
return new OkResult(response.code(), response.body().string());
|
int code = response.code();
|
||||||
|
String body = response.body().string();
|
||||||
|
SpiderDebug.log(code + "," + body);
|
||||||
|
return new OkResult(code, body);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
SpiderDebug.log(e);
|
||||||
return new OkResult();
|
return new OkResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import com.github.catvod.bean.Filter;
|
||||||
import com.github.catvod.bean.Result;
|
import com.github.catvod.bean.Result;
|
||||||
import com.github.catvod.bean.Vod;
|
import com.github.catvod.bean.Vod;
|
||||||
import com.github.catvod.crawler.Spider;
|
import com.github.catvod.crawler.Spider;
|
||||||
import com.github.catvod.net.Cronet;
|
import com.github.catvod.net.OkHttp;
|
||||||
import com.github.catvod.utils.Utils;
|
import com.github.catvod.utils.Utils;
|
||||||
|
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
|
|
@ -32,6 +32,7 @@ public class Dm84 extends Spider {
|
||||||
private HashMap<String, String> getHeaders() {
|
private HashMap<String, String> getHeaders() {
|
||||||
HashMap<String, String> headers = new HashMap<>();
|
HashMap<String, String> headers = new HashMap<>();
|
||||||
headers.put("User-Agent", Utils.CHROME);
|
headers.put("User-Agent", Utils.CHROME);
|
||||||
|
headers.put("Accept", Utils.ACCEPT);
|
||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,7 +56,7 @@ public class Dm84 extends Spider {
|
||||||
List<Vod> list = new ArrayList<>();
|
List<Vod> list = new ArrayList<>();
|
||||||
List<Class> classes = new ArrayList<>();
|
List<Class> classes = new ArrayList<>();
|
||||||
LinkedHashMap<String, List<Filter>> filters = new LinkedHashMap<>();
|
LinkedHashMap<String, List<Filter>> filters = new LinkedHashMap<>();
|
||||||
Document doc = Jsoup.parse(Cronet.string(siteUrl, getHeaders()));
|
Document doc = Jsoup.parse(OkHttp.string(siteUrl, getHeaders()));
|
||||||
for (Element element : doc.select("ul.nav_row > li > a")) {
|
for (Element element : doc.select("ul.nav_row > li > a")) {
|
||||||
if (element.attr("href").startsWith("/list")) {
|
if (element.attr("href").startsWith("/list")) {
|
||||||
String id = element.attr("href").split("-")[1].substring(0, 1);
|
String id = element.attr("href").split("-")[1].substring(0, 1);
|
||||||
|
|
@ -64,7 +65,7 @@ public class Dm84 extends Spider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Class item : classes) {
|
for (Class item : classes) {
|
||||||
doc = Jsoup.parse(Cronet.string(siteUrl + "/list-" + item.getTypeId() + ".html", getHeaders()));
|
doc = Jsoup.parse(OkHttp.string(siteUrl + "/list-" + item.getTypeId() + ".html", getHeaders()));
|
||||||
Elements elements = doc.select("ul.list_filter > li > div");
|
Elements elements = doc.select("ul.list_filter > li > div");
|
||||||
List<Filter> array = new ArrayList<>();
|
List<Filter> array = new ArrayList<>();
|
||||||
array.add(getFilter("類型", "type", elements.get(0).select("a").eachText()));
|
array.add(getFilter("類型", "type", elements.get(0).select("a").eachText()));
|
||||||
|
|
@ -93,7 +94,7 @@ public class Dm84 extends Spider {
|
||||||
String type = URLEncoder.encode(extend.get("type"));
|
String type = URLEncoder.encode(extend.get("type"));
|
||||||
String year = extend.get("year");
|
String year = extend.get("year");
|
||||||
String target = siteUrl + String.format("/show-%s--%s-%s--%s-%s.html", tid, by, type, year, pg);
|
String target = siteUrl + String.format("/show-%s--%s-%s--%s-%s.html", tid, by, type, year, pg);
|
||||||
Document doc = Jsoup.parse(Cronet.string(target, getHeaders()));
|
Document doc = Jsoup.parse(OkHttp.string(target, getHeaders()));
|
||||||
for (Element element : doc.select("div.item")) {
|
for (Element element : doc.select("div.item")) {
|
||||||
String img = element.select("a.cover").attr("data-bg");
|
String img = element.select("a.cover").attr("data-bg");
|
||||||
String url = element.select("a.title").attr("href");
|
String url = element.select("a.title").attr("href");
|
||||||
|
|
@ -107,7 +108,7 @@ public class Dm84 extends Spider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String detailContent(List<String> ids) {
|
public String detailContent(List<String> ids) {
|
||||||
Document doc = Jsoup.parse(Cronet.string(siteUrl.concat("/v/").concat(ids.get(0)), getHeaders()));
|
Document doc = Jsoup.parse(OkHttp.string(siteUrl.concat("/v/").concat(ids.get(0)), getHeaders()));
|
||||||
String name = doc.select("h1.v_title").text();
|
String name = doc.select("h1.v_title").text();
|
||||||
String remarks = doc.select("p.v_desc > span.desc").text();
|
String remarks = doc.select("p.v_desc > span.desc").text();
|
||||||
String img = doc.select("meta[property=og:image]").attr("content");
|
String img = doc.select("meta[property=og:image]").attr("content");
|
||||||
|
|
@ -157,7 +158,7 @@ public class Dm84 extends Spider {
|
||||||
public String searchContent(String key, boolean quick) {
|
public String searchContent(String key, boolean quick) {
|
||||||
List<Vod> list = new ArrayList<>();
|
List<Vod> list = new ArrayList<>();
|
||||||
String target = siteUrl.concat("/s----------.html?wd=").concat(key);
|
String target = siteUrl.concat("/s----------.html?wd=").concat(key);
|
||||||
Document doc = Jsoup.parse(Cronet.string(target, getHeaders()));
|
Document doc = Jsoup.parse(OkHttp.string(target, getHeaders()));
|
||||||
for (Element element : doc.select("div.item")) {
|
for (Element element : doc.select("div.item")) {
|
||||||
String img = element.select("a.cover").attr("data-bg");
|
String img = element.select("a.cover").attr("data-bg");
|
||||||
String url = element.select("a.title").attr("href");
|
String url = element.select("a.title").attr("href");
|
||||||
|
|
@ -171,7 +172,7 @@ public class Dm84 extends Spider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String playerContent(String flag, String id, List<String> vipFlags) {
|
public String playerContent(String flag, String id, List<String> vipFlags) {
|
||||||
Document doc = Jsoup.parse(Cronet.string(siteUrl.concat(id), getHeaders()));
|
Document doc = Jsoup.parse(OkHttp.string(siteUrl.concat(id), getHeaders()));
|
||||||
String url = doc.select("iframe").attr("src");
|
String url = doc.select("iframe").attr("src");
|
||||||
return Result.get().url(url).parse().header(getHeaders()).string();
|
return Result.get().url(url).parse().header(getHeaders()).string();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
public static final String CHROME = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36";
|
public static final String CHROME = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36";
|
||||||
|
public static final String ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7";
|
||||||
public static final List<String> MEDIA = Arrays.asList("mp4", "mkv", "wmv", "flv", "avi", "mp3", "aac", "flac", "m4a", "ape", "ogg");
|
public static final List<String> MEDIA = Arrays.asList("mp4", "mkv", "wmv", "flv", "avi", "mp3", "aac", "flac", "m4a", "ape", "ogg");
|
||||||
public static final Pattern RULE = Pattern.compile(
|
public static final Pattern RULE = Pattern.compile(
|
||||||
"http((?!http).){12,}?\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg|m4a|mp3)\\?.*|" +
|
"http((?!http).){12,}?\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg|m4a|mp3)\\?.*|" +
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue