diff --git a/app/src/main/java/com/github/catvod/api/UCApi.java b/app/src/main/java/com/github/catvod/api/UCApi.java index 26134748..cafa6305 100644 --- a/app/src/main/java/com/github/catvod/api/UCApi.java +++ b/app/src/main/java/com/github/catvod/api/UCApi.java @@ -226,9 +226,21 @@ public class UCApi { Map header = getHeaders(); header.remove("Host"); header.remove("Content-Type"); + + //UCTV 可以直接播放,不需要代理 + if (testVideo(playUrl)) { + return Result.get().url(playUrl).octet().header(header).string(); + } return Result.get().url(proxyVideoUrl(playUrl, header)).octet().header(header).string(); } + private boolean testVideo(String url) { + + OkResult okResult1 = OkHttp.get(url, new HashMap<>(), Map.of("Range", "bytes=0-0")); + return okResult1.getCode() == 206; + + } + private String proxyVideoUrl(String url, Map header) { return String.format(Proxy.getUrl() + "?do=uc&type=video&url=%s&header=%s", Util.base64Encode(url.getBytes(Charset.defaultCharset())), Util.base64Encode(Json.toJson(header).getBytes(Charset.defaultCharset()))); } diff --git a/app/src/test/java/com/github/catvod/api/QRCodeHandlerTest.java b/app/src/test/java/com/github/catvod/api/QRCodeHandlerTest.java index 0b73b2f2..9bfc68ca 100644 --- a/app/src/test/java/com/github/catvod/api/QRCodeHandlerTest.java +++ b/app/src/test/java/com/github/catvod/api/QRCodeHandlerTest.java @@ -1,10 +1,14 @@ package com.github.catvod.api; +import com.github.catvod.net.OkHttp; +import com.github.catvod.net.OkResult; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; +import java.util.HashMap; + @RunWith(RobolectricTestRunner.class) public class QRCodeHandlerTest { @@ -23,18 +27,22 @@ public class QRCodeHandlerTest { // Execute the method under test String result = qrCodeHandler.startUC_TOKENScan(); System.out.println(result); - while(true){ + while (true) { } - } @Test + } + + @Test public void download() throws Exception { // Mock the OkHttp.get method to return a predefined OkResult // Execute the method under test - qrCodeHandler.download("eyJhbGciOiJIUzI1NiIsIlR5cGUiOiJKd3QiLCJ0eXAiOiJKV1QifQ.eyJvcGVuSWQiOiJkMTQ4MjM1MmFiMWU0NmYwOGQ3M2VmYzQyYWRiOTgxNSIsImV4cCI6MTc0MjUyNjU1MiwidG9rZW4iOiJkZmEwMjI2YzJmNDQ0ZTlmYTAxNzYxNGVhMDVkODczOCJ9.mUlFZdgSfACjZaBsmYNdgZSY7eSy4_hI3oZ8niq36Xs","c31c86354605487cbb077a59d3bfa8ad"); + qrCodeHandler.download("eyJhbGciOiJIUzI1NiIsIlR5cGUiOiJKd3QiLCJ0eXAiOiJKV1QifQ.eyJvcGVuSWQiOiJkMTQ4MjM1MmFiMWU0NmYwOGQ3M2VmYzQyYWRiOTgxNSIsImV4cCI6MTc0MjUyNjU1MiwidG9rZW4iOiJkZmEwMjI2YzJmNDQ0ZTlmYTAxNzYxNGVhMDVkODczOCJ9.mUlFZdgSfACjZaBsmYNdgZSY7eSy4_hI3oZ8niq36Xs", "c31c86354605487cbb077a59d3bfa8ad"); } + + } \ No newline at end of file diff --git a/app/src/test/java/com/github/catvod/api/QuarkApiTest.java b/app/src/test/java/com/github/catvod/api/QuarkApiTest.java index 0e5850c3..af24852b 100644 --- a/app/src/test/java/com/github/catvod/api/QuarkApiTest.java +++ b/app/src/test/java/com/github/catvod/api/QuarkApiTest.java @@ -3,6 +3,8 @@ package com.github.catvod.api; import static org.junit.Assert.*; import com.github.catvod.bean.quark.ShareData; +import com.github.catvod.net.OkHttp; +import com.github.catvod.net.OkResult; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -10,6 +12,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; +import java.util.HashMap; +import java.util.Map; + @RunWith(RobolectricTestRunner.class) public class QuarkApiTest { @@ -22,4 +27,16 @@ public class QuarkApiTest { // // System.out.println("getShareData--" + gson.toJson(shareData)); // } + + @Test + public void testdownload() throws Exception { + + String url = "https://video-play-p-zb.cdn.yun.cn/P7r95SEr/1997440970/7986fbd7419840ba83d70e7ec36f933867d2fadf/67d2fadf98f5dd83fcd64481858236a79b4c3384?auth_key=1741952223-3304496-16098-d233ccbc65c0321102d36db56f3db9c2&sp=642&token=3-08917a23ee79367eab5e9dcfbd898751-3-2-963-5cbf_3bd039d6d54ec6a8737515d6f20a488c-0-0-0-0-e9fc047ff0aa9b590be130819e1e82f2&ud=9-0-1-2-1-5-8-N-0-4-0-N"; + OkResult okResult1 = OkHttp.get(url, new HashMap<>(), Map.of("Range","bytes=0-0")); + if (okResult1.getCode() == 200) { + + } + + + } } \ No newline at end of file diff --git a/jar/custom_spider.jar b/jar/custom_spider.jar index 5fafc001..56067074 100644 Binary files a/jar/custom_spider.jar and b/jar/custom_spider.jar differ diff --git a/jar/custom_spider.jar.md5 b/jar/custom_spider.jar.md5 index 5b46b8a1..d0d067c6 100644 --- a/jar/custom_spider.jar.md5 +++ b/jar/custom_spider.jar.md5 @@ -1 +1 @@ -64a776d83bd9349b875b76ed6cc4e4a9 +a7d20a774661b18abb93ca0c7106b7b3 diff --git a/json/index.json b/json/index.json index 4fe08948..ba2eef6b 100644 --- a/json/index.json +++ b/json/index.json @@ -1,5 +1,5 @@ { - "spider": "https://androidcatvodspider.netlify.app/jar/custom_spider.jar;md5;64a776d83bd9349b875b76ed6cc4e4a9", + "spider": "https://androidcatvodspider.netlify.app/jar/custom_spider.jar;md5;a7d20a774661b18abb93ca0c7106b7b3", "lives": [ { diff --git a/json/index1.json b/json/index1.json index 512bd41d..8eec57b0 100644 --- a/json/index1.json +++ b/json/index1.json @@ -1,5 +1,5 @@ { - "spider": "https://androidcatvodspider.netlify.app/jar/custom_spider.jar;md5;64a776d83bd9349b875b76ed6cc4e4a9", + "spider": "https://androidcatvodspider.netlify.app/jar/custom_spider.jar;md5;a7d20a774661b18abb93ca0c7106b7b3", "lives": [ { "name": "直播ipv6", diff --git a/json/index2.json b/json/index2.json index f3291a21..3875255b 100644 --- a/json/index2.json +++ b/json/index2.json @@ -1,5 +1,5 @@ { - "spider": "https://androidcatvodspider.netlify.app/jar/custom_spider.jar;md5;64a776d83bd9349b875b76ed6cc4e4a9", + "spider": "https://androidcatvodspider.netlify.app/jar/custom_spider.jar;md5;a7d20a774661b18abb93ca0c7106b7b3", "lives": [ { "name": "直播ipv6", diff --git a/json/test.json b/json/test.json index feac910a..8c0a5861 100644 --- a/json/test.json +++ b/json/test.json @@ -1,5 +1,5 @@ { - "spider": "https://androidcatvodspider.netlify.app/jar/custom_spider.jar;md5;64a776d83bd9349b875b76ed6cc4e4a9", + "spider": "https://androidcatvodspider.netlify.app/jar/custom_spider.jar;md5;a7d20a774661b18abb93ca0c7106b7b3", "lives": [ { "name": "直播",