pull/142/head
FongMi 3 years ago
parent 05229922da
commit 5da9b869f3
  1. 4
      app/src/main/java/com/fongmi/android/tv/model/SiteViewModel.java
  2. 4
      catvod/src/main/java/com/github/catvod/crawler/Spider.java
  3. 10
      catvod/src/main/java/com/github/catvod/net/OkHttp.java
  4. 2
      pyramid/src/main/java/com/undcover/freedom/pyramid/Spider.java

@ -238,7 +238,7 @@ public class SiteViewModel extends ViewModel {
}
private String call(Site site, ArrayMap<String, String> params, boolean limit) throws IOException {
Call call = fetchExt(site, params, limit).length() <= 1000 ? OkHttp.newCall(site.isProxy(), site.getApi(), params, site.getHeaders()) : OkHttp.newCall(site.isProxy(), site.getApi(), OkHttp.toBody(params), site.getHeaders());
Call call = fetchExt(site, params, limit).length() <= 1000 ? OkHttp.newCall(site.isProxy(), site.getApi(), site.getHeaders(), params) : OkHttp.newCall(site.isProxy(), site.getApi(), site.getHeaders(), OkHttp.toBody(params));
return call.execute().body().string();
}
@ -264,7 +264,7 @@ public class SiteViewModel extends ViewModel {
ArrayMap<String, String> params = new ArrayMap<>();
params.put("ac", site.getType() == 0 ? "videolist" : "detail");
params.put("ids", TextUtils.join(",", ids));
String response = OkHttp.newCall(site.isProxy(), site.getApi(), params, site.getHeaders()).execute().body().string();
String response = OkHttp.newCall(site.isProxy(), site.getApi(), site.getHeaders(), params).execute().body().string();
result.setList(Result.fromType(site.getType(), response).getList());
return result;
}

@ -78,7 +78,7 @@ public abstract class Spider {
return OkHttp.dns();
}
public static OkHttpClient client(boolean proxy, boolean redirect, int timeout) {
return OkHttp.client(proxy, redirect, timeout);
public OkHttpClient client() {
return OkHttp.client(proxy);
}
}

@ -108,6 +108,10 @@ public class OkHttp {
return client.newCall(new Request.Builder().url(url).build());
}
public static Call newCall(OkHttpClient client, String url, Headers headers) {
return client.newCall(new Request.Builder().url(url).headers(headers).build());
}
public static Call newCall(String url, Headers headers) {
return newCall(true, url, headers);
}
@ -116,12 +120,12 @@ public class OkHttp {
return client(proxy).newCall(new Request.Builder().url(url).headers(headers).build());
}
public static Call newCall(boolean proxy, String url, ArrayMap<String, String> params, Headers headers) {
public static Call newCall(boolean proxy, String url, Headers headers, ArrayMap<String, String> params) {
return client(proxy).newCall(new Request.Builder().url(buildUrl(url, params)).headers(headers).build());
}
public static Call newCall(boolean proxy, String url, RequestBody body, Headers headers) {
return client(proxy).newCall(new Request.Builder().url(url).post(body).headers(headers).build());
public static Call newCall(boolean proxy, String url, Headers headers, RequestBody body) {
return client(proxy).newCall(new Request.Builder().url(url).headers(headers).post(body).build());
}
public static Call newCall(OkHttpClient client, String url, RequestBody body) {

@ -99,7 +99,7 @@ public class Spider extends com.github.catvod.crawler.Spider {
Headers header = getHeader(object.optString("header"));
ArrayMap<String, String> param = getParam(object.optString("param"));
if (object.optString("type").equals("stream")) {
return new Object[]{code, type, OkHttp.newCall(proxy(), url, param, header).execute().body().byteStream()};
return new Object[]{code, type, OkHttp.newCall(proxy(), url, header, param).execute().body().byteStream()};
} else {
if (content.isEmpty()) content = OkHttp.newCall(proxy(), url, header).execute().body().string();
return new Object[]{code, type, new ByteArrayInputStream(content.getBytes())};

Loading…
Cancel
Save