optimize ysp
This commit is contained in:
parent
cc2dc25e35
commit
d8fffbb402
|
|
@ -100,6 +100,7 @@ class Request(var context: Context) {
|
||||||
val matchResult = regex.find(decodedString)
|
val matchResult = regex.find(decodedString)
|
||||||
var keyBytes = byteArrayOf()
|
var keyBytes = byteArrayOf()
|
||||||
var ivBytes = byteArrayOf()
|
var ivBytes = byteArrayOf()
|
||||||
|
|
||||||
if (matchResult != null) {
|
if (matchResult != null) {
|
||||||
val (key, iv) = matchResult.destructured
|
val (key, iv) = matchResult.destructured
|
||||||
keyBytes = Base64.decode(key, Base64.DEFAULT)
|
keyBytes = Base64.decode(key, Base64.DEFAULT)
|
||||||
|
|
@ -107,9 +108,9 @@ class Request(var context: Context) {
|
||||||
}
|
}
|
||||||
tvModel.updateVideoUrlByYSP(
|
tvModel.updateVideoUrlByYSP(
|
||||||
liveInfo.data.playurl + "&revoi=" + encryptTripleDES(
|
liveInfo.data.playurl + "&revoi=" + encryptTripleDES(
|
||||||
keyBytes,
|
keyBytes + byteArrayOf(0, 0, 0, 0, 0, 0, 0, 0),
|
||||||
ivBytes
|
ivBytes
|
||||||
)
|
).uppercase()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -177,15 +178,15 @@ class Request(var context: Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun encryptTripleDES(key: ByteArray, iv: ByteArray): String {
|
private fun encryptTripleDES(key: ByteArray, iv: ByteArray): String {
|
||||||
val plaintext =
|
var plaintext =
|
||||||
"""{"mver":"1","subver":"1.2","host":"www.yangshipin.cn/#/tv/home?pid=","referer":"","canvas":"YSPANGLE(Apple,AppleM1Pro,OpenGL4.1)"}"""
|
"""{"mver":"1","subver":"1.2","host":"www.yangshipin.cn/#/tv/home?pid=","referer":"","canvas":"YSPANGLE(Apple,AppleM1Pro,OpenGL4.1)"}"""
|
||||||
return try {
|
return try {
|
||||||
val keySpec = SecretKeySpec(key, "DESede")
|
val keySpec = SecretKeySpec(key, "DESede")
|
||||||
val ivSpec = IvParameterSpec(iv)
|
val ivSpec = IvParameterSpec(iv)
|
||||||
val cipher = Cipher.getInstance("DESede/CBC/PKCS7Padding")
|
val cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding")
|
||||||
cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec)
|
cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec)
|
||||||
val encryptedBytes = cipher.doFinal(plaintext.toByteArray())
|
val encryptedBytes = cipher.doFinal(plaintext.toByteArray())
|
||||||
encryptedBytes.let { it -> it.joinToString("") { "%02x".format(it) } }
|
return encryptedBytes.let { it -> it.joinToString("") { "%02x".format(it) } }
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
""
|
""
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ class YSP(var context: Context) {
|
||||||
cnlid = tvModel.getTV().sid
|
cnlid = tvModel.getTV().sid
|
||||||
defn = "fhd"
|
defn = "fhd"
|
||||||
|
|
||||||
guid = getGuid()
|
// guid = getGuid()
|
||||||
randStr = getRand()
|
randStr = getRand()
|
||||||
timeStr = getTimeStr()
|
timeStr = getTimeStr()
|
||||||
|
|
||||||
|
|
@ -80,7 +80,6 @@ class YSP(var context: Context) {
|
||||||
encryptor!!.encrypt(cnlid, timeStr, appVer, guid, platform)
|
encryptor!!.encrypt(cnlid, timeStr, appVer, guid, platform)
|
||||||
signature = getSignature()
|
signature = getSignature()
|
||||||
return """{"cnlid":"$cnlid","livepid":"$livepid","stream":"$stream","guid":"$guid","cKey":"$cKey","adjust":$adjust,"sphttps":"$sphttps","platform":"$platform","cmd":"$cmd","encryptVer":"$encryptVer","dtype":"$dtype","devid":"$devid","otype":"$otype","appVer":"$appVer","app_version":"$appVersion","rand_str":"$randStr","channel":"$channel","defn":"$defn","signature":"$signature"}"""
|
return """{"cnlid":"$cnlid","livepid":"$livepid","stream":"$stream","guid":"$guid","cKey":"$cKey","adjust":$adjust,"sphttps":"$sphttps","platform":"$platform","cmd":"$cmd","encryptVer":"$encryptVer","dtype":"$dtype","devid":"$devid","otype":"$otype","appVer":"$appVer","app_version":"$appVersion","rand_str":"$randStr","channel":"$channel","defn":"$defn","signature":"$signature"}"""
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getTimeStr(): String {
|
private fun getTimeStr(): String {
|
||||||
|
|
@ -100,7 +99,7 @@ class YSP(var context: Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getGuid(): String {
|
private fun getGuid(): String {
|
||||||
// var guid = sharedPref?.getString("guid", "").toString()
|
var guid = sharedPref?.getString("guid", "").toString()
|
||||||
if (guid == "") {
|
if (guid == "") {
|
||||||
guid = generateGuid()
|
guid = generateGuid()
|
||||||
with(sharedPref!!.edit()) {
|
with(sharedPref!!.edit()) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue