diff --git a/app/src/main/java/com/github/catvod/api/AliYun.java b/app/src/main/java/com/github/catvod/api/AliYun.java index 6202c95..2e14d94 100644 --- a/app/src/main/java/com/github/catvod/api/AliYun.java +++ b/app/src/main/java/com/github/catvod/api/AliYun.java @@ -34,7 +34,7 @@ import com.github.catvod.net.OkHttp; import com.github.catvod.net.OkResult; import com.github.catvod.spider.Init; import com.github.catvod.spider.Proxy; -import com.github.catvod.utils.MultiThreadedDownloader; +import com.github.catvod.utils.MultiThread; import com.github.catvod.utils.Path; import com.github.catvod.utils.ProxyVideo; import com.github.catvod.utils.QRCode; @@ -67,8 +67,6 @@ public class AliYun { private final List tempIds; private final ReentrantLock lock; private final Cache cache; - - private MultiThreadedDownloader downloader; private ScheduledExecutorService service; private String refreshToken; private AlertDialog dialog; @@ -516,9 +514,7 @@ public class AliYun { if (thread == 1) { return new Object[]{ProxyVideo.proxy(downloadUrl, headers)}; } else { - if (downloader != null) downloader.destory(); - downloader = new MultiThreadedDownloader(downloadUrl, headers, thread); - return new Object[]{downloader.start()}; + return new Object[]{ProxyVideo.proxy(MultiThread.go(downloadUrl, thread), headers)}; } } diff --git a/app/src/main/java/com/github/catvod/utils/MultiThread.java b/app/src/main/java/com/github/catvod/utils/MultiThread.java index 510bb6b..b545d20 100644 --- a/app/src/main/java/com/github/catvod/utils/MultiThread.java +++ b/app/src/main/java/com/github/catvod/utils/MultiThread.java @@ -12,6 +12,10 @@ public class MultiThread { return String.format(Proxy.getUrl() + "?do=multi&url=%s&thread=%d", URLEncoder.encode(url), thread); } + public static String go(String url, int thread) { + return String.format("http://127.0.0.1:7777/?url=%s&thread=%d", URLEncoder.encode(url), thread); + } + public static Object[] proxy(Map params) throws Exception { String url = params.get("url"); int thread = Integer.parseInt(params.get("thread")); diff --git a/app/src/main/java/com/github/catvod/utils/ProxyVideo.java b/app/src/main/java/com/github/catvod/utils/ProxyVideo.java index 02d5922..29dc61e 100644 --- a/app/src/main/java/com/github/catvod/utils/ProxyVideo.java +++ b/app/src/main/java/com/github/catvod/utils/ProxyVideo.java @@ -23,6 +23,8 @@ public class ProxyVideo { String contentDisposition = response.headers().get("Content-Disposition"); long contentLength = hContentLength != null ? Long.parseLong(hContentLength) : 0; if (contentDisposition != null) contentType = Utils.getMimeType(contentDisposition); - return newFixedLengthResponse(status, contentType, response.body().byteStream(), contentLength); + NanoHTTPD.Response resp = newFixedLengthResponse(status, contentType, response.body().byteStream(), contentLength); + for (String key : response.headers().names()) resp.addHeader(key, response.headers().get(key)); + return resp; } }