|
|
|
|
@ -3,7 +3,10 @@ package com.github.catvod.utils; |
|
|
|
|
import static fi.iki.elonen.NanoHTTPD.Response.Status; |
|
|
|
|
import static fi.iki.elonen.NanoHTTPD.newFixedLengthResponse; |
|
|
|
|
|
|
|
|
|
import android.os.SystemClock; |
|
|
|
|
|
|
|
|
|
import com.github.catvod.net.OkHttp; |
|
|
|
|
import com.github.catvod.spider.Proxy; |
|
|
|
|
|
|
|
|
|
import java.net.URLEncoder; |
|
|
|
|
import java.util.Locale; |
|
|
|
|
@ -14,8 +17,12 @@ import okhttp3.Response; |
|
|
|
|
|
|
|
|
|
public class ProxyVideo { |
|
|
|
|
|
|
|
|
|
private static final String GO_SERVER = "http://127.0.0.1:7777/"; |
|
|
|
|
|
|
|
|
|
public static NanoHTTPD.Response multi(String url, Map<String, String> headers, int thread) throws Exception { |
|
|
|
|
return proxy(String.format(Locale.getDefault(), "http://127.0.0.1:7777/?url=%s&thread=%d", URLEncoder.encode(url), thread), headers); |
|
|
|
|
if (OkHttp.string(GO_SERVER).isEmpty()) OkHttp.string("http://127.0.0.1:" + Proxy.getPort() + "/go"); |
|
|
|
|
while (OkHttp.string(GO_SERVER).isEmpty()) SystemClock.sleep(250); |
|
|
|
|
return proxy(String.format(Locale.getDefault(), "%s?url=%s&thread=%d", GO_SERVER, URLEncoder.encode(url), thread), headers); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static NanoHTTPD.Response proxy(String url, Map<String, String> headers) throws Exception { |
|
|
|
|
|