mirror of
https://github.com/lizongying/my-tv.git
synced 2026-10-27 22:56:32 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
83a70291d4 | ||
|
|
872f668c59 | ||
|
|
426839c747 | ||
|
|
3e513d5adf | ||
|
|
86d4081d03 | ||
|
|
f76aa37169 | ||
|
|
d944777fc6 | ||
|
|
a45244c552 | ||
|
|
809ec920a5 | ||
|
|
8e4f7df8d4 | ||
|
|
fe209183ea | ||
|
|
b7ec58ac5b | ||
|
|
096acdf55e | ||
|
|
c8d59d5aab | ||
|
|
2b4b823946 | ||
|
|
127ceeb0b0 | ||
|
|
9dd6a2155f | ||
|
|
526a7c5c40 | ||
|
|
960f890ddd | ||
|
|
0a7837c577 | ||
|
|
d8342e8c6a | ||
|
|
6387f48409 | ||
|
|
807300918c | ||
|
|
36eacb7a57 | ||
|
|
b4abe0ccc6 | ||
|
|
fd1dc8d3c7 | ||
|
|
ea56bf1b80 | ||
|
|
a746fe6c65 | ||
|
|
594d5e3499 | ||
|
|
6061187bc8 | ||
|
|
cd8b37e63c | ||
|
|
aa3ba1d41f | ||
|
|
c778ac07ba | ||
|
|
700c8b4c04 | ||
|
|
825a872a09 | ||
|
|
54b43664ec | ||
|
|
a93cfb455c | ||
|
|
8535689e95 |
@@ -0,0 +1,83 @@
|
||||
name: Bug 反馈
|
||||
description: 反馈一个 Bug
|
||||
labels: [ "bug" ]
|
||||
title: "[BUG] "
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checklist
|
||||
attributes:
|
||||
label: 检查清单
|
||||
description: 确保我们的错误报告表单适合您。
|
||||
options:
|
||||
- label: 之前没有人提交过类似或相同的 bug report。
|
||||
required: true
|
||||
- label: 我正在使用本软件的最新版本。
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: version
|
||||
attributes:
|
||||
label: my-ty 版本
|
||||
description: 请选择正在使用的版本
|
||||
options:
|
||||
- 最新稳定版
|
||||
- 最新 CI 版
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: bug
|
||||
attributes:
|
||||
label: Bug 描述
|
||||
description: 请描述 bug 详情
|
||||
placeholder: |
|
||||
e.g. Crashed when generating snapshot.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: 预期行为
|
||||
description: 你预期会发生什么?
|
||||
placeholder: |
|
||||
e.g. A New snapshot!
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: actual
|
||||
attributes:
|
||||
label: 实际行为
|
||||
description: 反而发生了什么?
|
||||
placeholder: |
|
||||
e.g. Crashed.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: steps
|
||||
attributes:
|
||||
label: 复现步骤
|
||||
description: 如何复现这个 bug。
|
||||
placeholder: |
|
||||
1. Open the app
|
||||
2. Crashed
|
||||
|
||||
What an app.
|
||||
- type: input
|
||||
id: ui
|
||||
attributes:
|
||||
label: UI / OS
|
||||
description: 你的电视系统 UI 或 OS 或 品牌
|
||||
placeholder: TCL / XIAOMI / PHONE / etc.
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: android
|
||||
attributes:
|
||||
label: Android 版本
|
||||
description: 你的 Android 版本
|
||||
placeholder: "12"
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: additional
|
||||
attributes:
|
||||
label: 额外信息
|
||||
description: 任何你觉得值得说的。
|
||||
@@ -0,0 +1,36 @@
|
||||
name: 功能(新频道)请求
|
||||
description: 提出一个建议
|
||||
labels: [ "enhancement" ]
|
||||
title: "[FR] "
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checklist
|
||||
attributes:
|
||||
label: 检查清单
|
||||
description: 确保我们的错误报告表单适合您。
|
||||
options:
|
||||
- label: 之前没有人提交过类似或相同的功能请求。
|
||||
required: true
|
||||
- label: 这个建议不会背离 LibChecker 的初衷。
|
||||
required: true
|
||||
- type: textarea
|
||||
id: propose
|
||||
attributes:
|
||||
label: 改进目的
|
||||
description: 改进有什么用
|
||||
placeholder: |
|
||||
Show your idea here.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: solution
|
||||
attributes:
|
||||
label: 解决方案
|
||||
description: 你会怎么完成这个改进?
|
||||
placeholder: |
|
||||
How to do it on your opinion? Or left this blank
|
||||
- type: textarea
|
||||
id: addition
|
||||
attributes:
|
||||
label: 额外信息
|
||||
description: 任何你觉得值得说的。
|
||||
@@ -14,6 +14,16 @@
|
||||
|
||||
## 更新日志
|
||||
|
||||
### v1.5.8(通用版)
|
||||
|
||||
* 修复央视6画质差的问题
|
||||
* 增加兵团卫视
|
||||
* 播放失败重试
|
||||
|
||||
### v1.5.6(通用版)
|
||||
|
||||
* 解决部分设备系统时间不对导致播放失败的问题
|
||||
|
||||
### v1.5.2(通用版)
|
||||
|
||||
* 修复APP恢复后频道号、频道列表不自动消失的问题
|
||||
@@ -109,6 +119,7 @@ adb install my-tv.apk
|
||||
* 获取系统时间
|
||||
* 选中的图标比例能否相差更大
|
||||
* 自动重连
|
||||
* 节目增加预告
|
||||
|
||||
## 赞赏
|
||||
|
||||
|
||||
@@ -113,4 +113,8 @@ dependencies {
|
||||
implementation 'com.github.bumptech.glide:glide:4.11.0'
|
||||
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.2"
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0-RC")
|
||||
|
||||
implementation 'com.google.android.exoplayer:exoplayer-ui:2.13.3'
|
||||
implementation 'com.google.android.exoplayer:exoplayer-core:2.13.3'
|
||||
implementation 'com.google.android.exoplayer:exoplayer-hls:2.13.3'
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
android:name="android.software.leanback"
|
||||
android:required="true" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:largeHeap="true"
|
||||
@@ -29,5 +30,13 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<receiver
|
||||
android:name=".BootReceiver"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.lizongying.mytv
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
||||
class BootReceiver : BroadcastReceiver() {
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
val sp = context.getSharedPreferences("MainActivity", Context.MODE_PRIVATE)
|
||||
if (sp.getBoolean(MainActivity.BOOT_STARTUP, true)) {
|
||||
context.startActivity(
|
||||
Intent(context, MainActivity::class.java)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package com.lizongying.mytv
|
||||
|
||||
import android.content.Context
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
*@author LeGend
|
||||
*@date 2024/2/4 22:42
|
||||
*/
|
||||
object ChannelUtils {
|
||||
/**
|
||||
* 获取服务器channel版本
|
||||
*
|
||||
* @param context Context
|
||||
*
|
||||
* @return 服务器channel版本
|
||||
*/
|
||||
suspend fun getServerVersion(context: Context): Int {
|
||||
return withContext(Dispatchers.IO) {
|
||||
val client = okhttp3.OkHttpClient.Builder().connectTimeout(500, java.util.concurrent.TimeUnit.MILLISECONDS)
|
||||
.readTimeout(1, java.util.concurrent.TimeUnit.SECONDS).build()
|
||||
client.newCall(okhttp3.Request.Builder().url(getServerVersionUrl(context)).build()).execute()
|
||||
.use { response ->
|
||||
if (!response.isSuccessful) throw java.io.IOException("Unexpected code $response")
|
||||
val body = response.body()
|
||||
body?.string()?.toInt() ?: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务器channel
|
||||
*
|
||||
* @param url String 服务器地址
|
||||
*
|
||||
* @return Array<TV> 服务器channel
|
||||
*
|
||||
* @throws java.io.IOException 网络请求失败
|
||||
*/
|
||||
suspend fun getServerChannel(url: String): List<TV> {
|
||||
val result = withContext(Dispatchers.IO) {
|
||||
val client = okhttp3.OkHttpClient.Builder().connectTimeout(500, java.util.concurrent.TimeUnit.MILLISECONDS)
|
||||
.readTimeout(1, java.util.concurrent.TimeUnit.SECONDS).build()
|
||||
val request = okhttp3.Request.Builder().url(url).build()
|
||||
client.newCall(request).execute().use { response ->
|
||||
if (!response.isSuccessful) throw java.io.IOException("Unexpected code $response")
|
||||
val body = response.body()
|
||||
body?.string() ?: ""
|
||||
}
|
||||
}
|
||||
return withContext(Dispatchers.Default) {
|
||||
val type = object : com.google.gson.reflect.TypeToken<List<TV>>() {}.type
|
||||
com.google.gson.Gson().fromJson(result, type)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务器地址
|
||||
*
|
||||
* @param context Context
|
||||
*
|
||||
* @return 服务器地址
|
||||
*/
|
||||
fun getServerUrl(context: Context): String {
|
||||
return context.resources.getString(R.string.server_url)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取serverVersion的URL
|
||||
*
|
||||
* @param context Context
|
||||
*
|
||||
* @return serverVersionURL 服务器版本地址
|
||||
*/
|
||||
suspend fun getServerVersionUrl(context: Context): String {
|
||||
return withContext(Dispatchers.IO) {
|
||||
context.resources.getString(R.string.server_version_url)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取本地channel版本
|
||||
*
|
||||
* @param context Context
|
||||
*
|
||||
* @return 本地channel
|
||||
*/
|
||||
suspend fun getLocalVersion(context: Context): Int {
|
||||
return withContext(Dispatchers.IO) {
|
||||
val file = File(getAppDirectory(context), "channels")
|
||||
//检查本地是否已经有保存的channels.json,若无保存的Channel.json则从读取assert中文件
|
||||
val savedVersion =
|
||||
context.getSharedPreferences("saved_version", Context.MODE_PRIVATE).getInt("version", Integer.MIN_VALUE)
|
||||
if (!file.exists() || savedVersion == Integer.MIN_VALUE) {
|
||||
context.resources.getInteger(R.integer.local_channel_version)
|
||||
} else {
|
||||
savedVersion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本地可读取的目录
|
||||
* @param context Context
|
||||
*
|
||||
* @return 可读取的目录
|
||||
*/
|
||||
private fun getAppDirectory(context: Context): File {
|
||||
return context.filesDir
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本地channel
|
||||
*
|
||||
* @param context Context
|
||||
*
|
||||
* @return Array<TV> 本地channel
|
||||
*/
|
||||
suspend fun getLocalChannel(context: Context): List<TV> {
|
||||
val str = withContext(Dispatchers.IO) {
|
||||
if (File(getAppDirectory(context), "channels").exists()) {
|
||||
File(getAppDirectory(context), "channels").readText()
|
||||
} else {
|
||||
context.resources.openRawResource(R.raw.channels).bufferedReader().use { it.readText() }
|
||||
}
|
||||
}
|
||||
return withContext(Dispatchers.Default) {
|
||||
val type = object : com.google.gson.reflect.TypeToken<List<TV>>() {}.type
|
||||
com.google.gson.Gson().fromJson(str, type)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新channels.json
|
||||
*
|
||||
* @param context Context
|
||||
*
|
||||
* @return 无
|
||||
*
|
||||
* @throws java.io.IOException 写入失败
|
||||
*/
|
||||
suspend fun updateLocalChannel(context: Context, version: Int, channels: List<TV>) {
|
||||
withContext(Dispatchers.IO) {
|
||||
val file = File(getAppDirectory(context), "channels")
|
||||
if (!file.exists()) {
|
||||
file.createNewFile()
|
||||
}
|
||||
file.writeText(com.google.gson.Gson().toJson(channels))
|
||||
context.getSharedPreferences("saved_version", Context.MODE_PRIVATE).edit().putInt(
|
||||
"version", version
|
||||
).apply()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,10 @@ class InfoFragment : Fragment() {
|
||||
.load(R.drawable.xinjiang)
|
||||
.into(binding.infoLogo)
|
||||
|
||||
"兵团卫视" -> Glide.with(this)
|
||||
.load(R.drawable.bingtuan)
|
||||
.into(binding.infoLogo)
|
||||
|
||||
else -> Glide.with(this)
|
||||
.load(tvViewModel.logo.value)
|
||||
.into(binding.infoLogo)
|
||||
|
||||
@@ -18,7 +18,12 @@ import android.view.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
import android.view.WindowManager
|
||||
import android.widget.Toast
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.lizongying.mytv.models.TVViewModel
|
||||
import kotlinx.coroutines.CoroutineStart
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.launch
|
||||
import java.security.MessageDigest
|
||||
|
||||
|
||||
@@ -41,9 +46,20 @@ class MainActivity : FragmentActivity() {
|
||||
lateinit var sharedPref: SharedPreferences
|
||||
private var channelReversal = false
|
||||
private var channelNum = true
|
||||
private var bootStartup = true
|
||||
|
||||
private var versionName = ""
|
||||
|
||||
init {
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
val utilsJob = async(start = CoroutineStart.LAZY) { Utils.init() }
|
||||
|
||||
utilsJob.start()
|
||||
|
||||
utilsJob.await()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
Log.i(TAG, "onCreate")
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -67,9 +83,10 @@ class MainActivity : FragmentActivity() {
|
||||
sharedPref = getPreferences(Context.MODE_PRIVATE)
|
||||
channelReversal = sharedPref.getBoolean(CHANNEL_REVERSAL, channelReversal)
|
||||
channelNum = sharedPref.getBoolean(CHANNEL_NUM, channelNum)
|
||||
bootStartup = sharedPref.getBoolean(BOOT_STARTUP, bootStartup)
|
||||
|
||||
versionName = getPackageInfo().versionName
|
||||
settingFragment = SettingFragment(versionName, channelReversal, channelNum)
|
||||
settingFragment = SettingFragment(versionName, channelReversal, channelNum, bootStartup)
|
||||
}
|
||||
|
||||
fun showInfoFragment(tvViewModel: TVViewModel) {
|
||||
@@ -222,6 +239,14 @@ class MainActivity : FragmentActivity() {
|
||||
this.channelNum = channelNum
|
||||
}
|
||||
|
||||
fun saveBootStartup(bootStartup: Boolean) {
|
||||
with(sharedPref.edit()) {
|
||||
putBoolean(BOOT_STARTUP, bootStartup)
|
||||
apply()
|
||||
}
|
||||
this.bootStartup = bootStartup
|
||||
}
|
||||
|
||||
private fun showSetting() {
|
||||
if (!mainFragment.isHidden) {
|
||||
return
|
||||
@@ -510,5 +535,6 @@ class MainActivity : FragmentActivity() {
|
||||
private const val TAG = "MainActivity"
|
||||
private const val CHANNEL_REVERSAL = "channel_reversal"
|
||||
private const val CHANNEL_NUM = "channel_num"
|
||||
const val BOOT_STARTUP = "boot_startup"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,6 @@ class MainFragment : BrowseSupportFragment() {
|
||||
val cardPresenter = CardPresenter(viewLifecycleOwner)
|
||||
|
||||
var idx: Long = 0
|
||||
context?.let { TVList.init(it) }
|
||||
for ((k, v) in TVList.list) {
|
||||
val listRowAdapter = ArrayObjectAdapter(cardPresenter)
|
||||
for ((idx2, v1) in v.withIndex()) {
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.lizongying.mytv
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.SurfaceHolder
|
||||
import android.view.SurfaceView
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewTreeObserver
|
||||
@@ -15,24 +17,39 @@ import androidx.media3.common.VideoSize
|
||||
import androidx.media3.common.util.UnstableApi
|
||||
import androidx.media3.exoplayer.ExoPlayer
|
||||
import androidx.media3.ui.PlayerView
|
||||
import com.google.android.exoplayer2.SimpleExoPlayer
|
||||
import com.lizongying.mytv.databinding.PlayerBinding
|
||||
import com.lizongying.mytv.models.TVViewModel
|
||||
|
||||
|
||||
class PlayerFragment : Fragment() {
|
||||
class PlayerFragment : Fragment(), SurfaceHolder.Callback {
|
||||
|
||||
private var _binding: PlayerBinding? = null
|
||||
private var playerView: PlayerView? = null
|
||||
private var tvViewModel: TVViewModel? = null
|
||||
private val aspectRatio = 16f / 9f
|
||||
|
||||
|
||||
private lateinit var surfaceView: SurfaceView
|
||||
private lateinit var surfaceHolder: SurfaceHolder
|
||||
private var exoPlayer: SimpleExoPlayer? = null
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = PlayerBinding.inflate(inflater, container, false)
|
||||
playerView = _binding!!.playerView
|
||||
(activity as MainActivity).playerFragment = this
|
||||
|
||||
if (Utils.isTmallDevice()) {
|
||||
_binding!!.playerView.visibility = View.GONE
|
||||
surfaceView = _binding!!.surfaceView
|
||||
surfaceHolder = surfaceView.holder
|
||||
surfaceHolder.addCallback(this)
|
||||
} else {
|
||||
_binding!!.surfaceView.visibility = View.GONE
|
||||
playerView = _binding!!.playerView
|
||||
}
|
||||
|
||||
playerView?.viewTreeObserver?.addOnGlobalLayoutListener(object :
|
||||
ViewTreeObserver.OnGlobalLayoutListener {
|
||||
override fun onGlobalLayout() {
|
||||
@@ -78,6 +95,10 @@ class PlayerFragment : Fragment() {
|
||||
setMediaItem(MediaItem.fromUri(tvViewModel.getVideoUrlCurrent()))
|
||||
prepare()
|
||||
}
|
||||
exoPlayer?.run {
|
||||
setMediaItem(com.google.android.exoplayer2.MediaItem.fromUri(tvViewModel.getVideoUrlCurrent()))
|
||||
prepare()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
@@ -86,8 +107,10 @@ class PlayerFragment : Fragment() {
|
||||
if (playerView != null && playerView!!.player?.isPlaying == false) {
|
||||
Log.i(TAG, "replay")
|
||||
playerView!!.player?.prepare()
|
||||
} else {
|
||||
Log.i(TAG, "playing")
|
||||
}
|
||||
if (exoPlayer?.isPlaying == false) {
|
||||
Log.i(TAG, "replay")
|
||||
exoPlayer?.prepare()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,6 +124,9 @@ class PlayerFragment : Fragment() {
|
||||
if (playerView != null && playerView!!.player?.isPlaying == true) {
|
||||
playerView!!.player?.stop()
|
||||
}
|
||||
if (exoPlayer?.isPlaying == true) {
|
||||
exoPlayer?.stop()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
@@ -108,6 +134,7 @@ class PlayerFragment : Fragment() {
|
||||
if (playerView != null) {
|
||||
playerView!!.player?.release()
|
||||
}
|
||||
exoPlayer?.release()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
@@ -118,4 +145,16 @@ class PlayerFragment : Fragment() {
|
||||
companion object {
|
||||
private const val TAG = "PlaybackVideoFragment"
|
||||
}
|
||||
|
||||
override fun surfaceCreated(holder: SurfaceHolder) {
|
||||
exoPlayer = SimpleExoPlayer.Builder(requireContext()).build()
|
||||
exoPlayer?.setVideoSurfaceHolder(surfaceHolder)
|
||||
exoPlayer?.playWhenReady = true
|
||||
}
|
||||
|
||||
override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) {
|
||||
}
|
||||
|
||||
override fun surfaceDestroyed(holder: SurfaceHolder) {
|
||||
}
|
||||
}
|
||||
@@ -41,55 +41,7 @@ class Request {
|
||||
|
||||
private val regex = Regex("""des_key = "([^"]+).+var des_iv = "([^"]+)""")
|
||||
private val input =
|
||||
"""{"mver":"1","subver":"1.2","host":"www.yangshipin.cn/#/tv/home?pid=","referer":"","canvas":"YSPANGLE(Apple,AppleM1Pro,OpenGL4.1)"}""".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 "新疆卫视",
|
||||
)
|
||||
"""{"mver":"1","subver":"1.2","host":"www.yangshipin.cn/#/tv/home?pid=","referer":"","canvas":"YSPANGLE(Apple,ANGLEMetalRenderer:AppleM1Pro,UnspecifiedVersion)"}""".toByteArray()
|
||||
|
||||
init {
|
||||
handler.post(tokenRunnable)
|
||||
@@ -97,8 +49,6 @@ class Request {
|
||||
|
||||
fun initYSP(context: Context) {
|
||||
ysp = YSP(context)
|
||||
//TODO 不确定在哪里初始化
|
||||
TVList.init(context)
|
||||
}
|
||||
|
||||
var call: Call<LiveInfo>? = null
|
||||
@@ -120,6 +70,7 @@ class Request {
|
||||
override fun onResponse(call: Call<LiveInfo>, response: Response<LiveInfo>) {
|
||||
if (response.isSuccessful) {
|
||||
val liveInfo = response.body()
|
||||
|
||||
if (liveInfo?.data?.playurl != null) {
|
||||
val chanll = liveInfo.data.chanll
|
||||
val decodedBytes = Base64.decode(
|
||||
@@ -135,8 +86,8 @@ class Request {
|
||||
val url = liveInfo.data.playurl + "&revoi=" + encryptTripleDES(
|
||||
keyBytes + byteArrayOf(0, 0, 0, 0, 0, 0, 0, 0),
|
||||
ivBytes
|
||||
).uppercase()
|
||||
// Log.d(TAG, "$title url $url")
|
||||
).uppercase() + liveInfo.data.extended_param
|
||||
Log.d(TAG, "$title url $url")
|
||||
tvModel.addVideoUrl(url)
|
||||
tvModel.allReady()
|
||||
tvModel.retryTimes = 0
|
||||
@@ -229,7 +180,7 @@ class Request {
|
||||
yspTokenService.getInfo()
|
||||
.enqueue(object : Callback<Info> {
|
||||
override fun onResponse(call: Call<Info>, response: Response<Info>) {
|
||||
if (response.isSuccessful) {
|
||||
if (response.isSuccessful && response.body()?.data?.token != null) {
|
||||
token = response.body()?.data?.token!!
|
||||
Log.i(TAG, "info success $token")
|
||||
val cookie =
|
||||
@@ -292,7 +243,7 @@ class Request {
|
||||
yspTokenService.getInfo()
|
||||
.enqueue(object : Callback<Info> {
|
||||
override fun onResponse(call: Call<Info>, response: Response<Info>) {
|
||||
if (response.isSuccessful) {
|
||||
if (response.isSuccessful && response.body()?.data?.token != null) {
|
||||
token = response.body()?.data?.token!!
|
||||
Log.i(TAG, "info success $token")
|
||||
} else {
|
||||
@@ -356,29 +307,20 @@ class Request {
|
||||
) {
|
||||
if (response.isSuccessful) {
|
||||
val body = response.body()
|
||||
|
||||
if (body?.data?.feedModuleListCount == 1) {
|
||||
for (item in body.data?.feedModuleListList!![0]?.dataTvChannelListList!!) {
|
||||
if (item.isVip && !item.isLimitedFree) {
|
||||
continue
|
||||
}
|
||||
Log.i(
|
||||
Log.d(
|
||||
TAG,
|
||||
"${item.channelName},${item.pid},${item.streamId}"
|
||||
)
|
||||
var channelType = "央视频道"
|
||||
if (item?.channelType === "weishi") {
|
||||
channelType = "地方频道"
|
||||
}
|
||||
if (!mapping.containsKey(item.channelName)) {
|
||||
continue
|
||||
}
|
||||
val tv =
|
||||
TVList.list[channelType]?.find { it.title == mapping[item.channelName] }
|
||||
if (tv != null) {
|
||||
tv.logo = item.tvLogo
|
||||
tv.pid = item.pid
|
||||
tv.sid = item.streamId
|
||||
|
||||
for ((_, v) in TVList.list) {
|
||||
for (v2 in v) {
|
||||
if (v2.title == item.channelName || v2.alias == item.channelName) {
|
||||
v2.pid = item.pid
|
||||
v2.sid = item.streamId
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.lizongying.mytv.databinding.DialogBinding
|
||||
class SettingFragment(private val versionName: String,
|
||||
private val channelReversal: Boolean,
|
||||
private val channelNum: Boolean,
|
||||
private val bootStartup: Boolean,
|
||||
) :
|
||||
DialogFragment() {
|
||||
|
||||
@@ -43,6 +44,12 @@ class SettingFragment(private val versionName: String,
|
||||
(activity as MainActivity).saveChannelNum(isChecked)
|
||||
}
|
||||
|
||||
val switchBootStartup = _binding?.switchBootStartup
|
||||
switchBootStartup?.isChecked = bootStartup
|
||||
switchBootStartup?.setOnCheckedChangeListener { _, isChecked ->
|
||||
(activity as MainActivity).saveBootStartup(isChecked)
|
||||
}
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.io.Serializable
|
||||
data class TV(
|
||||
var id: Int = 0,
|
||||
var title: String,
|
||||
var alias: String = "",
|
||||
var videoUrl: List<String>,
|
||||
var videoIndex: Int = 0,
|
||||
var channel: String = "",
|
||||
@@ -12,10 +13,10 @@ data class TV(
|
||||
var pid: String = "",
|
||||
var sid: String = "",
|
||||
var programId: String = "",
|
||||
var needToken:Boolean=false,
|
||||
var mustToken:Boolean=false,
|
||||
var needToken: Boolean = false,
|
||||
var mustToken: Boolean = false,
|
||||
|
||||
) : Serializable {
|
||||
) : Serializable {
|
||||
|
||||
override fun toString(): String {
|
||||
return "TV{" +
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,5 @@
|
||||
package com.lizongying.mytv
|
||||
|
||||
class UpdateManager {
|
||||
|
||||
}
|
||||
@@ -1,20 +1,64 @@
|
||||
package com.lizongying.mytv
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.os.Build
|
||||
import android.util.TypedValue
|
||||
import java.io.File
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import com.google.gson.Gson
|
||||
import com.lizongying.mytv.api.TimeResponse
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.IOException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
object Utils {
|
||||
private var between: Long = 0
|
||||
|
||||
fun getDateFormat(format: String): String {
|
||||
return SimpleDateFormat(format, Locale.CHINA).format(Date())
|
||||
return SimpleDateFormat(
|
||||
format,
|
||||
Locale.CHINA
|
||||
).format(Date(System.currentTimeMillis() - between))
|
||||
}
|
||||
|
||||
fun getDateTimestamp(): Long {
|
||||
return Date().time / 1000
|
||||
return (System.currentTimeMillis() - between) / 1000
|
||||
}
|
||||
|
||||
suspend fun init() {
|
||||
var currentTimeMillis: Long = 0
|
||||
try {
|
||||
currentTimeMillis = getTimestampFromServer()
|
||||
} catch (e: Exception) {
|
||||
println("Failed to retrieve timestamp from server: ${e.message}")
|
||||
}
|
||||
between = System.currentTimeMillis() - currentTimeMillis
|
||||
}
|
||||
|
||||
/**
|
||||
* 从服务器获取时间戳
|
||||
* @return Long 时间戳
|
||||
*/
|
||||
private suspend fun getTimestampFromServer(): Long {
|
||||
return withContext(Dispatchers.IO) {
|
||||
val client = okhttp3.OkHttpClient.Builder()
|
||||
.connectTimeout(500, java.util.concurrent.TimeUnit.MILLISECONDS)
|
||||
.readTimeout(1, java.util.concurrent.TimeUnit.SECONDS).build()
|
||||
val request = okhttp3.Request.Builder()
|
||||
.url("https://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp")
|
||||
.build()
|
||||
try {
|
||||
client.newCall(request).execute().use { response ->
|
||||
if (!response.isSuccessful) throw IOException("Unexpected code $response")
|
||||
val string = response.body()?.string()
|
||||
Gson().fromJson(string, TimeResponse::class.java).data.t.toLong()
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
// Handle network errors
|
||||
throw IOException("Error during network request", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun dpToPx(dp: Float): Int {
|
||||
@@ -29,48 +73,5 @@ object Utils {
|
||||
).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取可读写的目录
|
||||
*
|
||||
* @param context 应用环境信息
|
||||
*
|
||||
* @return 可读写的目录
|
||||
*
|
||||
*/
|
||||
fun getAppDirectory(context: Context): File {
|
||||
return context.filesDir
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新channels.json
|
||||
*
|
||||
* @param context 应用环境信息
|
||||
*
|
||||
* @return 无
|
||||
*
|
||||
* @throws IOException 网络请求失败
|
||||
*/
|
||||
fun updateChannel(context: Context) {
|
||||
val client = okhttp3.OkHttpClient()
|
||||
val request = okhttp3.Request.Builder().url(getServerUrl(context)).build()
|
||||
client.newCall(request).execute().use { response ->
|
||||
if (!response.isSuccessful) throw IOException("Unexpected code $response")
|
||||
val body = response.body()
|
||||
//覆盖channels.json
|
||||
val file = File(getAppDirectory(context), "channels.json")
|
||||
if (!file.exists()) {
|
||||
file.createNewFile()
|
||||
}
|
||||
file.writeText(body!!.string())
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从res/values/server.xml获取服务器地址
|
||||
* @param context 应用环境信息
|
||||
* @return 服务器地址
|
||||
*/
|
||||
private fun getServerUrl(context: Context): String {
|
||||
return context.resources.getString(R.string.server_url)
|
||||
}
|
||||
fun isTmallDevice() = Build.MANUFACTURER.equals("Tmall", ignoreCase = true)
|
||||
}
|
||||
@@ -9,3 +9,11 @@ data class Info(
|
||||
data class InfoData(
|
||||
val token: String,
|
||||
)
|
||||
|
||||
data class TimeResponse(
|
||||
val data: Time
|
||||
) {
|
||||
data class Time(
|
||||
val t: String
|
||||
)
|
||||
}
|
||||
@@ -13,6 +13,7 @@ data class LiveInfo(
|
||||
)
|
||||
|
||||
data class LiveInfoData(
|
||||
val extended_param: String,
|
||||
val chanll: String,
|
||||
val playurl: String,
|
||||
val errinfo: String,
|
||||
|
||||
@@ -127,7 +127,6 @@ class YSP(var context: Context) {
|
||||
private fun getSignature(): String {
|
||||
val e =
|
||||
"adjust=${adjust}&appVer=${appVer}&app_version=$appVersion&cKey=$cKey&channel=$channel&cmd=$cmd&cnlid=$cnlid&defn=${defn}&devid=${devid}&dtype=${dtype}&encryptVer=${encryptVer}&guid=${guid}&livepid=${livepid}&otype=${otype}&platform=${platform}&rand_str=${randStr}&sphttps=${sphttps}&stream=${stream}".toByteArray()
|
||||
|
||||
val hashedData = encryptor?.hash(e) ?: return ""
|
||||
return hashedData.let { it -> it.joinToString("") { "%02x".format(it) } }
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
@@ -40,6 +40,12 @@
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<Switch
|
||||
android:id="@+id/switch_boot_startup"
|
||||
android:text="@string/title_boot_startup"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:layout_width="300dp"
|
||||
|
||||
@@ -7,6 +7,14 @@
|
||||
android:background="@color/black"
|
||||
android:keepScreenOn="true">
|
||||
|
||||
<SurfaceView
|
||||
android:id="@+id/surface_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
app:resize_mode="fill"
|
||||
app:use_controller="false" />
|
||||
|
||||
<androidx.media3.ui.PlayerView
|
||||
android:id="@+id/player_view"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="server_url">http://localhost:8080</string>
|
||||
</resources>
|
||||
<integer name="local_channel_version">1</integer>
|
||||
<string name="server_version_url">https://fastly.jsdelivr.net/gh/LeGend-wLw/my-tv-json-utils@main/version.txt</string>
|
||||
<string name="server_url">https://fastly.jsdelivr.net/gh/LeGend-wLw/my-tv-json-utils@main/channels.json</string>
|
||||
</resources>
|
||||
|
||||
@@ -2,4 +2,5 @@
|
||||
<string name="app_name">我的电视</string>
|
||||
<string name="title_channel_reversal">换台反转</string>
|
||||
<string name="title_channel_num">数字选台</string>
|
||||
<string name="title_boot_startup">开机自启</string>
|
||||
</resources>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 73 KiB |
Reference in New Issue
Block a user