Add files via upload
This commit is contained in:
@@ -19,9 +19,7 @@ import org.json.JSONObject;
|
|||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.security.Key;
|
|
||||||
import java.security.KeyFactory;
|
import java.security.KeyFactory;
|
||||||
import java.security.PublicKey;
|
|
||||||
import java.security.interfaces.RSAPublicKey;
|
import java.security.interfaces.RSAPublicKey;
|
||||||
import java.security.spec.X509EncodedKeySpec;
|
import java.security.spec.X509EncodedKeySpec;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -45,19 +43,13 @@ public class Kmys extends Spider {
|
|||||||
private String apiDomain = "";
|
private String apiDomain = "";
|
||||||
private String staticDomain = "";
|
private String staticDomain = "";
|
||||||
|
|
||||||
private String appId = "1"; // 飞瓜 1 酷猫 5
|
private String appId = "5"; // 飞瓜 1 酷猫 5
|
||||||
|
|
||||||
private String device = null;
|
|
||||||
|
|
||||||
public static final String KEY_ALGORITHM = "RSA";
|
|
||||||
|
|
||||||
private static final int MAX_DECRYPT_BLOCK = 128;
|
|
||||||
|
|
||||||
|
private String device = "1a7348ae45f8f6de4d798614fc07e7271657392501986";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Context context) {
|
public void init(Context context) {
|
||||||
super.init(context);
|
super.init(context);
|
||||||
getkey();
|
|
||||||
SharedPreferences sharedPreferences = context.getSharedPreferences("sp_Kmys", Context.MODE_PRIVATE);
|
SharedPreferences sharedPreferences = context.getSharedPreferences("sp_Kmys", Context.MODE_PRIVATE);
|
||||||
try {
|
try {
|
||||||
device = sharedPreferences.getString("device", null);
|
device = sharedPreferences.getString("device", null);
|
||||||
@@ -75,6 +67,7 @@ public class Kmys extends Spider {
|
|||||||
headers.put("versionNumber", "360");
|
headers.put("versionNumber", "360");
|
||||||
headers.put("versionName", "3.6.0");
|
headers.put("versionName", "3.6.0");
|
||||||
headers.put("device", device);
|
headers.put("device", device);
|
||||||
|
headers.put("ed", device);
|
||||||
headers.put("appId", appId);
|
headers.put("appId", appId);
|
||||||
headers.put("platformId", "7");
|
headers.put("platformId", "7");
|
||||||
headers.put("User-Agent", "okhttp/3.14.7");
|
headers.put("User-Agent", "okhttp/3.14.7");
|
||||||
@@ -86,6 +79,7 @@ public class Kmys extends Spider {
|
|||||||
String url = "http://feigua2021.oss-cn-beijing.aliyuncs.com/static/config/video/" + appId + ".json";
|
String url = "http://feigua2021.oss-cn-beijing.aliyuncs.com/static/config/video/" + appId + ".json";
|
||||||
HashMap<String, String> headers = new HashMap<>();
|
HashMap<String, String> headers = new HashMap<>();
|
||||||
headers.put("User-Agent", "okhttp/3.14.7");
|
headers.put("User-Agent", "okhttp/3.14.7");
|
||||||
|
headers.put("ed", device);
|
||||||
String json = OkHttpUtil.string(url, headers);
|
String json = OkHttpUtil.string(url, headers);
|
||||||
try {
|
try {
|
||||||
JSONObject obj = new JSONObject(json);
|
JSONObject obj = new JSONObject(json);
|
||||||
@@ -220,6 +214,7 @@ public class Kmys extends Spider {
|
|||||||
public String homeVideoContent() {
|
public String homeVideoContent() {
|
||||||
try {
|
try {
|
||||||
checkDomain();
|
checkDomain();
|
||||||
|
getkey();
|
||||||
String url = staticDomain + "/static/" + appId + "/index/cloumn/1.json";
|
String url = staticDomain + "/static/" + appId + "/index/cloumn/1.json";
|
||||||
String content = OkHttpUtil.string(url, getHeaders(url));
|
String content = OkHttpUtil.string(url, getHeaders(url));
|
||||||
JSONObject jsonObject = new JSONObject(content).getJSONObject("data");
|
JSONObject jsonObject = new JSONObject(content).getJSONObject("data");
|
||||||
@@ -250,6 +245,7 @@ public class Kmys extends Spider {
|
|||||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) {
|
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) {
|
||||||
try {
|
try {
|
||||||
checkDomain();
|
checkDomain();
|
||||||
|
getkey();
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
|
|
||||||
String url = apiDomain + "/videolibrary/v2/" + appId + "/" + tid;
|
String url = apiDomain + "/videolibrary/v2/" + appId + "/" + tid;
|
||||||
@@ -306,6 +302,7 @@ public class Kmys extends Spider {
|
|||||||
public String detailContent(List<String> ids) {
|
public String detailContent(List<String> ids) {
|
||||||
try {
|
try {
|
||||||
checkDomain();
|
checkDomain();
|
||||||
|
getkey();
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
String url = staticDomain + "/static/video/detail/" + ids.get(0) + ".json";
|
String url = staticDomain + "/static/video/detail/" + ids.get(0) + ".json";
|
||||||
String content = OkHttpUtil.string(url, getHeaders(url));
|
String content = OkHttpUtil.string(url, getHeaders(url));
|
||||||
@@ -388,9 +385,6 @@ public class Kmys extends Spider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String searchContent(String key, boolean quick) {
|
public String searchContent(String key, boolean quick) {
|
||||||
|
|
||||||
if (quick)
|
|
||||||
return "";
|
|
||||||
try {
|
try {
|
||||||
checkDomain();
|
checkDomain();
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
@@ -434,7 +428,61 @@ public class Kmys extends Spider {
|
|||||||
SpiderDebug.log(e);
|
SpiderDebug.log(e);
|
||||||
}
|
}
|
||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void getkey(){
|
||||||
|
if (signPlayerStr.isEmpty()){
|
||||||
|
////https://video-api.kumaoys.cn/api/v2/b/83708861
|
||||||
|
String url = "https://mtv.stvmts.com/api/v2/b/"+((int) (Math.random() * 100000000));
|
||||||
|
HashMap hashMap = new HashMap();
|
||||||
|
hashMap.put("versionNumber", "360");
|
||||||
|
hashMap.put("versionName", "3.6.0");
|
||||||
|
hashMap.put("device", "1a7348ae45f8f6de4d798614fc07e7271657392501986");
|
||||||
|
//hashMap.put("appId", "5");
|
||||||
|
hashMap.put("platformId", "7");
|
||||||
|
hashMap.put("User-Agent", "okhttp/3.14.7");
|
||||||
|
hashMap.put("Pragma", "Pragma:: no-cache");
|
||||||
|
hashMap.put("Cache-Control", "no-cache");
|
||||||
|
hashMap.put("Host", "mtv.stvmts.com");
|
||||||
|
hashMap.put("Content-Type", "application/json; charser=utf-8");
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
try {
|
||||||
|
int random = (int)(Math.random()*1.0E8d);
|
||||||
|
int time = (int)(System.currentTimeMillis()/1000);
|
||||||
|
String signBefore = "p=com.feigua.yingshi&t=" + time + "&r=" + random + "&s=36eff39894f62d333fd3f488cffbf364&pl=1";
|
||||||
|
jsonObject.put("s",Misc.MD5(signBefore,Misc.CharsetUTF8));
|
||||||
|
jsonObject.put("t",time);
|
||||||
|
jsonObject.put("r",random);
|
||||||
|
jsonObject.put("i",5);
|
||||||
|
jsonObject.put("p",1);
|
||||||
|
OkHttpUtil.postJson(OkHttpUtil.defaultClient(), url, jsonObject.toString(), hashMap, new OKCallBack.OKCallBackString() {
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call call, Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(String response) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
JSONObject jsonObject = new JSONObject(response).getJSONObject("data");
|
||||||
|
String a = new String(Base64.decode(jsonObject.getString("a"), Base64.DEFAULT));
|
||||||
|
String k = new String(Base64.decode(jsonObject.getString("k"), Base64.DEFAULT));
|
||||||
|
String z = new String(Base64.decode(jsonObject.getString("z"), Base64.DEFAULT));
|
||||||
|
String data = rsa2(k+z+a);
|
||||||
|
signPlayerStr = new JSONObject(data).optString("key");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
String rsa(String in) {
|
String rsa(String in) {
|
||||||
try {
|
try {
|
||||||
@@ -466,6 +514,30 @@ public class Kmys extends Spider {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String rsa2(String in) {
|
||||||
|
try {
|
||||||
|
RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(Base64.decode("MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCt/dLGQj1Iimj0LIUMUXgBGUjsfrm6o1/pZjXXVLL3py2vLktNtSoJU+69v1tUXZqiU9BqMHApVmMOtOnkL5J+ENdLIX3bXnNtfNJpYX4Iz8OBMqKdDch80gN8rLkTPReFkBGsMAndKpc0iMdgd6nts/gQ3wUBNJKpmOG35UateQIDAQAB", Base64.DEFAULT)));
|
||||||
|
Cipher cipher = Cipher.getInstance("RSA/None/PKCS1Padding");
|
||||||
|
cipher.init(Cipher.DECRYPT_MODE, pubKey);
|
||||||
|
byte[] inData = Base64.decode(in, Base64.DEFAULT);
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
if (inData.length <= 256) {
|
||||||
|
outputStream.write(cipher.doFinal(inData));
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < inData.length; i += 256) {
|
||||||
|
outputStream.write(cipher.doFinal(inData, i, 256));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outputStream.flush();
|
||||||
|
String result = new String(outputStream.toByteArray(), Misc.CharsetUTF8);
|
||||||
|
outputStream.close();
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
private static HashMap<String, String> kmysPlayerHeaders = null;
|
private static HashMap<String, String> kmysPlayerHeaders = null;
|
||||||
private static String signPlayerStr = "";
|
private static String signPlayerStr = "";
|
||||||
private static final Pattern tsRex = Pattern.compile("(\\S+.ts)|(#EXT-X-KEY:\\S+\")(\\S+)(\")");
|
private static final Pattern tsRex = Pattern.compile("(\\S+.ts)|(#EXT-X-KEY:\\S+\")(\\S+)(\")");
|
||||||
@@ -482,7 +554,7 @@ public class Kmys extends Spider {
|
|||||||
Uri uri = Uri.parse(m3u8);
|
Uri uri = Uri.parse(m3u8);
|
||||||
String time = String.valueOf(System.currentTimeMillis());
|
String time = String.valueOf(System.currentTimeMillis());
|
||||||
String key = Misc.MD5(subUrl(m3u8) + signPlayerStr + time, Misc.CharsetUTF8).toLowerCase();
|
String key = Misc.MD5(subUrl(m3u8) + signPlayerStr + time, Misc.CharsetUTF8).toLowerCase();
|
||||||
String realUrl = m3u8 + "?key=" + key + "&time=" + time;
|
String realUrl = m3u8 + "?key=" + key + "&v=360&i=5&p=7&ed=1a7348ae45f8f6de4d798614fc07e7271657392501986&time=" + time;
|
||||||
String m3u8Content = OkHttpUtil.string(realUrl, kmysPlayerHeaders);
|
String m3u8Content = OkHttpUtil.string(realUrl, kmysPlayerHeaders);
|
||||||
String tsUrl = m3u8.substring(0, m3u8.indexOf(uri.getLastPathSegment()));
|
String tsUrl = m3u8.substring(0, m3u8.indexOf(uri.getLastPathSegment()));
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
@@ -512,7 +584,7 @@ public class Kmys extends Spider {
|
|||||||
static Object[] getKeyContent(String key) {
|
static Object[] getKeyContent(String key) {
|
||||||
String time = String.valueOf(System.currentTimeMillis());
|
String time = String.valueOf(System.currentTimeMillis());
|
||||||
String md5 = Misc.MD5(subUrl(key) + signPlayerStr + time, Misc.CharsetUTF8).toLowerCase();
|
String md5 = Misc.MD5(subUrl(key) + signPlayerStr + time, Misc.CharsetUTF8).toLowerCase();
|
||||||
String realUrl = key + "?key=" + md5 + "&time=" + time;
|
String realUrl = key + "?key=" + md5 + "&v=360&i=5&p=7&ed=1a7348ae45f8f6de4d798614fc07e7271657392501986&time=" + time;
|
||||||
String keyContent = OkHttpUtil.string(realUrl, kmysPlayerHeaders);
|
String keyContent = OkHttpUtil.string(realUrl, kmysPlayerHeaders);
|
||||||
String type = "application/octet-stream";
|
String type = "application/octet-stream";
|
||||||
Object[] result = new Object[3];
|
Object[] result = new Object[3];
|
||||||
@@ -526,7 +598,7 @@ public class Kmys extends Spider {
|
|||||||
static Object[] getTsContent(String ts) {
|
static Object[] getTsContent(String ts) {
|
||||||
String time = String.valueOf(System.currentTimeMillis());
|
String time = String.valueOf(System.currentTimeMillis());
|
||||||
String key = Misc.MD5(subUrl(ts) + signPlayerStr + time, Misc.CharsetUTF8).toLowerCase();
|
String key = Misc.MD5(subUrl(ts) + signPlayerStr + time, Misc.CharsetUTF8).toLowerCase();
|
||||||
String realUrl = ts + "?key=" + key + "&time=" + time;
|
String realUrl = ts + "?key=" + key + "&v=360&i=5&p=7&ed=1a7348ae45f8f6de4d798614fc07e7271657392501986&time=" + time;
|
||||||
OKCallBack.OKCallBackDefault callBack = new OKCallBack.OKCallBackDefault() {
|
OKCallBack.OKCallBackDefault callBack = new OKCallBack.OKCallBackDefault() {
|
||||||
|
|
||||||
|
|
||||||
@@ -562,6 +634,7 @@ public class Kmys extends Spider {
|
|||||||
if (kmysPlayerHeaders == null) {
|
if (kmysPlayerHeaders == null) {
|
||||||
kmysPlayerHeaders = new HashMap<>();
|
kmysPlayerHeaders = new HashMap<>();
|
||||||
kmysPlayerHeaders.put("User-Agent", "okhttp/3.14.7");
|
kmysPlayerHeaders.put("User-Agent", "okhttp/3.14.7");
|
||||||
|
kmysPlayerHeaders.put("ed", "1a7348ae45f8f6de4d798614fc07e7271657392501986");
|
||||||
kmysPlayerHeaders.put("Connection", "close");
|
kmysPlayerHeaders.put("Connection", "close");
|
||||||
}
|
}
|
||||||
if (type.equals("m3u8")) {
|
if (type.equals("m3u8")) {
|
||||||
@@ -574,90 +647,5 @@ public class Kmys extends Spider {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getkey(){
|
|
||||||
if (signPlayerStr.isEmpty()){
|
|
||||||
////https://video-api.kumaoys.cn/api/v2/b/83708861
|
|
||||||
String url = "https://mtv.stvmts.com/api/v2/b/"+((int) (Math.random() * 100000000));
|
|
||||||
HashMap hashMap = new HashMap();
|
|
||||||
hashMap.put("versionNumber", "360");
|
|
||||||
hashMap.put("versionName", "3.6.0");
|
|
||||||
hashMap.put("device", "f6076f40ecda2adacbcefeaad22527ce1656685979546");
|
|
||||||
//hashMap.put("appId", "5");
|
|
||||||
hashMap.put("platformId", "7");
|
|
||||||
hashMap.put("User-Agent", "okhttp/3.14.7");
|
|
||||||
hashMap.put("Pragma", "Pragma:: no-cache");
|
|
||||||
hashMap.put("Cache-Control", "no-cache");
|
|
||||||
hashMap.put("Host", "mtv.stvmts.com");
|
|
||||||
hashMap.put("Content-Type", "application/json; charser=utf-8");
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
|
||||||
try {
|
|
||||||
int random = (int)(Math.random()*1.0E8d);
|
|
||||||
int time = (int)(System.currentTimeMillis()/1000);
|
|
||||||
String signBefore = "p=com.kumao.yingshi&t=" + time + "&r=" + random + "&s=36eff39894f62d333fd3f488cffbf364&pl=1";
|
|
||||||
jsonObject.put("s",Misc.MD5(signBefore,Misc.CharsetUTF8));
|
|
||||||
jsonObject.put("t",time);
|
|
||||||
jsonObject.put("r",random);
|
|
||||||
jsonObject.put("i",5);
|
|
||||||
jsonObject.put("p",1);
|
|
||||||
OkHttpUtil.postJson(OkHttpUtil.defaultClient(), url, jsonObject.toString(), hashMap, new OKCallBack.OKCallBackString() {
|
|
||||||
@Override
|
|
||||||
public void onFailure(Call call, Exception e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public void onResponse(String response) {
|
|
||||||
try {
|
|
||||||
|
|
||||||
JSONObject jsonObject = new JSONObject(response).getJSONObject("data");
|
|
||||||
String a = new String(Base64.decode(jsonObject.getString("a"),Base64.DEFAULT));
|
|
||||||
String k = new String(Base64.decode(jsonObject.getString("k"),Base64.DEFAULT));
|
|
||||||
String z = new String(Base64.decode(jsonObject.getString("z"),Base64.DEFAULT));
|
|
||||||
|
|
||||||
String sum=(k+z+a);
|
|
||||||
byte[] byte_sum=Base64.decode(sum,Base64.DEFAULT);
|
|
||||||
byte[] jiemi=decryptByPublicKey(byte_sum,"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCt/dLGQj1Iimj0LIUMUXgBGUjsfrm6o1/pZjXXVLL3py2vLktNtSoJU+69v1tUXZqiU9BqMHApVmMOtOnkL5J+ENdLIX3bXnNtfNJpYX4Iz8OBMqKdDch80gN8rLkTPReFkBGsMAndKpc0iMdgd6nts/gQ3wUBNJKpmOG35UateQIDAQAB");
|
|
||||||
String data =new String(jiemi,Misc.CharsetUTF8);
|
|
||||||
signPlayerStr = new JSONObject(data).optString("key");
|
|
||||||
} catch (JSONException e) {
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte[] decryptByPublicKey(byte[] encryptedData, String publicKey) throws Exception {
|
|
||||||
byte[] keyBytes = Base64.decode(publicKey,Base64.DEFAULT);
|
|
||||||
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes);
|
|
||||||
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
|
|
||||||
Key publicK = keyFactory.generatePublic(x509KeySpec);
|
|
||||||
Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
|
|
||||||
cipher.init(Cipher.DECRYPT_MODE, publicK);
|
|
||||||
int inputLen = encryptedData.length;
|
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
||||||
int offSet = 0;
|
|
||||||
byte[] cache;
|
|
||||||
int i = 0;
|
|
||||||
// 对数据分段解密
|
|
||||||
while (inputLen - offSet > 0) {
|
|
||||||
if (inputLen - offSet > MAX_DECRYPT_BLOCK) {
|
|
||||||
cache = cipher.doFinal(encryptedData, offSet, MAX_DECRYPT_BLOCK);
|
|
||||||
} else {
|
|
||||||
cache = cipher.doFinal(encryptedData, offSet, inputLen - offSet);
|
|
||||||
}
|
|
||||||
out.write(cache, 0, cache.length);
|
|
||||||
i++;
|
|
||||||
offSet = i * MAX_DECRYPT_BLOCK;
|
|
||||||
}
|
|
||||||
byte[] decryptedData = out.toByteArray();
|
|
||||||
out.close();
|
|
||||||
return decryptedData;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user