mirror of
https://github.com/lizongying/my-tv.git
synced 2026-11-01 00:56:29 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
353dc0570f | ||
|
|
d7a60531ab |
@@ -14,10 +14,15 @@
|
|||||||
|
|
||||||
## 更新日志
|
## 更新日志
|
||||||
|
|
||||||
|
### v1.5.8(通用版)
|
||||||
|
|
||||||
|
* 修复央视6画质差的问题
|
||||||
|
* 增加兵团卫视
|
||||||
|
* 播放失败重试
|
||||||
|
|
||||||
### v1.5.6(通用版)
|
### v1.5.6(通用版)
|
||||||
|
|
||||||
* 解决部分设备系统时间不对导致播放失败的问题
|
* 解决部分设备系统时间不对导致播放失败的问题
|
||||||
*
|
|
||||||
|
|
||||||
### v1.5.2(通用版)
|
### v1.5.2(通用版)
|
||||||
|
|
||||||
@@ -114,6 +119,7 @@ adb install my-tv.apk
|
|||||||
* 获取系统时间
|
* 获取系统时间
|
||||||
* 选中的图标比例能否相差更大
|
* 选中的图标比例能否相差更大
|
||||||
* 自动重连
|
* 自动重连
|
||||||
|
* 节目增加预告
|
||||||
|
|
||||||
## 赞赏
|
## 赞赏
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -80,6 +80,11 @@ class CardAdapter(private val owner: LifecycleOwner, private var tvListViewModel
|
|||||||
.centerInside()
|
.centerInside()
|
||||||
.into(cardView.mainImageView)
|
.into(cardView.mainImageView)
|
||||||
|
|
||||||
|
"兵团卫视" -> Glide.with(viewHolder.view.context)
|
||||||
|
.load(R.drawable.bingtuan)
|
||||||
|
.centerInside()
|
||||||
|
.into(cardView.mainImageView)
|
||||||
|
|
||||||
else -> Glide.with(viewHolder.view.context)
|
else -> Glide.with(viewHolder.view.context)
|
||||||
.load(tvViewModel.logo.value)
|
.load(tvViewModel.logo.value)
|
||||||
.centerInside()
|
.centerInside()
|
||||||
|
|||||||
@@ -47,6 +47,11 @@ class CardPresenter(
|
|||||||
.centerInside()
|
.centerInside()
|
||||||
.into(cardView.mainImageView)
|
.into(cardView.mainImageView)
|
||||||
|
|
||||||
|
"兵团卫视" -> Glide.with(viewHolder.view.context)
|
||||||
|
.load(R.drawable.bingtuan)
|
||||||
|
.centerInside()
|
||||||
|
.into(cardView.mainImageView)
|
||||||
|
|
||||||
else -> Glide.with(viewHolder.view.context)
|
else -> Glide.with(viewHolder.view.context)
|
||||||
.load(tvViewModel.logo.value)
|
.load(tvViewModel.logo.value)
|
||||||
.centerInside()
|
.centerInside()
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.lizongying.mytv
|
||||||
|
|
||||||
|
import android.app.AlertDialog
|
||||||
|
import android.app.Dialog
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.fragment.app.DialogFragment
|
||||||
|
|
||||||
|
class ConfirmationDialogFragment(private val listener: ConfirmationDialogListener) :
|
||||||
|
DialogFragment() {
|
||||||
|
|
||||||
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
|
return activity?.let {
|
||||||
|
val builder = AlertDialog.Builder(it)
|
||||||
|
builder.setTitle("确认")
|
||||||
|
.setMessage("确认更新吗?")
|
||||||
|
.setPositiveButton(
|
||||||
|
"确定"
|
||||||
|
) { _, _ ->
|
||||||
|
listener.onConfirm()
|
||||||
|
}
|
||||||
|
.setNegativeButton(
|
||||||
|
"取消"
|
||||||
|
) { _, _ ->
|
||||||
|
listener.onCancel()
|
||||||
|
}
|
||||||
|
// 创建并返回 AlertDialog 对象
|
||||||
|
builder.create()
|
||||||
|
} ?: throw IllegalStateException("Activity cannot be null")
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ConfirmationDialogListener {
|
||||||
|
fun onConfirm()
|
||||||
|
fun onCancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -9,6 +9,8 @@ class Encryptor {
|
|||||||
|
|
||||||
external fun hash(data: ByteArray): ByteArray?
|
external fun hash(data: ByteArray): ByteArray?
|
||||||
|
|
||||||
|
external fun hash2(data: ByteArray): ByteArray?
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
init {
|
init {
|
||||||
System.loadLibrary("native")
|
System.loadLibrary("native")
|
||||||
|
|||||||
@@ -43,6 +43,10 @@ class InfoFragment : Fragment() {
|
|||||||
.load(R.drawable.xinjiang)
|
.load(R.drawable.xinjiang)
|
||||||
.into(binding.infoLogo)
|
.into(binding.infoLogo)
|
||||||
|
|
||||||
|
"兵团卫视" -> Glide.with(this)
|
||||||
|
.load(R.drawable.bingtuan)
|
||||||
|
.into(binding.infoLogo)
|
||||||
|
|
||||||
else -> Glide.with(this)
|
else -> Glide.with(this)
|
||||||
.load(tvViewModel.logo.value)
|
.load(tvViewModel.logo.value)
|
||||||
.into(binding.infoLogo)
|
.into(binding.infoLogo)
|
||||||
|
|||||||
@@ -84,8 +84,14 @@ class MainActivity : FragmentActivity() {
|
|||||||
channelReversal = sharedPref.getBoolean(CHANNEL_REVERSAL, channelReversal)
|
channelReversal = sharedPref.getBoolean(CHANNEL_REVERSAL, channelReversal)
|
||||||
channelNum = sharedPref.getBoolean(CHANNEL_NUM, channelNum)
|
channelNum = sharedPref.getBoolean(CHANNEL_NUM, channelNum)
|
||||||
|
|
||||||
versionName = getPackageInfo().versionName
|
val packageInfo = getPackageInfo()
|
||||||
settingFragment = SettingFragment(versionName, channelReversal, channelNum)
|
versionName = packageInfo.versionName
|
||||||
|
val versionCode = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
|
packageInfo.longVersionCode
|
||||||
|
} else {
|
||||||
|
packageInfo.versionCode.toLong()
|
||||||
|
}
|
||||||
|
settingFragment = SettingFragment(versionName, versionCode, channelReversal, channelNum)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showInfoFragment(tvViewModel: TVViewModel) {
|
fun showInfoFragment(tvViewModel: TVViewModel) {
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ class PlayerFragment : Fragment() {
|
|||||||
super.onPlayerError(error)
|
super.onPlayerError(error)
|
||||||
|
|
||||||
Log.e(TAG, "PlaybackException $error")
|
Log.e(TAG, "PlaybackException $error")
|
||||||
|
tvViewModel?.changed()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import android.util.Base64
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.lizongying.mytv.Utils.getDateFormat
|
import com.lizongying.mytv.Utils.getDateFormat
|
||||||
import com.lizongying.mytv.api.ApiClient
|
import com.lizongying.mytv.api.ApiClient
|
||||||
|
import com.lizongying.mytv.api.Auth
|
||||||
|
import com.lizongying.mytv.api.AuthRequest
|
||||||
import com.lizongying.mytv.api.Info
|
import com.lizongying.mytv.api.Info
|
||||||
import com.lizongying.mytv.api.LiveInfo
|
import com.lizongying.mytv.api.LiveInfo
|
||||||
import com.lizongying.mytv.api.LiveInfoRequest
|
import com.lizongying.mytv.api.LiveInfoRequest
|
||||||
@@ -43,54 +45,6 @@ class Request {
|
|||||||
private val input =
|
private val input =
|
||||||
"""{"mver":"1","subver":"1.2","host":"www.yangshipin.cn/#/tv/home?pid=","referer":"","canvas":"YSPANGLE(Apple,ANGLEMetalRenderer:AppleM1Pro,UnspecifiedVersion)"}""".toByteArray()
|
"""{"mver":"1","subver":"1.2","host":"www.yangshipin.cn/#/tv/home?pid=","referer":"","canvas":"YSPANGLE(Apple,ANGLEMetalRenderer:AppleM1Pro,UnspecifiedVersion)"}""".toByteArray()
|
||||||
|
|
||||||
private var mapping = mapOf(
|
|
||||||
"CCTV4K" to "CCTV4K 超高清",
|
|
||||||
"CCTV1" to "CCTV1 综合",
|
|
||||||
"CCTV2" to "CCTV2 财经",
|
|
||||||
"CCTV4" to "CCTV4 中文国际",
|
|
||||||
"CCTV5" to "CCTV5 体育",
|
|
||||||
"CCTV5+" to "CCTV5+ 体育赛事",
|
|
||||||
"CCTV7" to "CCTV7 国防军事",
|
|
||||||
"CCTV9" to "CCTV9 记录",
|
|
||||||
"CCTV10" to "CCTV10 科教",
|
|
||||||
"CCTV11" to "CCTV11 戏曲",
|
|
||||||
"CCTV12" to "CCTV12 社会与法",
|
|
||||||
"CCTV13" to "CCTV13 新闻",
|
|
||||||
"CCTV14" to "CCTV14 少儿",
|
|
||||||
"CCTV15" to "CCTV15 音乐",
|
|
||||||
"CCTV16-HD" to "CCTV16 奥林匹克",
|
|
||||||
"CCTV17" to "CCTV17 农业农村",
|
|
||||||
"CGTN" to "CGTN",
|
|
||||||
"CGTN法语频道" to "CGTN 法语频道",
|
|
||||||
"CGTN俄语频道" to "CGTN 俄语频道",
|
|
||||||
"CGTN阿拉伯语频道" to "CGTN 阿拉伯语频道",
|
|
||||||
"CGTN西班牙语频道" to "CGTN 西班牙语频道",
|
|
||||||
"CGTN外语纪录频道" to "CGTN 纪录频道",
|
|
||||||
"东方卫视" to "东方卫视",
|
|
||||||
"湖南卫视" to "湖南卫视",
|
|
||||||
"湖北卫视" to "湖北卫视",
|
|
||||||
"辽宁卫视" to "辽宁卫视",
|
|
||||||
"江苏卫视" to "江苏卫视",
|
|
||||||
"江西卫视" to "江西卫视",
|
|
||||||
"山东卫视" to "山东卫视",
|
|
||||||
"广东卫视" to "广东卫视",
|
|
||||||
"广西卫视" to "广西卫视",
|
|
||||||
"重庆卫视" to "重庆卫视",
|
|
||||||
"河南卫视" to "河南卫视",
|
|
||||||
"河北卫视" to "河北卫视",
|
|
||||||
"贵州卫视" to "贵州卫视",
|
|
||||||
"北京卫视" to "北京卫视",
|
|
||||||
"黑龙江卫视" to "黑龙江卫视",
|
|
||||||
"浙江卫视" to "浙江卫视",
|
|
||||||
"安徽卫视" to "安徽卫视",
|
|
||||||
"深圳卫视" to "深圳卫视",
|
|
||||||
"四川卫视" to "四川卫视",
|
|
||||||
"福建东南卫视" to "东南卫视",
|
|
||||||
"海南卫视" to "海南卫视",
|
|
||||||
"天津卫视" to "天津卫视",
|
|
||||||
"新疆卫视" to "新疆卫视",
|
|
||||||
)
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
handler.post(tokenRunnable)
|
handler.post(tokenRunnable)
|
||||||
}
|
}
|
||||||
@@ -100,6 +54,84 @@ class Request {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var call: Call<LiveInfo>? = null
|
var call: Call<LiveInfo>? = null
|
||||||
|
var callAuth: Call<Auth>? = null
|
||||||
|
|
||||||
|
private fun fetchAuth(tvModel: TVViewModel, cookie: String) {
|
||||||
|
callAuth?.cancel()
|
||||||
|
|
||||||
|
val title = tvModel.title.value
|
||||||
|
|
||||||
|
val data = ysp?.getAuthData(tvModel)
|
||||||
|
val request = data?.let { AuthRequest(it) }
|
||||||
|
callAuth = request?.let { yspApiService.getAuth("guid=${ysp?.getGuid()}; $cookie", it) }
|
||||||
|
|
||||||
|
callAuth?.enqueue(object : Callback<Auth> {
|
||||||
|
override fun onResponse(call: Call<Auth>, response: Response<Auth>) {
|
||||||
|
if (response.isSuccessful) {
|
||||||
|
val liveInfo = response.body()
|
||||||
|
|
||||||
|
if (liveInfo?.data?.token != null) {
|
||||||
|
Log.i(TAG, "token ${liveInfo.data.token}")
|
||||||
|
ysp?.token = liveInfo.data.token
|
||||||
|
fetchVideo(tvModel, cookie)
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "$title token error")
|
||||||
|
if (tvModel.retryTimes < tvModel.retryMaxTimes) {
|
||||||
|
tvModel.retryTimes++
|
||||||
|
if (tvModel.getTV().needToken) {
|
||||||
|
if (tvModel.tokenRetryTimes == tvModel.tokenRetryMaxTimes) {
|
||||||
|
if (!tvModel.getTV().mustToken) {
|
||||||
|
fetchAuth(tvModel, cookie)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
token = ""
|
||||||
|
fetchAuth(tvModel)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fetchAuth(tvModel, cookie)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "$title auth status error")
|
||||||
|
if (tvModel.retryTimes < tvModel.retryMaxTimes) {
|
||||||
|
tvModel.retryTimes++
|
||||||
|
if (tvModel.getTV().needToken) {
|
||||||
|
if (tvModel.tokenRetryTimes == tvModel.tokenRetryMaxTimes) {
|
||||||
|
if (!tvModel.getTV().mustToken) {
|
||||||
|
fetchAuth(tvModel, cookie)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
token = ""
|
||||||
|
fetchAuth(tvModel)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fetchAuth(tvModel, cookie)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFailure(call: Call<Auth>, t: Throwable) {
|
||||||
|
Log.e(TAG, "$title auth request error $t")
|
||||||
|
if (tvModel.retryTimes < tvModel.retryMaxTimes) {
|
||||||
|
tvModel.retryTimes++
|
||||||
|
if (tvModel.getTV().needToken) {
|
||||||
|
if (tvModel.tokenRetryTimes == tvModel.tokenRetryMaxTimes) {
|
||||||
|
if (!tvModel.getTV().mustToken) {
|
||||||
|
fetchVideo(tvModel, cookie)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
token = ""
|
||||||
|
fetchAuth(tvModel)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fetchAuth(tvModel, cookie)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fun fetchVideo(tvModel: TVViewModel, cookie: String) {
|
fun fetchVideo(tvModel: TVViewModel, cookie: String) {
|
||||||
call?.cancel()
|
call?.cancel()
|
||||||
@@ -112,7 +144,7 @@ class Request {
|
|||||||
tvModel.seq = 0
|
tvModel.seq = 0
|
||||||
val data = ysp?.switch(tvModel)
|
val data = ysp?.switch(tvModel)
|
||||||
val request = data?.let { LiveInfoRequest(it) }
|
val request = data?.let { LiveInfoRequest(it) }
|
||||||
call = request?.let { yspApiService.getLiveInfo("guid=${ysp?.getGuid()}; $cookie", it) }
|
call = request?.let { yspApiService.getLiveInfo("guid=${ysp?.getGuid()}; $cookie", ysp!!.token, it) }
|
||||||
|
|
||||||
call?.enqueue(object : Callback<LiveInfo> {
|
call?.enqueue(object : Callback<LiveInfo> {
|
||||||
override fun onResponse(call: Call<LiveInfo>, response: Response<LiveInfo>) {
|
override fun onResponse(call: Call<LiveInfo>, response: Response<LiveInfo>) {
|
||||||
@@ -223,6 +255,53 @@ class Request {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun fetchAuth(tvModel: TVViewModel) {
|
||||||
|
if (token == "") {
|
||||||
|
yspTokenService.getInfo()
|
||||||
|
.enqueue(object : Callback<Info> {
|
||||||
|
override fun onResponse(call: Call<Info>, response: Response<Info>) {
|
||||||
|
if (response.isSuccessful) {
|
||||||
|
token = response.body()?.data?.token!!
|
||||||
|
Log.i(TAG, "info success $token")
|
||||||
|
val cookie =
|
||||||
|
"versionName=99.99.99; versionCode=999999; vplatform=109; platformVersion=Chrome; deviceModel=120; appid=1400421205; yspappid=519748109;yspopenid=vu0-8lgGV2LW9QjDeuBFsX8yMnzs37Q3_HZF6XyVDpGR_I; vusession=$token"
|
||||||
|
fetchAuth(tvModel, cookie)
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "info status error")
|
||||||
|
if (tvModel.tokenRetryTimes < tvModel.tokenRetryMaxTimes) {
|
||||||
|
tvModel.tokenRetryTimes++
|
||||||
|
fetchAuth(tvModel)
|
||||||
|
} else {
|
||||||
|
if (!tvModel.getTV().mustToken) {
|
||||||
|
val cookie =
|
||||||
|
"versionName=99.99.99; versionCode=999999; vplatform=109; platformVersion=Chrome; deviceModel=120; appid=1400421205; yspappid=519748109"
|
||||||
|
fetchAuth(tvModel, cookie)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFailure(call: Call<Info>, t: Throwable) {
|
||||||
|
Log.e(TAG, "info request error $t")
|
||||||
|
if (tvModel.tokenRetryTimes < tvModel.tokenRetryMaxTimes) {
|
||||||
|
tvModel.tokenRetryTimes++
|
||||||
|
fetchVideo(tvModel)
|
||||||
|
} else {
|
||||||
|
if (!tvModel.getTV().mustToken) {
|
||||||
|
val cookie =
|
||||||
|
"versionName=99.99.99; versionCode=999999; vplatform=109; platformVersion=Chrome; deviceModel=120; appid=1400421205; yspappid=519748109"
|
||||||
|
fetchAuth(tvModel, cookie)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
val cookie =
|
||||||
|
"versionName=99.99.99; versionCode=999999; vplatform=109; platformVersion=Chrome; deviceModel=120; appid=1400421205; yspappid=519748109;yspopenid=vu0-8lgGV2LW9QjDeuBFsX8yMnzs37Q3_HZF6XyVDpGR_I; vusession=$token"
|
||||||
|
fetchAuth(tvModel, cookie)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun fetchVideo(tvModel: TVViewModel) {
|
fun fetchVideo(tvModel: TVViewModel) {
|
||||||
if (token == "") {
|
if (token == "") {
|
||||||
yspTokenService.getInfo()
|
yspTokenService.getInfo()
|
||||||
@@ -232,7 +311,7 @@ class Request {
|
|||||||
token = response.body()?.data?.token!!
|
token = response.body()?.data?.token!!
|
||||||
Log.i(TAG, "info success $token")
|
Log.i(TAG, "info success $token")
|
||||||
val cookie =
|
val cookie =
|
||||||
"versionName=99.99.99; versionCode=999999; vplatform=109; platformVersion=Chrome; deviceModel=120; yspappid=519748109;yspopenid=vu0-8lgGV2LW9QjDeuBFsX8yMnzs37Q3_HZF6XyVDpGR_I; vusession=$token"
|
"versionName=99.99.99; versionCode=999999; vplatform=109; platformVersion=Chrome; deviceModel=120; appid=1400421205; yspappid=519748109;yspopenid=vu0-8lgGV2LW9QjDeuBFsX8yMnzs37Q3_HZF6XyVDpGR_I; vusession=$token"
|
||||||
fetchVideo(tvModel, cookie)
|
fetchVideo(tvModel, cookie)
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "info status error")
|
Log.e(TAG, "info status error")
|
||||||
@@ -242,7 +321,7 @@ class Request {
|
|||||||
} else {
|
} else {
|
||||||
if (!tvModel.getTV().mustToken) {
|
if (!tvModel.getTV().mustToken) {
|
||||||
val cookie =
|
val cookie =
|
||||||
"versionName=99.99.99; versionCode=999999; vplatform=109; platformVersion=Chrome; deviceModel=120; yspappid=519748109"
|
"versionName=99.99.99; versionCode=999999; vplatform=109; platformVersion=Chrome; deviceModel=120; appid=1400421205; yspappid=519748109"
|
||||||
fetchVideo(tvModel, cookie)
|
fetchVideo(tvModel, cookie)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -257,7 +336,7 @@ class Request {
|
|||||||
} else {
|
} else {
|
||||||
if (!tvModel.getTV().mustToken) {
|
if (!tvModel.getTV().mustToken) {
|
||||||
val cookie =
|
val cookie =
|
||||||
"versionName=99.99.99; versionCode=999999; vplatform=109; platformVersion=Chrome; deviceModel=120; yspappid=519748109"
|
"versionName=99.99.99; versionCode=999999; vplatform=109; platformVersion=Chrome; deviceModel=120; appid=1400421205; yspappid=519748109"
|
||||||
fetchVideo(tvModel, cookie)
|
fetchVideo(tvModel, cookie)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -265,18 +344,20 @@ class Request {
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
val cookie =
|
val cookie =
|
||||||
"versionName=99.99.99; versionCode=999999; vplatform=109; platformVersion=Chrome; deviceModel=120; yspappid=519748109;yspopenid=vu0-8lgGV2LW9QjDeuBFsX8yMnzs37Q3_HZF6XyVDpGR_I; vusession=$token"
|
"versionName=99.99.99; versionCode=999999; vplatform=109; platformVersion=Chrome; deviceModel=120; appid=1400421205; yspappid=519748109;yspopenid=vu0-8lgGV2LW9QjDeuBFsX8yMnzs37Q3_HZF6XyVDpGR_I; vusession=$token"
|
||||||
fetchVideo(tvModel, cookie)
|
fetchVideo(tvModel, cookie)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun fetchData(tvModel: TVViewModel) {
|
fun fetchData(tvModel: TVViewModel) {
|
||||||
if (tvModel.getTV().needToken) {
|
if (tvModel.getTV().needToken) {
|
||||||
fetchVideo(tvModel)
|
// fetchVideo(tvModel)
|
||||||
|
fetchAuth(tvModel)
|
||||||
} else {
|
} else {
|
||||||
val cookie =
|
val cookie =
|
||||||
"versionName=99.99.99; versionCode=999999; vplatform=109; platformVersion=Chrome; deviceModel=120; yspappid=519748109"
|
"versionName=99.99.99; versionCode=999999; vplatform=109; platformVersion=Chrome; deviceModel=120; appid=1400421205"
|
||||||
fetchVideo(tvModel, cookie)
|
// fetchVideo(tvModel, cookie)
|
||||||
|
fetchAuth(tvModel, cookie)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,28 @@
|
|||||||
package com.lizongying.mytv
|
package com.lizongying.mytv
|
||||||
|
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import com.lizongying.mytv.databinding.DialogBinding
|
import com.lizongying.mytv.databinding.DialogBinding
|
||||||
|
|
||||||
|
|
||||||
class SettingFragment(private val versionName: String,
|
class SettingFragment(
|
||||||
private val channelReversal: Boolean,
|
private val versionName: String,
|
||||||
private val channelNum: Boolean,
|
private val versionCode: Long,
|
||||||
) :
|
private val channelReversal: Boolean,
|
||||||
|
private val channelNum: Boolean,
|
||||||
|
) :
|
||||||
DialogFragment() {
|
DialogFragment() {
|
||||||
|
|
||||||
private var _binding: DialogBinding? = null
|
private var _binding: DialogBinding? = null
|
||||||
private val binding get() = _binding!!
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
|
private lateinit var updateManager: UpdateManager
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setStyle(STYLE_NO_TITLE, 0)
|
setStyle(STYLE_NO_TITLE, 0)
|
||||||
@@ -43,14 +49,33 @@ class SettingFragment(private val versionName: String,
|
|||||||
(activity as MainActivity).saveChannelNum(isChecked)
|
(activity as MainActivity).saveChannelNum(isChecked)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateManager = UpdateManager(context, this, versionCode)
|
||||||
|
_binding?.checkVersion?.setOnClickListener(OnClickListenerCheckVersion(updateManager))
|
||||||
|
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setVersionName(versionName: String) {
|
||||||
|
binding.versionName.text = versionName
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class OnClickListenerCheckVersion(private val updateManager: UpdateManager) :
|
||||||
|
View.OnClickListener {
|
||||||
|
override fun onClick(view: View?) {
|
||||||
|
updateManager.checkAndUpdate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
_binding = null
|
_binding = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
// updateManager.destroy()
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "SettingFragment"
|
const val TAG = "SettingFragment"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,8 +84,8 @@ object TVList {
|
|||||||
0,
|
0,
|
||||||
"央视频道",
|
"央视频道",
|
||||||
"https://resources.yangshipin.cn/assets/oms/image/202306/741515efda91f03f455df8a7da4ee11fa9329139c276435cf0a9e2af398d5bf2.png?imageMogr2/format/webp",
|
"https://resources.yangshipin.cn/assets/oms/image/202306/741515efda91f03f455df8a7da4ee11fa9329139c276435cf0a9e2af398d5bf2.png?imageMogr2/format/webp",
|
||||||
"600001802",
|
"600108442",
|
||||||
"2022574301",
|
"2013693901",
|
||||||
"600001802",
|
"600001802",
|
||||||
true,
|
true,
|
||||||
mustToken = true
|
mustToken = true
|
||||||
@@ -852,10 +852,24 @@ object TVList {
|
|||||||
true,
|
true,
|
||||||
mustToken = false
|
mustToken = false
|
||||||
),
|
),
|
||||||
|
TV(
|
||||||
|
56,
|
||||||
|
"兵团卫视",
|
||||||
|
"兵团卫视",
|
||||||
|
listOf(),
|
||||||
|
0,
|
||||||
|
"地方频道",
|
||||||
|
"",
|
||||||
|
"600170344",
|
||||||
|
"2022606701",
|
||||||
|
"",
|
||||||
|
true,
|
||||||
|
mustToken = false
|
||||||
|
),
|
||||||
),
|
),
|
||||||
"国际频道" to listOf(
|
"国际频道" to listOf(
|
||||||
TV(
|
TV(
|
||||||
56,
|
57,
|
||||||
"CGTN",
|
"CGTN",
|
||||||
"CGTN",
|
"CGTN",
|
||||||
listOf("http://live.cgtn.com/1000/prog_index.m3u8"),
|
listOf("http://live.cgtn.com/1000/prog_index.m3u8"),
|
||||||
@@ -869,7 +883,7 @@ object TVList {
|
|||||||
mustToken = false
|
mustToken = false
|
||||||
),
|
),
|
||||||
TV(
|
TV(
|
||||||
57,
|
58,
|
||||||
"CGTN 法语频道",
|
"CGTN 法语频道",
|
||||||
"CGTN法语频道",
|
"CGTN法语频道",
|
||||||
listOf("https://livefr.cgtn.com/1000f/prog_index.m3u8"),
|
listOf("https://livefr.cgtn.com/1000f/prog_index.m3u8"),
|
||||||
@@ -883,7 +897,7 @@ object TVList {
|
|||||||
mustToken = false
|
mustToken = false
|
||||||
),
|
),
|
||||||
TV(
|
TV(
|
||||||
58,
|
59,
|
||||||
"CGTN 俄语频道",
|
"CGTN 俄语频道",
|
||||||
"CGTN俄语频道",
|
"CGTN俄语频道",
|
||||||
listOf("http://liveru.cgtn.com/1000r/prog_index.m3u8"),
|
listOf("http://liveru.cgtn.com/1000r/prog_index.m3u8"),
|
||||||
@@ -897,7 +911,7 @@ object TVList {
|
|||||||
mustToken = false
|
mustToken = false
|
||||||
),
|
),
|
||||||
TV(
|
TV(
|
||||||
59,
|
60,
|
||||||
"CGTN 阿拉伯语频道",
|
"CGTN 阿拉伯语频道",
|
||||||
"CGTN阿拉伯语频道",
|
"CGTN阿拉伯语频道",
|
||||||
listOf("http://livear.cgtn.com/1000a/prog_index.m3u8"),
|
listOf("http://livear.cgtn.com/1000a/prog_index.m3u8"),
|
||||||
@@ -911,7 +925,7 @@ object TVList {
|
|||||||
mustToken = false
|
mustToken = false
|
||||||
),
|
),
|
||||||
TV(
|
TV(
|
||||||
60,
|
61,
|
||||||
"CGTN 西班牙语频道",
|
"CGTN 西班牙语频道",
|
||||||
"CGTN西班牙语频道",
|
"CGTN西班牙语频道",
|
||||||
listOf(
|
listOf(
|
||||||
@@ -928,7 +942,7 @@ object TVList {
|
|||||||
mustToken = false
|
mustToken = false
|
||||||
),
|
),
|
||||||
TV(
|
TV(
|
||||||
61,
|
62,
|
||||||
"CGTN 纪录频道",
|
"CGTN 纪录频道",
|
||||||
"CGTN外语纪录频道",
|
"CGTN外语纪录频道",
|
||||||
listOf("https://livedoc.cgtn.com/500d/prog_index.m3u8"),
|
listOf("https://livedoc.cgtn.com/500d/prog_index.m3u8"),
|
||||||
|
|||||||
@@ -6,11 +6,14 @@ import android.content.BroadcastReceiver
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
|
import android.database.Cursor
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.annotation.RequiresApi
|
import android.widget.Toast
|
||||||
import com.lizongying.mytv.api.Release
|
import com.lizongying.mytv.api.Release
|
||||||
import com.lizongying.mytv.requests.MyRequest
|
import com.lizongying.mytv.requests.MyRequest
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
@@ -19,37 +22,54 @@ import kotlinx.coroutines.launch
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
|
||||||
class UpdateManager(private var context: Context?) {
|
class UpdateManager(
|
||||||
|
private var context: Context?,
|
||||||
|
private var settingFragment: SettingFragment,
|
||||||
|
private var versionCode: Long
|
||||||
|
) :
|
||||||
|
ConfirmationDialogFragment.ConfirmationDialogListener {
|
||||||
|
|
||||||
private var myRequest = MyRequest()
|
private var myRequest = MyRequest()
|
||||||
|
private var release: Release? = null
|
||||||
|
|
||||||
|
private var downloadReceiver: DownloadReceiver? = null
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
|
||||||
fun checkAndUpdate() {
|
fun checkAndUpdate() {
|
||||||
CoroutineScope(Dispatchers.Main).launch {
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
try {
|
try {
|
||||||
val release = myRequest.getRelease()
|
release = myRequest.getRelease()
|
||||||
// 在主线程中更新 UI
|
|
||||||
updateUI(release)
|
updateUI(release)
|
||||||
if (release?.data?.versionCode!! > 0) {
|
Log.i(TAG, "versionCode $versionCode ${release?.data?.versionCode}")
|
||||||
startDownload(release)
|
if (release != null) {
|
||||||
|
if (release?.data?.versionCode!! >= versionCode) {
|
||||||
|
val dialog = ConfirmationDialogFragment(this@UpdateManager)
|
||||||
|
dialog.show(settingFragment.fragmentManager, "ConfirmationDialogFragment")
|
||||||
|
} else {
|
||||||
|
Toast.makeText(context, "不需要更新", Toast.LENGTH_LONG)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
// 处理异常情况
|
|
||||||
Log.e(TAG, "Error occurred: ${e.message}", e)
|
Log.e(TAG, "Error occurred: ${e.message}", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateUI(release: Release?) {
|
private fun updateUI(release: Release?) {
|
||||||
|
if (release?.data?.versionName.isNullOrEmpty()) {
|
||||||
|
settingFragment.setVersionName("版本获取失败")
|
||||||
|
} else {
|
||||||
|
settingFragment.setVersionName("最新版本:${release?.data?.versionName!!}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
|
||||||
private fun startDownload(release: Release) {
|
private fun startDownload(release: Release) {
|
||||||
val apkFileName = "my-tv-${release.data.versionName}.apk"
|
val apkFileName = "my-tv-${release.data.versionName}.apk"
|
||||||
|
Log.i(TAG, "apkFileName $apkFileName")
|
||||||
val downloadManager =
|
val downloadManager =
|
||||||
context!!.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
|
context!!.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
|
||||||
val request = Request(Uri.parse(release.data.downloadUrl))
|
val request = Request(Uri.parse(release.data.downloadUrl))
|
||||||
|
Log.i(TAG, "url ${Uri.parse(release.data.downloadUrl)}")
|
||||||
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, apkFileName)
|
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, apkFileName)
|
||||||
request.setTitle("New Version Download")
|
request.setTitle("New Version Download")
|
||||||
request.setNotificationVisibility(Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
request.setNotificationVisibility(Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
||||||
@@ -57,13 +77,63 @@ class UpdateManager(private var context: Context?) {
|
|||||||
// 获取下载任务的引用
|
// 获取下载任务的引用
|
||||||
val downloadReference = downloadManager.enqueue(request)
|
val downloadReference = downloadManager.enqueue(request)
|
||||||
|
|
||||||
// 注册广播接收器,监听下载完成事件
|
downloadReceiver = DownloadReceiver(context!!, apkFileName, downloadReference)
|
||||||
context!!.registerReceiver(
|
|
||||||
DownloadReceiver(context!!, apkFileName, downloadReference),
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE), Context.RECEIVER_NOT_EXPORTED
|
context!!.registerReceiver(
|
||||||
)
|
downloadReceiver,
|
||||||
|
IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE),
|
||||||
|
Context.RECEIVER_NOT_EXPORTED,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
context!!.registerReceiver(
|
||||||
|
downloadReceiver,
|
||||||
|
IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
getDownloadProgress(context!!, downloadReference) { progress ->
|
||||||
|
println("Download progress: $progress%")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getDownloadProgress(context: Context, downloadId: Long, progressListener: (Int) -> Unit) {
|
||||||
|
val downloadManager = context.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
|
||||||
|
val handler = Handler(Looper.getMainLooper())
|
||||||
|
val intervalMillis: Long = 1000
|
||||||
|
|
||||||
|
handler.post(object : Runnable {
|
||||||
|
override fun run() {
|
||||||
|
Log.i(TAG, "search")
|
||||||
|
val query = DownloadManager.Query().setFilterById(downloadId)
|
||||||
|
val cursor: Cursor = downloadManager.query(query)
|
||||||
|
cursor.use {
|
||||||
|
if (it.moveToFirst()) {
|
||||||
|
val bytesDownloadedIndex =
|
||||||
|
it.getColumnIndex(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR)
|
||||||
|
val bytesTotalIndex =
|
||||||
|
it.getColumnIndex(DownloadManager.COLUMN_TOTAL_SIZE_BYTES)
|
||||||
|
|
||||||
|
// 检查列名是否存在
|
||||||
|
if (bytesDownloadedIndex != -1 && bytesTotalIndex != -1) {
|
||||||
|
val bytesDownloaded = it.getInt(bytesDownloadedIndex)
|
||||||
|
val bytesTotal = it.getInt(bytesTotalIndex)
|
||||||
|
|
||||||
|
if (bytesTotal != -1) {
|
||||||
|
val progress = (bytesDownloaded * 100L / bytesTotal).toInt()
|
||||||
|
progressListener(progress)
|
||||||
|
if (progress == 100) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// handler.postDelayed(this, intervalMillis)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
private class DownloadReceiver(
|
private class DownloadReceiver(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
@@ -72,6 +142,9 @@ class UpdateManager(private var context: Context?) {
|
|||||||
) : BroadcastReceiver() {
|
) : BroadcastReceiver() {
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
val reference = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1)
|
val reference = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1)
|
||||||
|
Log.i(TAG, "reference $reference")
|
||||||
|
val progress = intent.getIntExtra("progress", 0)
|
||||||
|
Log.i(TAG, "progress $progress")
|
||||||
|
|
||||||
// 检查是否是我们发起的下载
|
// 检查是否是我们发起的下载
|
||||||
if (reference == downloadReference) {
|
if (reference == downloadReference) {
|
||||||
@@ -94,8 +167,23 @@ class UpdateManager(private var context: Context?) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "UpdateManager"
|
private const val TAG = "UpdateManager"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onConfirm() {
|
||||||
|
Log.i(TAG, "onConfirm $release")
|
||||||
|
release?.let { startDownload(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCancel() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun destroy() {
|
||||||
|
if (downloadReceiver != null) {
|
||||||
|
context!!.unregisterReceiver(downloadReceiver)
|
||||||
|
Log.i(TAG, "destroy downloadReceiver")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,8 @@ import okhttp3.OkHttpClient
|
|||||||
import retrofit2.Retrofit
|
import retrofit2.Retrofit
|
||||||
import retrofit2.converter.gson.GsonConverterFactory
|
import retrofit2.converter.gson.GsonConverterFactory
|
||||||
import retrofit2.converter.protobuf.ProtoConverterFactory
|
import retrofit2.converter.protobuf.ProtoConverterFactory
|
||||||
|
import java.net.InetSocketAddress
|
||||||
|
import java.net.Proxy
|
||||||
import javax.net.ssl.SSLContext
|
import javax.net.ssl.SSLContext
|
||||||
import javax.net.ssl.TrustManager
|
import javax.net.ssl.TrustManager
|
||||||
import javax.net.ssl.X509TrustManager
|
import javax.net.ssl.X509TrustManager
|
||||||
@@ -13,9 +15,11 @@ import javax.net.ssl.X509TrustManager
|
|||||||
class ApiClient {
|
class ApiClient {
|
||||||
private val yspUrl = "https://player-api.yangshipin.cn/"
|
private val yspUrl = "https://player-api.yangshipin.cn/"
|
||||||
private val myUrl = "https://lyrics.run/"
|
private val myUrl = "https://lyrics.run/"
|
||||||
|
private val devUrl = "http://10.0.2.2:8081/"
|
||||||
private val protoUrl = "https://capi.yangshipin.cn/"
|
private val protoUrl = "https://capi.yangshipin.cn/"
|
||||||
private val traceUrl = "https://btrace.yangshipin.cn/"
|
private val traceUrl = "https://btrace.yangshipin.cn/"
|
||||||
|
|
||||||
|
|
||||||
private var okHttpClient = getUnsafeOkHttpClient()
|
private var okHttpClient = getUnsafeOkHttpClient()
|
||||||
|
|
||||||
val yspApiService: YSPApiService by lazy {
|
val yspApiService: YSPApiService by lazy {
|
||||||
@@ -34,9 +38,9 @@ class ApiClient {
|
|||||||
.build().create(YSPTokenService::class.java)
|
.build().create(YSPTokenService::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
val ReleaseService by lazy {
|
val releaseService: ReleaseService by lazy {
|
||||||
Retrofit.Builder()
|
Retrofit.Builder()
|
||||||
.baseUrl(myUrl)
|
.baseUrl(devUrl)
|
||||||
.client(okHttpClient)
|
.client(okHttpClient)
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
.build().create(ReleaseService::class.java)
|
.build().create(ReleaseService::class.java)
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.lizongying.mytv.api
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
|
import okhttp3.MediaType
|
||||||
|
import okhttp3.RequestBody
|
||||||
|
import okio.BufferedSink
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
|
data class Auth(
|
||||||
|
val code: Int,
|
||||||
|
val msg: String,
|
||||||
|
val data: AuthData,
|
||||||
|
)
|
||||||
|
|
||||||
|
data class AuthData(
|
||||||
|
val token: String,
|
||||||
|
)
|
||||||
|
|
||||||
|
data class AuthRequest(
|
||||||
|
var data: String,
|
||||||
|
) : RequestBody() {
|
||||||
|
override fun contentType(): MediaType? {
|
||||||
|
return MediaType.parse("application/x-www-form-urlencoded;charset=UTF-8")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun writeTo(sink: BufferedSink) {
|
||||||
|
try {
|
||||||
|
sink.writeUtf8(data)
|
||||||
|
} catch (e: IOException) {
|
||||||
|
Log.e(TAG, "$e")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val TAG = "AuthRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -50,6 +50,9 @@ class YSP(var context: Context) {
|
|||||||
|
|
||||||
private var signature = ""
|
private var signature = ""
|
||||||
|
|
||||||
|
private var appid = "ysp_pc"
|
||||||
|
var token = ""
|
||||||
|
|
||||||
private var encryptor: Encryptor? = null
|
private var encryptor: Encryptor? = null
|
||||||
private lateinit var sharedPref: SharedPreferences
|
private lateinit var sharedPref: SharedPreferences
|
||||||
|
|
||||||
@@ -83,6 +86,19 @@ class YSP(var context: Context) {
|
|||||||
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"}"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getAuthData(tvModel: TVViewModel): String {
|
||||||
|
livepid = tvModel.pid.value!!
|
||||||
|
|
||||||
|
randStr = getRand()
|
||||||
|
|
||||||
|
if (tvModel.retryTimes > 0) {
|
||||||
|
guid = newGuid()
|
||||||
|
}
|
||||||
|
|
||||||
|
signature = getAuthSignature()
|
||||||
|
return """pid=$livepid&guid=$guid&appid=$appid&rand_str=$randStr&signature=$signature"""
|
||||||
|
}
|
||||||
|
|
||||||
private fun getTimeStr(): String {
|
private fun getTimeStr(): String {
|
||||||
return getDateTimestamp().toString()
|
return getDateTimestamp().toString()
|
||||||
}
|
}
|
||||||
@@ -131,6 +147,13 @@ class YSP(var context: Context) {
|
|||||||
return hashedData.let { it -> it.joinToString("") { "%02x".format(it) } }
|
return hashedData.let { it -> it.joinToString("") { "%02x".format(it) } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getAuthSignature(): String {
|
||||||
|
val e =
|
||||||
|
"appid=${appid}&guid=${guid}&pid=${livepid}&rand_str=${randStr}".toByteArray()
|
||||||
|
val hashedData = encryptor?.hash2(e) ?: return ""
|
||||||
|
return hashedData.let { it -> it.joinToString("") { "%02x".format(it) } }
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "YSP"
|
private const val TAG = "YSP"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,23 @@ interface YSPApiService {
|
|||||||
"content-type: application/json;charset=UTF-8",
|
"content-type: application/json;charset=UTF-8",
|
||||||
"referer: https://www.yangshipin.cn/",
|
"referer: https://www.yangshipin.cn/",
|
||||||
"yspappid: 519748109",
|
"yspappid: 519748109",
|
||||||
|
"user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
||||||
)
|
)
|
||||||
fun getLiveInfo(
|
fun getLiveInfo(
|
||||||
@Header("cookie") cookie: String,
|
@Header("cookie") cookie: String,
|
||||||
|
@Header("Yspplayertoken") token: String,
|
||||||
@Body request: LiveInfoRequest,
|
@Body request: LiveInfoRequest,
|
||||||
): Call<LiveInfo>
|
): Call<LiveInfo>
|
||||||
|
|
||||||
|
@POST("v1/player/auth")
|
||||||
|
@Headers(
|
||||||
|
"content-type: application/x-www-form-urlencoded;charset=UTF-8",
|
||||||
|
"referer: https://www.yangshipin.cn/",
|
||||||
|
"yspappid: 519748109",
|
||||||
|
"user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
||||||
|
)
|
||||||
|
fun getAuth(
|
||||||
|
@Header("cookie") cookie: String,
|
||||||
|
@Body request: AuthRequest,
|
||||||
|
): Call<Auth>
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ import kotlin.coroutines.resume
|
|||||||
import kotlin.coroutines.suspendCoroutine
|
import kotlin.coroutines.suspendCoroutine
|
||||||
|
|
||||||
class MyRequest {
|
class MyRequest {
|
||||||
private var releaseService = ApiClient().ReleaseService
|
private var releaseService = ApiClient().releaseService
|
||||||
|
|
||||||
suspend fun getRelease(): Release? {
|
suspend fun getRelease(): Release? {
|
||||||
return withContext(Dispatchers.IO) {
|
return withContext(Dispatchers.IO) {
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
@@ -27,7 +27,31 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:text="当前版本: $versionName\n获取最新: https://github.com/lizongying/my-tv/releases/"
|
android:text="当前版本: $versionName\n获取最新: https://github.com/lizongying/my-tv/releases/"
|
||||||
></TextView>
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
android:id="@+id/check_version"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="10dp"
|
||||||
|
android:text="@string/check_version"
|
||||||
|
/>
|
||||||
|
<ProgressBar
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/version_name"
|
||||||
|
android:text=""
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<Switch
|
<Switch
|
||||||
android:id="@+id/switch_channel_reversal"
|
android:id="@+id/switch_channel_reversal"
|
||||||
android:text="@string/title_channel_reversal"
|
android:text="@string/title_channel_reversal"
|
||||||
|
|||||||
@@ -2,4 +2,5 @@
|
|||||||
<string name="app_name">我的电视</string>
|
<string name="app_name">我的电视</string>
|
||||||
<string name="title_channel_reversal">换台反转</string>
|
<string name="title_channel_reversal">换台反转</string>
|
||||||
<string name="title_channel_num">数字选台</string>
|
<string name="title_channel_num">数字选台</string>
|
||||||
|
<string name="check_version">检查更新</string>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user