mirror of
https://github.com/lizongying/my-tv.git
synced 2026-10-27 14:46:30 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af9ff5c8dd | ||
|
|
f0f43e0fda | ||
|
|
61f62121f2 |
@@ -33,6 +33,9 @@ jobs:
|
|||||||
signingKeyBase64: ${{ secrets.KEYSTORE }}
|
signingKeyBase64: ${{ secrets.KEYSTORE }}
|
||||||
keyStorePassword: ${{ secrets.KEYSTORE_PASSWORD }}
|
keyStorePassword: ${{ secrets.KEYSTORE_PASSWORD }}
|
||||||
keyPassword: ${{ secrets.ALIAS_PASSWORD }}
|
keyPassword: ${{ secrets.ALIAS_PASSWORD }}
|
||||||
|
env:
|
||||||
|
# override default build-tools version (29.0.3) -- optional
|
||||||
|
BUILD_TOOLS_VERSION: "30.0.2"
|
||||||
|
|
||||||
- name: Create Release
|
- name: Create Release
|
||||||
id: create_release
|
id: create_release
|
||||||
|
|||||||
@@ -14,6 +14,11 @@
|
|||||||
|
|
||||||
## 更新日志
|
## 更新日志
|
||||||
|
|
||||||
|
### v1.3.3
|
||||||
|
|
||||||
|
* 部分错误会提示用户
|
||||||
|
* 菜单3秒钟后自动关闭
|
||||||
|
|
||||||
### v1.3.2
|
### v1.3.2
|
||||||
|
|
||||||
* 增加重试,减少因网络问题导致的播放失败
|
* 增加重试,减少因网络问题导致的播放失败
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ class MainActivity : FragmentActivity() {
|
|||||||
|
|
||||||
private lateinit var gestureDetector: GestureDetector
|
private lateinit var gestureDetector: GestureDetector
|
||||||
|
|
||||||
|
private val handler = Handler()
|
||||||
|
private val delay: Long = 3000
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
@@ -86,6 +89,7 @@ class MainActivity : FragmentActivity() {
|
|||||||
|
|
||||||
if (mainFragment.isHidden) {
|
if (mainFragment.isHidden) {
|
||||||
transaction.show(mainFragment)
|
transaction.show(mainFragment)
|
||||||
|
keepRunnable()
|
||||||
} else {
|
} else {
|
||||||
transaction.hide(mainFragment)
|
transaction.hide(mainFragment)
|
||||||
}
|
}
|
||||||
@@ -93,6 +97,15 @@ class MainActivity : FragmentActivity() {
|
|||||||
transaction.commit()
|
transaction.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun keepRunnable() {
|
||||||
|
handler.removeCallbacks(hideRunnable)
|
||||||
|
handler.postDelayed(hideRunnable, delay)
|
||||||
|
}
|
||||||
|
|
||||||
|
private val hideRunnable = Runnable {
|
||||||
|
supportFragmentManager.beginTransaction().hide(mainFragment).commit()
|
||||||
|
}
|
||||||
|
|
||||||
private fun mainFragmentIsHidden(): Boolean {
|
private fun mainFragmentIsHidden(): Boolean {
|
||||||
return mainFragment.isHidden
|
return mainFragment.isHidden
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import android.os.Bundle
|
|||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.leanback.app.BrowseSupportFragment
|
import androidx.leanback.app.BrowseSupportFragment
|
||||||
import androidx.leanback.widget.ArrayObjectAdapter
|
import androidx.leanback.widget.ArrayObjectAdapter
|
||||||
import androidx.leanback.widget.HeaderItem
|
import androidx.leanback.widget.HeaderItem
|
||||||
@@ -63,6 +64,13 @@ class MainFragment : BrowseSupportFragment() {
|
|||||||
handler.post(mUpdateProgramRunnable)
|
handler.post(mUpdateProgramRunnable)
|
||||||
|
|
||||||
tvListViewModel.getTVListViewModel().value?.forEach { tvViewModel ->
|
tvListViewModel.getTVListViewModel().value?.forEach { tvViewModel ->
|
||||||
|
tvViewModel.errInfo.observe(viewLifecycleOwner) { _ ->
|
||||||
|
if (tvViewModel.errInfo.value != null
|
||||||
|
&& tvViewModel.id.value == itemPosition
|
||||||
|
) {
|
||||||
|
Toast.makeText(context, tvViewModel.errInfo.value, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
tvViewModel.ready.observe(viewLifecycleOwner) { _ ->
|
tvViewModel.ready.observe(viewLifecycleOwner) { _ ->
|
||||||
|
|
||||||
// not first time && channel not change
|
// not first time && channel not change
|
||||||
@@ -305,6 +313,7 @@ class MainFragment : BrowseSupportFragment() {
|
|||||||
) {
|
) {
|
||||||
if (item is TVViewModel) {
|
if (item is TVViewModel) {
|
||||||
tvListViewModel.setItemPositionCurrent(item.id.value!!)
|
tvListViewModel.setItemPositionCurrent(item.id.value!!)
|
||||||
|
(activity as MainActivity).keepRunnable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,9 @@ 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.BtraceClient
|
|
||||||
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
|
||||||
import com.lizongying.mytv.api.ProtoClient
|
|
||||||
import com.lizongying.mytv.api.YSP
|
import com.lizongying.mytv.api.YSP
|
||||||
import com.lizongying.mytv.api.YSPApiService
|
import com.lizongying.mytv.api.YSPApiService
|
||||||
import com.lizongying.mytv.api.YSPBtraceService
|
import com.lizongying.mytv.api.YSPBtraceService
|
||||||
@@ -31,8 +29,8 @@ import javax.crypto.spec.SecretKeySpec
|
|||||||
class Request {
|
class Request {
|
||||||
private var yspTokenService: YSPTokenService = ApiClient().yspTokenService
|
private var yspTokenService: YSPTokenService = ApiClient().yspTokenService
|
||||||
private var yspApiService: YSPApiService = ApiClient().yspApiService
|
private var yspApiService: YSPApiService = ApiClient().yspApiService
|
||||||
private var yspBtraceService: YSPBtraceService = BtraceClient().yspBtraceService
|
private var yspBtraceService: YSPBtraceService = ApiClient().yspBtraceService
|
||||||
private var yspProtoService: YSPProtoService = ProtoClient().yspProtoService
|
private var yspProtoService: YSPProtoService = ApiClient().yspProtoService
|
||||||
private var ysp: YSP? = null
|
private var ysp: YSP? = null
|
||||||
|
|
||||||
// TODO onDestroy
|
// TODO onDestroy
|
||||||
@@ -62,7 +60,6 @@ class Request {
|
|||||||
"CGTN阿拉伯语频道" to "CGTN 阿拉伯语频道",
|
"CGTN阿拉伯语频道" to "CGTN 阿拉伯语频道",
|
||||||
"CGTN西班牙语频道" to "CGTN 西班牙语频道",
|
"CGTN西班牙语频道" to "CGTN 西班牙语频道",
|
||||||
"CGTN外语纪录频道" to "CGTN 纪录频道",
|
"CGTN外语纪录频道" to "CGTN 纪录频道",
|
||||||
|
|
||||||
"东方卫视" to "东方卫视",
|
"东方卫视" to "东方卫视",
|
||||||
"湖南卫视" to "湖南卫视",
|
"湖南卫视" to "湖南卫视",
|
||||||
"湖北卫视" to "湖北卫视",
|
"湖北卫视" to "湖北卫视",
|
||||||
@@ -86,8 +83,6 @@ class Request {
|
|||||||
"海南卫视" to "海南卫视",
|
"海南卫视" to "海南卫视",
|
||||||
)
|
)
|
||||||
|
|
||||||
private var token: String? = null
|
|
||||||
|
|
||||||
fun initYSP(context: Context) {
|
fun initYSP(context: Context) {
|
||||||
ysp = YSP(context)
|
ysp = YSP(context)
|
||||||
}
|
}
|
||||||
@@ -135,21 +130,26 @@ class Request {
|
|||||||
Log.e(TAG, "$title key error")
|
Log.e(TAG, "$title key error")
|
||||||
if (tvModel.retryTimes < tvModel.retryMaxTimes) {
|
if (tvModel.retryTimes < tvModel.retryMaxTimes) {
|
||||||
tvModel.retryTimes++
|
tvModel.retryTimes++
|
||||||
fetchData(tvModel)
|
fetchVideo(tvModel, cookie)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "$title url error $request")
|
if (liveInfo?.data?.errinfo != null && liveInfo.data.errinfo == "应版权方要求,暂停提供直播信号,请点击观看其他精彩节目") {
|
||||||
if (tvModel.retryTimes < tvModel.retryMaxTimes) {
|
Log.e(TAG, "$title error ${liveInfo.data.errinfo}")
|
||||||
tvModel.retryTimes++
|
tvModel.setErrInfo(liveInfo.data.errinfo)
|
||||||
fetchData(tvModel)
|
} else {
|
||||||
|
Log.e(TAG, "$title url error $request $liveInfo")
|
||||||
|
if (tvModel.retryTimes < tvModel.retryMaxTimes) {
|
||||||
|
tvModel.retryTimes++
|
||||||
|
fetchVideo(tvModel, cookie)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "$title status error")
|
Log.e(TAG, "$title status error")
|
||||||
if (tvModel.retryTimes < tvModel.retryMaxTimes) {
|
if (tvModel.retryTimes < tvModel.retryMaxTimes) {
|
||||||
tvModel.retryTimes++
|
tvModel.retryTimes++
|
||||||
fetchData(tvModel)
|
fetchVideo(tvModel, cookie)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,61 +158,47 @@ class Request {
|
|||||||
Log.e(TAG, "$title request error")
|
Log.e(TAG, "$title request error")
|
||||||
if (tvModel.retryTimes < tvModel.retryMaxTimes) {
|
if (tvModel.retryTimes < tvModel.retryMaxTimes) {
|
||||||
tvModel.retryTimes++
|
tvModel.retryTimes++
|
||||||
fetchData(tvModel)
|
fetchVideo(tvModel, cookie)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun fetchVideo(tvModel: TVViewModel) {
|
||||||
|
yspTokenService.getInfo()
|
||||||
|
.enqueue(object : Callback<Info> {
|
||||||
|
override fun onResponse(call: Call<Info>, response: Response<Info>) {
|
||||||
|
if (response.isSuccessful) {
|
||||||
|
val info = response.body()
|
||||||
|
val token = info?.data?.token
|
||||||
|
Log.i(TAG, "info success $token")
|
||||||
|
val cookie =
|
||||||
|
"guid=1; vplatform=109; yspopenid=vu0-8lgGV2LW9QjDeuBFsX8yMnzs37Q3_HZF6XyVDpGR_I; vusession=$token"
|
||||||
|
fetchVideo(tvModel, cookie)
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "info status error")
|
||||||
|
if (tvModel.retryTimes < tvModel.retryMaxTimes) {
|
||||||
|
tvModel.retryTimes++
|
||||||
|
fetchVideo(tvModel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFailure(call: Call<Info>, t: Throwable) {
|
||||||
|
Log.e(TAG, "info request error $t")
|
||||||
|
if (tvModel.retryTimes < tvModel.retryMaxTimes) {
|
||||||
|
tvModel.retryTimes++
|
||||||
|
fetchVideo(tvModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fun fetchData(tvModel: TVViewModel) {
|
fun fetchData(tvModel: TVViewModel) {
|
||||||
var cookie = "guid=1; vplatform=109"
|
if (tvModel.needToken) {
|
||||||
val channels = arrayOf(
|
fetchVideo(tvModel)
|
||||||
"CCTV3 综艺",
|
|
||||||
"CCTV6 电影",
|
|
||||||
"CCTV8 电视剧",
|
|
||||||
"风云剧场",
|
|
||||||
"第一剧场",
|
|
||||||
"怀旧剧场",
|
|
||||||
"世界地理",
|
|
||||||
"风云音乐",
|
|
||||||
"兵器科技",
|
|
||||||
"风云足球",
|
|
||||||
"高尔夫网球",
|
|
||||||
"女性时尚",
|
|
||||||
"央视文化精品",
|
|
||||||
"央视台球",
|
|
||||||
"电视指南",
|
|
||||||
"卫生健康",
|
|
||||||
)
|
|
||||||
if (tvModel.title.value in channels) {
|
|
||||||
yspTokenService.getInfo()
|
|
||||||
.enqueue(object : Callback<Info> {
|
|
||||||
override fun onResponse(call: Call<Info>, response: Response<Info>) {
|
|
||||||
if (response.isSuccessful) {
|
|
||||||
val info = response.body()
|
|
||||||
token = info?.data?.token
|
|
||||||
Log.i(TAG, "info success $token")
|
|
||||||
cookie =
|
|
||||||
"guid=1; vplatform=109; yspopenid=vu0-8lgGV2LW9QjDeuBFsX8yMnzs37Q3_HZF6XyVDpGR_I; vusession=$token"
|
|
||||||
fetchVideo(tvModel, cookie)
|
|
||||||
} else {
|
|
||||||
Log.e(TAG, "info status error")
|
|
||||||
if (tvModel.retryTimes < tvModel.retryMaxTimes) {
|
|
||||||
tvModel.retryTimes++
|
|
||||||
fetchData(tvModel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onFailure(call: Call<Info>, t: Throwable) {
|
|
||||||
Log.e(TAG, "info request error $t")
|
|
||||||
if (tvModel.retryTimes < tvModel.retryMaxTimes) {
|
|
||||||
tvModel.retryTimes++
|
|
||||||
fetchData(tvModel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
|
val cookie = "guid=1; vplatform=109"
|
||||||
fetchVideo(tvModel, cookie)
|
fetchVideo(tvModel, cookie)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,26 @@
|
|||||||
package com.lizongying.mytv.api
|
package com.lizongying.mytv.api
|
||||||
|
|
||||||
|
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
import retrofit2.Retrofit
|
import retrofit2.Retrofit
|
||||||
import retrofit2.converter.gson.GsonConverterFactory
|
import retrofit2.converter.gson.GsonConverterFactory
|
||||||
|
import retrofit2.converter.protobuf.ProtoConverterFactory
|
||||||
|
|
||||||
|
|
||||||
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 myUrl = "http://10.0.2.2:8081/"
|
private val protoUrl = "https://capi.yangshipin.cn/"
|
||||||
|
private val traceUrl = "https://btrace.yangshipin.cn/"
|
||||||
|
|
||||||
|
private var okHttpClient = OkHttpClient.Builder()
|
||||||
|
.dns(DnsCache())
|
||||||
|
.build()
|
||||||
|
|
||||||
val yspApiService: YSPApiService by lazy {
|
val yspApiService: YSPApiService by lazy {
|
||||||
Retrofit.Builder()
|
Retrofit.Builder()
|
||||||
.baseUrl(yspUrl)
|
.baseUrl(yspUrl)
|
||||||
|
.client(okHttpClient)
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
.build().create(YSPApiService::class.java)
|
.build().create(YSPApiService::class.java)
|
||||||
}
|
}
|
||||||
@@ -20,7 +28,24 @@ class ApiClient {
|
|||||||
val yspTokenService: YSPTokenService by lazy {
|
val yspTokenService: YSPTokenService by lazy {
|
||||||
Retrofit.Builder()
|
Retrofit.Builder()
|
||||||
.baseUrl(myUrl)
|
.baseUrl(myUrl)
|
||||||
|
.client(okHttpClient)
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
.build().create(YSPTokenService::class.java)
|
.build().create(YSPTokenService::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val yspProtoService: YSPProtoService by lazy {
|
||||||
|
Retrofit.Builder()
|
||||||
|
.baseUrl(protoUrl)
|
||||||
|
.client(okHttpClient)
|
||||||
|
.addConverterFactory(ProtoConverterFactory.create())
|
||||||
|
.build().create(YSPProtoService::class.java)
|
||||||
|
}
|
||||||
|
|
||||||
|
val yspBtraceService: YSPBtraceService by lazy {
|
||||||
|
Retrofit.Builder()
|
||||||
|
.baseUrl(traceUrl)
|
||||||
|
.client(okHttpClient)
|
||||||
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
|
.build().create(YSPBtraceService::class.java)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package com.lizongying.mytv.api
|
|
||||||
|
|
||||||
|
|
||||||
import retrofit2.Retrofit
|
|
||||||
import retrofit2.converter.gson.GsonConverterFactory
|
|
||||||
|
|
||||||
|
|
||||||
class BtraceClient {
|
|
||||||
private val yspUrl = "https://btrace.yangshipin.cn/"
|
|
||||||
|
|
||||||
val yspBtraceService: YSPBtraceService by lazy {
|
|
||||||
Retrofit.Builder()
|
|
||||||
.baseUrl(yspUrl)
|
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
|
||||||
.build().create(YSPBtraceService::class.java)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.lizongying.mytv.api
|
||||||
|
|
||||||
|
import okhttp3.Dns
|
||||||
|
import java.net.InetAddress
|
||||||
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
|
|
||||||
|
class DnsCache : Dns {
|
||||||
|
private val dnsCache: MutableMap<String, List<InetAddress>> = ConcurrentHashMap()
|
||||||
|
|
||||||
|
override fun lookup(hostname: String): List<InetAddress> {
|
||||||
|
dnsCache[hostname]?.let {
|
||||||
|
return it
|
||||||
|
}
|
||||||
|
|
||||||
|
val addresses = InetAddress.getAllByName(hostname).toList()
|
||||||
|
|
||||||
|
if (addresses.isNotEmpty()) {
|
||||||
|
dnsCache[hostname] = addresses
|
||||||
|
}
|
||||||
|
|
||||||
|
return addresses
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ data class LiveInfo(
|
|||||||
data class LiveInfoData(
|
data class LiveInfoData(
|
||||||
val chanll: String,
|
val chanll: String,
|
||||||
val playurl: String,
|
val playurl: String,
|
||||||
|
val errinfo: String,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class LiveInfoRequest(
|
data class LiveInfoRequest(
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.lizongying.mytv.api
|
|
||||||
|
|
||||||
import retrofit2.Retrofit
|
|
||||||
import retrofit2.converter.protobuf.ProtoConverterFactory
|
|
||||||
|
|
||||||
|
|
||||||
class ProtoClient {
|
|
||||||
private val protoUrl = "https://capi.yangshipin.cn/"
|
|
||||||
|
|
||||||
val yspProtoService: YSPProtoService by lazy {
|
|
||||||
Retrofit.Builder()
|
|
||||||
.baseUrl(protoUrl)
|
|
||||||
.addConverterFactory(ProtoConverterFactory.create())
|
|
||||||
.build().create(YSPProtoService::class.java)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -70,6 +70,8 @@ class YSP(var context: Context) {
|
|||||||
defn = "fhd"
|
defn = "fhd"
|
||||||
|
|
||||||
randStr = getRand()
|
randStr = getRand()
|
||||||
|
|
||||||
|
guid = newGuid()
|
||||||
timeStr = getTimeStr()
|
timeStr = getTimeStr()
|
||||||
|
|
||||||
// guid = "lq3oqitm_1e15dnzgjnb"
|
// guid = "lq3oqitm_1e15dnzgjnb"
|
||||||
@@ -105,6 +107,15 @@ class YSP(var context: Context) {
|
|||||||
return guid
|
return guid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun newGuid(): String {
|
||||||
|
guid = generateGuid()
|
||||||
|
with(sharedPref!!.edit()) {
|
||||||
|
putString("guid", guid)
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
return guid
|
||||||
|
}
|
||||||
|
|
||||||
fun getRand(): String {
|
fun getRand(): String {
|
||||||
var n = ""
|
var n = ""
|
||||||
val e = "ABCDEFGHIJKlMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
val e = "ABCDEFGHIJKlMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||||
|
|||||||
@@ -20,9 +20,13 @@ class TVViewModel(private var tv: TV) : ViewModel() {
|
|||||||
private var itemPosition: Int = 0
|
private var itemPosition: Int = 0
|
||||||
|
|
||||||
var retryTimes: Int = 0
|
var retryTimes: Int = 0
|
||||||
var retryMaxTimes: Int = 3
|
var retryMaxTimes: Int = 5
|
||||||
var programUpdateTime: Long = 0
|
var programUpdateTime: Long = 0
|
||||||
|
|
||||||
|
private val _errInfo = MutableLiveData<String>()
|
||||||
|
val errInfo: LiveData<String>
|
||||||
|
get() = _errInfo
|
||||||
|
|
||||||
private val _programId = MutableLiveData<String>()
|
private val _programId = MutableLiveData<String>()
|
||||||
val programId: LiveData<String>
|
val programId: LiveData<String>
|
||||||
get() = _programId
|
get() = _programId
|
||||||
@@ -67,10 +71,31 @@ class TVViewModel(private var tv: TV) : ViewModel() {
|
|||||||
val ready: LiveData<Boolean>
|
val ready: LiveData<Boolean>
|
||||||
get() = _ready
|
get() = _ready
|
||||||
|
|
||||||
private var mMinimumLoadableRetryCount = 3
|
private var mMinimumLoadableRetryCount = 5
|
||||||
|
|
||||||
var seq = 0
|
var seq = 0
|
||||||
|
|
||||||
|
var needToken = false
|
||||||
|
|
||||||
|
private val channelsNeedToken = arrayOf(
|
||||||
|
"CCTV3 综艺",
|
||||||
|
"CCTV6 电影",
|
||||||
|
"CCTV8 电视剧",
|
||||||
|
"风云剧场",
|
||||||
|
"第一剧场",
|
||||||
|
"怀旧剧场",
|
||||||
|
"世界地理",
|
||||||
|
"风云音乐",
|
||||||
|
"兵器科技",
|
||||||
|
"风云足球",
|
||||||
|
"高尔夫网球",
|
||||||
|
"女性时尚",
|
||||||
|
"央视文化精品",
|
||||||
|
"央视台球",
|
||||||
|
"电视指南",
|
||||||
|
"卫生健康",
|
||||||
|
)
|
||||||
|
|
||||||
fun addVideoUrl(url: String) {
|
fun addVideoUrl(url: String) {
|
||||||
if (_videoUrl.value?.isNotEmpty() == true) {
|
if (_videoUrl.value?.isNotEmpty() == true) {
|
||||||
if (_videoUrl.value!!.last().contains("cctv.cn")) {
|
if (_videoUrl.value!!.last().contains("cctv.cn")) {
|
||||||
@@ -121,6 +146,10 @@ class TVViewModel(private var tv: TV) : ViewModel() {
|
|||||||
_pid.value = tv.pid
|
_pid.value = tv.pid
|
||||||
_sid.value = tv.sid
|
_sid.value = tv.sid
|
||||||
_program.value = mutableListOf()
|
_program.value = mutableListOf()
|
||||||
|
|
||||||
|
if (tv.title in channelsNeedToken) {
|
||||||
|
needToken = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getRowPosition(): Int {
|
fun getRowPosition(): Int {
|
||||||
@@ -139,6 +168,10 @@ class TVViewModel(private var tv: TV) : ViewModel() {
|
|||||||
itemPosition = position
|
itemPosition = position
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setErrInfo(info: String) {
|
||||||
|
_errInfo.value = info
|
||||||
|
}
|
||||||
|
|
||||||
fun update(t: TV) {
|
fun update(t: TV) {
|
||||||
tv = t
|
tv = t
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user