proxy返回url,走go代理时避免java代理
This commit is contained in:
parent
1b31eb04e1
commit
9223474f8f
|
|
@ -475,6 +475,7 @@ public class AliYun {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] proxyVideo(Map<String, String> params) throws Exception {
|
public Object[] proxyVideo(Map<String, String> params) throws Exception {
|
||||||
|
String response = params.get("response");
|
||||||
String templateId = params.get("templateId");
|
String templateId = params.get("templateId");
|
||||||
String shareId = params.get("shareId");
|
String shareId = params.get("shareId");
|
||||||
String mediaId = params.get("mediaId");
|
String mediaId = params.get("mediaId");
|
||||||
|
|
@ -500,7 +501,7 @@ public class AliYun {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
downloadUrl = mediaUrl;
|
downloadUrl = mediaUrl;
|
||||||
}
|
}
|
||||||
|
if ("url".equals(response)) return new Object[]{200, "text/plain; charset=utf-8", new ByteArrayInputStream(downloadUrl.getBytes("UTF-8"))};
|
||||||
Map<String, String> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
Map<String, String> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||||
for (String key : params.keySet()) headers.put(key, params.get(key));
|
for (String key : params.keySet()) headers.put(key, params.get(key));
|
||||||
headers.remove("do");
|
headers.remove("do");
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,12 @@ import static fi.iki.elonen.NanoHTTPD.Response.Status;
|
||||||
import static fi.iki.elonen.NanoHTTPD.newFixedLengthResponse;
|
import static fi.iki.elonen.NanoHTTPD.newFixedLengthResponse;
|
||||||
|
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.github.catvod.net.OkHttp;
|
import com.github.catvod.net.OkHttp;
|
||||||
import com.github.catvod.spider.Proxy;
|
import com.github.catvod.spider.Proxy;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
@ -24,8 +27,21 @@ public class ProxyVideo {
|
||||||
while (OkHttp.string(GO_SERVER).isEmpty()) SystemClock.sleep(20);
|
while (OkHttp.string(GO_SERVER).isEmpty()) SystemClock.sleep(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String goVersion() {
|
||||||
|
String result = OkHttp.string(GO_SERVER + "version");
|
||||||
|
if (TextUtils.isEmpty(result)) return "";
|
||||||
|
try {
|
||||||
|
JsonObject obj = JsonParser.parseString(result).getAsJsonObject();
|
||||||
|
return obj.get("version").getAsString();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String url(String url, int thread) {
|
public static String url(String url, int thread) {
|
||||||
go();
|
go();
|
||||||
|
String version = goVersion();
|
||||||
|
if (!TextUtils.isEmpty(version) && url.contains("/proxy?")) url += "&response=url";
|
||||||
return String.format(Locale.getDefault(), "%s?url=%s&thread=%d", GO_SERVER, URLEncoder.encode(url), thread);
|
return String.format(Locale.getDefault(), "%s?url=%s&thread=%d", GO_SERVER, URLEncoder.encode(url), thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue