diff --git a/app/src/main/java/com/github/catvod/spider/NCat.java b/app/src/main/java/com/github/catvod/spider/NCat.java index 1dd6fc00..c653921c 100644 --- a/app/src/main/java/com/github/catvod/spider/NCat.java +++ b/app/src/main/java/com/github/catvod/spider/NCat.java @@ -7,7 +7,7 @@ import com.github.catvod.crawler.Spider; import com.github.catvod.net.OkHttp; import com.github.catvod.utils.AESEncryption; import com.github.catvod.utils.Util; - +import org.apache.commons.lang3.StringUtils; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; @@ -15,6 +15,7 @@ import org.jsoup.select.Elements; import java.net.URLEncoder; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.regex.Matcher; @@ -22,8 +23,8 @@ import java.util.regex.Pattern; public class NCat extends Spider { - private static final String siteUrl = "https://www.ncat3.com:51111"; - private static final String picUrl = "https://61.147.93.252:15002"; + private static final String siteUrl = "https://www.ncat3.app"; + private static final String picUrl = "https://vres.wbadl.cn"; private static final String cateUrl = siteUrl + "/show/"; private static final String detailUrl = siteUrl + "/detail/"; private static final String searchUrl = siteUrl + "/search?k="; @@ -100,6 +101,7 @@ public class NCat extends Spider { String PlayUrl = ""; for (int i = 0; i < tabs.size(); i++) { String tabName = tabs.get(i).select("span").last().text(); + if (Arrays.asList("超清", "4K(高峰不卡)").contains(tabName)) continue; if (!"".equals(PlayFrom)) { PlayFrom = PlayFrom + "$$$" + tabName; } else { @@ -156,16 +158,27 @@ public class NCat extends Spider { public String playerContent(String flag, String id, List vipFlags) throws Exception { Document doc = Jsoup.parse(OkHttp.string(playUrl.concat(id), getHeaders())); String regex = "window.whatTMDwhatTMDPPPP = '(.*?)'"; - + String playSource = "playSource=\\{(.*?)\\}"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(doc.html()); String url = ""; if (matcher.find()) { url = matcher.group(1); - String regex1 = "KKYS\\.safePlay\\(\\)\\.url(\"(.*?)\"),"; + Pattern playSourcePattern = Pattern.compile(playSource); + Matcher playSourceMatcher = playSourcePattern.matcher(doc.html()); + //playSourceMatcher.find(); + String srcUrl = Util.findByRegex("https?://[^\\s/$.?#].+\\.m3u8", doc.html(), 0); + if(StringUtils.isNoneBlank(srcUrl)){ + return Result.get().url(srcUrl).header(getHeaders()).string(); + + } + String js = playSourceMatcher.group(1); + + String regex1 = "KKYS\\['safePlay'\\]\\(\\)\\['url'\\]\\(\"([^\"]+)\"\\)"; Pattern pattern1 = Pattern.compile(regex1); - Matcher matcher1 = pattern1.matcher(doc.html()); - String iv = ""; + String jsSource = Util.unicodeToString(js); + Matcher matcher1 = pattern1.matcher(jsSource); + String iv = "VNF9aVQF!G*0ux@2hAigUeH3"; if (matcher1.find()) { iv = matcher1.group(1); } @@ -178,7 +191,7 @@ public class NCat extends Spider { try { String encryptedKey = "VNF9aVQF!G*0ux@2hAigUeH3"; - return AESEncryption.decrypt(encryptedData, encryptedKey, iv,AESEncryption.ECB_PKCS_7_PADDING); + return AESEncryption.decrypt(encryptedData, encryptedKey, iv, AESEncryption.ECB_PKCS_7_PADDING); } catch (Exception e) { e.printStackTrace(); return "123456"; diff --git a/app/src/main/java/com/github/catvod/utils/Util.java b/app/src/main/java/com/github/catvod/utils/Util.java index f8ec0452..af15868d 100644 --- a/app/src/main/java/com/github/catvod/utils/Util.java +++ b/app/src/main/java/com/github/catvod/utils/Util.java @@ -11,18 +11,15 @@ import android.view.ViewGroup; import android.webkit.ValueCallback; import android.webkit.WebView; import android.webkit.WebViewClient; - import com.github.catvod.spider.Init; +import org.apache.commons.lang3.StringUtils; import java.math.BigInteger; import java.net.URI; import java.nio.charset.Charset; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -361,6 +358,41 @@ public class Util { } } + public static String unicodeToString(String unicode) { + if (StringUtils.isBlank(unicode)) { + return unicode; + } + + final int len = unicode.length(); + StringBuilder sb = new StringBuilder(len); + int i; + int pos = 0; + while ((i = StringUtils.indexOfIgnoreCase(unicode, "\\u", pos)) != -1) { + sb.append(unicode, pos, i);//写入Unicode符之前的部分 + pos = i; + if (i + 5 < len) { + char c; + try { + c = (char) Integer.parseInt(unicode.substring(i + 2, i + 6), 16); + sb.append(c); + pos = i + 6;//跳过整个Unicode符 + } catch (NumberFormatException e) { + //非法Unicode符,跳过 + sb.append(unicode, pos, i + 2);//写入"\\u" + pos = i + 2; + } + } else { + //非Unicode符,结束 + break; + } + } + + if (pos < len) { + sb.append(unicode, pos, len); + } + return sb.toString(); + } + public static class LCSResult { public int length; diff --git a/app/src/test/java/NCatTest.java b/app/src/test/java/NCatTest.java index b8031026..32302b27 100644 --- a/app/src/test/java/NCatTest.java +++ b/app/src/test/java/NCatTest.java @@ -73,8 +73,8 @@ public class NCatTest { @org.junit.Test public void playerContent() throws Exception { - String froms = "超清$$$4K(高峰不卡)$$$FF线路$$$蓝光3$$$蓝光2$$$蓝光9$$$蓝光1$$$蓝光9-1$$$蓝光1-1$$$蓝光9-2"; - String urls = "国语$232824-32-703932.html#粤语$232824-32-910325.html$$$国语$232824-35-703905.html#粤语$232824-35-910260.html$$$国语$232824-4-648287.html#粤语$232824-4-730937.html$$$HD国语$232824-2-558076.html#HD粤语$232824-2-573419.html$$$枪版$232824-31-824909.html$$$正片$232824-36-395120.html$$$国语中字$232824-27-547772.html$$$正片$232824-36-395138.html$$$TC$232824-27-504728.html$$$抢先版$232824-36-377043.html"; + String froms = "FF线路$$$蓝光3$$$蓝光9$$$蓝光9-1$$$蓝光1$$$蓝光9-2$$$蓝光1-1$$$蓝光1-2$$$蓝光7"; + String urls = "国语$232824-4-648287.html#粤语$232824-4-730937.html$$$HD国语$232824-2-558076.html#HD粤语$232824-2-573419.html$$$正片$232824-36-395120.html$$$正片$232824-36-395138.html$$$TC$232824-27-504728.html$$$抢先版$232824-36-377043.html$$$粤语中字$232824-27-547751.html$$$国语中字$232824-27-547772.html$$$正片$232824-33-393805.html"; for (int i = 0; i < urls.split("\\$\\$\\$").length; i++) { String content = spider.playerContent(froms.split("\\$\\$\\$")[i], urls.split("\\$\\$\\$")[i].split("\\$")[1].split("#")[0], new ArrayList<>()); JsonObject map = Json.safeObject(content); diff --git a/jar/custom_spider.jar b/jar/custom_spider.jar index 0101aa72..38f3f8a0 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 f10da4e3..7c815108 100644 --- a/jar/custom_spider.jar.md5 +++ b/jar/custom_spider.jar.md5 @@ -1 +1 @@ -a00ec8ec69d7fbf02a7e3b80d1cd7b2f +0980b0c660780f15ebefa9226fd43f7c diff --git a/json/index.json b/json/index.json index 927f0bd5..3577157b 100644 --- a/json/index.json +++ b/json/index.json @@ -1,5 +1,5 @@ { - "spider": "https://androidcatvodspider.netlify.app/jar/custom_spider.jar;md5;a00ec8ec69d7fbf02a7e3b80d1cd7b2f", + "spider": "https://androidcatvodspider.netlify.app/jar/custom_spider.jar;md5;0980b0c660780f15ebefa9226fd43f7c", "lives": [ { diff --git a/json/index1.json b/json/index1.json index ad906926..937873d8 100644 --- a/json/index1.json +++ b/json/index1.json @@ -1,5 +1,5 @@ { - "spider": "https://androidcatvodspider.netlify.app/jar/custom_spider.jar;md5;a00ec8ec69d7fbf02a7e3b80d1cd7b2f", + "spider": "https://androidcatvodspider.netlify.app/jar/custom_spider.jar;md5;0980b0c660780f15ebefa9226fd43f7c", "lives": [ { "name": "直播ipv6", diff --git a/json/index2.json b/json/index2.json index 667ee0ee..e2086d6f 100644 --- a/json/index2.json +++ b/json/index2.json @@ -1,5 +1,5 @@ { - "spider": "https://androidcatvodspider.netlify.app/jar/custom_spider.jar;md5;a00ec8ec69d7fbf02a7e3b80d1cd7b2f", + "spider": "https://androidcatvodspider.netlify.app/jar/custom_spider.jar;md5;0980b0c660780f15ebefa9226fd43f7c", "lives": [ { "name": "直播ipv6", diff --git a/json/test.json b/json/test.json index 18240b2e..b732ebcd 100644 --- a/json/test.json +++ b/json/test.json @@ -1,5 +1,5 @@ { - "spider": "https://androidcatvodspider.netlify.app/jar/custom_spider.jar;md5;a00ec8ec69d7fbf02a7e3b80d1cd7b2f", + "spider": "https://androidcatvodspider.netlify.app/jar/custom_spider.jar;md5;0980b0c660780f15ebefa9226fd43f7c", "lives": [ { "name": "直播",