Skip to content

Commit

Permalink
optimize the sources
Browse files Browse the repository at this point in the history
  • Loading branch information
lizongying committed Dec 6, 2024
1 parent a056ddb commit 0778d09
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 59 deletions.
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## 更新日誌

### v1.3.8.4

* 增加默認視頻源

### v1.3.8.3

* 修復視頻源導入成功時卻顯示錯誤的問題
Expand Down
67 changes: 15 additions & 52 deletions app/src/main/java/com/lizongying/mytv0/SP.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.util.Log
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.lizongying.mytv0.data.Source
import io.github.lizongying.Gua

object SP {
private const val TAG = "SP"
Expand Down Expand Up @@ -67,58 +68,7 @@ object SP {
const val DEFAULT_LOG_TIMES = 10
const val DEFAULT_POSITION_GROUP = 1
const val DEFAULT_POSITION = 0
val DEFAULT_SOURCES = Gson().toJson(listOf(
"https://live.fanmingming.com/tv/m3u/ipv6.m3u",
"https://live.fanmingming.com/tv/m3u/itv.m3u",
"https://live.fanmingming.com/tv/m3u/index.m3u",

"https://iptv-org.github.io/iptv/index.m3u",

// https://github.com/Guovin/iptv-api
"https://raw.githubusercontent.com/Guovin/iptv-api/gd/output/result.m3u",

// https://github.com/joevess/IPTV
"https://raw.githubusercontent.com/joevess/IPTV/main/sources/iptv_sources.m3u",
"https://raw.githubusercontent.com/joevess/IPTV/main/sources/home_sources.m3u",
"https://raw.githubusercontent.com/joevess/IPTV/main/iptv.m3u8",
"https://raw.githubusercontent.com/joevess/IPTV/main/home.m3u8",

// https://github.com/zbefine/iptv
"https://raw.githubusercontent.com/zbefine/iptv/main/iptv.m3u",

// https://github.com/YanG-1989/m3u
"https://raw.githubusercontent.com/YanG-1989/m3u/main/Gather.m3u",

// https://github.com/YueChan/Live
"https://raw.githubusercontent.com/YueChan/Live/main/APTV.m3u",
"https://raw.githubusercontent.com/YueChan/Live/main/Global.m3u",
"https://raw.githubusercontent.com/YueChan/Live/main/IPTV.m3u",

"https://freetv.fun/test_channels_new.m3u",

// https://github.com/SPX372928/MyIPTV
"https://raw.githubusercontent.com/SPX372928/MyIPTV/master/%E9%BB%91%E9%BE%99%E6%B1%9FPLTV%E7%A7%BB%E5%8A%A8CDN%E7%89%88.txt",

// https://github.com/vbskycn/iptv
"https://live.zbds.top/tv/iptv6.m3u",
"https://ghp.ci/raw.githubusercontent.com/vbskycn/iptv/refs/heads/master/tv/iptv4.m3u",

// https://github.com/yuanzl77/IPTV
"http://175.178.251.183:6689/live.m3u",

// https://github.com/BurningC4/Chinese-IPTV
"https://raw.githubusercontent.com/BurningC4/Chinese-IPTV/master/TV-IPV4.m3u",

// https://github.com/Moexin/IPTV
"https://raw.githubusercontent.com/Moexin/IPTV/Files/CCTV.m3u",
"https://raw.githubusercontent.com/Moexin/IPTV/Files/CNTV.m3u",
"https://raw.githubusercontent.com/Moexin/IPTV/Files/IPTV.m3u",
).map {
Source(
uri = it
)
}, object : TypeToken<List<Source>>() {}.type
) ?: ""
var DEFAULT_SOURCES = ""

private lateinit var sp: SharedPreferences

Expand All @@ -131,6 +81,19 @@ object SP {
Context.MODE_PRIVATE
)

context.resources.openRawResource(R.raw.sources).bufferedReader()
.use {
val str = it.readText()
if (str.isNotEmpty()) {
DEFAULT_SOURCES = Gson().toJson(Gua().decode(str).trim().split("\n").map { i ->
Source(
uri = i
)
}, object : TypeToken<List<Source>>() {}.type
) ?: ""
}
}

Log.i(TAG, "group position $positionGroup")
Log.i(TAG, "list position $position")
Log.i(TAG, "default channel $channel")
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/lizongying/mytv0/models/Sources.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.lizongying.mytv0.data.Source
class Sources {
private val type = object : TypeToken<List<Source>>() {}.type
var version = 0
private val gson = Gson()

private val _removed = MutableLiveData<Pair<Int, Int>>()
val removed: LiveData<Pair<Int, Int>>
Expand Down Expand Up @@ -37,7 +38,6 @@ class Sources {

fun setChecked(position: Int) {
_checked.value = position
SP.config = getSource(position)!!.uri
}

fun setSourceChecked(position: Int, checked: Boolean): Boolean {
Expand All @@ -56,7 +56,7 @@ class Sources {

private fun setSources(sources: List<Source>) {
_sources.value = sources
SP.sources = Gson().toJson(sources, type) ?: ""
SP.sources = gson.toJson(sources, type) ?: ""
}

fun addSource(source: Source) {
Expand All @@ -69,7 +69,7 @@ class Sources {
_sources.value = sourcesValue.toMutableList().apply {
add(0, source)
}
SP.sources = Gson().toJson(sourcesValue, type) ?: ""
SP.sources = gson.toJson(sourcesValue, type) ?: ""

_added.value = Pair(sourcesValue.size - 1, version)
version++
Expand All @@ -86,7 +86,7 @@ class Sources {
_sources.value = sourcesValue.toMutableList().apply {
removeAt(index)
}
SP.sources = Gson().toJson(sourcesValue, type) ?: ""
SP.sources = gson.toJson(sourcesValue, type) ?: ""

_removed.value = Pair(index, version)
version++
Expand All @@ -108,7 +108,7 @@ class Sources {
fun init() {
if (!SP.sources.isNullOrEmpty()) {
try {
val sources: List<Source> = Gson().fromJson(SP.sources!!, type)
val sources: List<Source> = gson.fromJson(SP.sources!!, type)
setSources(sources)
} catch (e: Exception) {
e.printStackTrace()
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/raw/channels.txt

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/main/res/raw/sources.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
䷯䷋䷃䷵䷟䷋䷽䷄䷴䷻䷍䷶䷯䷅䷑䷔䷴䷐䷑䷚䷸䷐䷥䷕䷸䷐䷱䷝䷯䷮䷙䷘䷴䷐䷷䷌䷸䷜䷍䷵䷱䷂䷍䷝䷽䷉䷧䷌䷯䷅䷖䷹䷷䷂䷙䷝䷽䷉䷧䷦䷯䷋䷃䷵䷟䷋䷽䷄䷴䷻䷍䷶䷯䷅䷑䷔䷴䷐䷑䷚䷸䷐䷥䷕䷸䷐䷱䷝䷯䷮䷙䷘䷴䷐䷷䷌䷸䷜䷍䷵䷱䷂䷍䷝䷽䷉䷧䷌䷯䷅䷃䷹䷴䷐䷵䷼䷱䷆䷕䷣䷱䷋䷃䷒䷟䷼䷣䷌䷴䷹䷨䷕䷱䷐䷧䷰䷑䷐䷢䷰䷸䷮䷔䷰䷑䷹䷥䷕䷸䷐䷟䷰䷭䷹䷍䷝䷴䷉䷃䷹䷴䷹䷵䷼䷱䷜䷍䷕䷸䷐䷃䷔䷛䷇䷙䷝䷽䷉䷧䷦䷯䷋䷃䷵䷟䷋䷽䷄䷴䷻䷍䷕䷟䷋䷃䷹䷴䷮䷍䷻䷑䷻䷙䷘䷯䷅䷃䷣䷱䷮䷎䷰䷯䷮䷡䷌䷯䷅䷖䷵䷱䷂䷍䷕䷸䷐䷃䷔䷛䷇䷙䷝䷽䷉䷧䷦䷯䷋䷃䷵䷟䷋䷽䷄䷴䷻䷍䷻䷭䷅䷟䷰䷑䷹䷔䷵䷯䷋䷿䷂䷱䷅䷷䷔䷟䷐䷷䷌䷸䷘䷃䷔䷸䷘䷆䷰䷭䷹䷍䷝䷴䷵䷱䷥䷸䷉䷑䷕䷸䷂䷍䷕䷟䷋䷃䷹䷴䷮䷢䷒䷯䷜䷍䷘䷑䷇䷍䷌䷱䷅䷃䷒䷱䷅䷆䷌䷟䷐䷿䷼䷱䷮䷨䷵䷴䷐䷵䷼䷱䷆䷕䷣䷱䷋䷃䷒䷟䷼䷣䷌䷴䷉䷳䷚䷱䷻䷙䷘䷯䷅䷃䷣䷱䷮䷳䷥䷟䷹䷿䷻䷭䷹䷍䷰䷱䷬䷿䷰䷱䷇䷙䷩䷸䷹䷵䷌䷯䷐䷍䷔䷱䷐䷿䷼䷟䷻䷍䷳䷧䷢䷃䷮䷴䷹䷥䷚䷯䷮䷊䷌䷟䷹䷍䷥䷟䷐䷷䷔䷟䷻䷍䷕䷟䷋䷃䷹䷅䷉䷷䷌䷱䷅䷳䷩䷑䷅䷽䷰䷸䷺䷷䷥䷇䷐䷚䷵䷱䷋䷖䷼䷞䷂䷡䷌䷟䷐䷢䷉䷴䷐䷱䷕䷱䷬䷚䷥䷭䷘䷿䷼䷑䷅䷳䷩䷸䷹䷙䷵䷑䷮䷙䷵䷴䷐䷷䷌䷸䷜䷍䷾䷸䷹䷿䷹䷑䷅䷷䷼䷴䷵䷔䷆䷿䷢䷭䷌䷸䷮䷢䷕䷸䷂䷍䷼䷸䷉䷿䷻䷭䷹䷿䷼䷴䷹䷚䷌䷸䷮䷿䷫䷟䷹䷍䷥䷟䷐䷷䷔䷟䷻䷙䷝䷽䷉䷧䷦䷯䷋䷃䷵䷟䷋䷽䷄䷴䷻䷍䷻䷭䷅䷟䷰䷑䷹䷔䷵䷯䷋䷿䷂䷱䷅䷷䷔䷟䷐䷷䷌䷸䷘䷃䷔䷸䷘䷆䷰䷭䷹䷍䷝䷴䷹䷕䷌䷑䷅䷑䷔䷟䷉䷽䷌䷜䷿䷖䷧䷿䷂䷍䷝䷭䷮䷔䷰䷴䷹䷔䷒䷱䷋䷭䷰䷸䷺䷷䷥䷞䷁䷕䷣䷱䷋䷃䷒䷟䷼䷣䷌䷴䷉䷳䷚䷱䷻䷙䷘䷯䷅䷃䷣䷱䷮䷳䷥䷟䷹䷿䷻䷭䷹䷍䷰䷱䷬䷿䷰䷱䷇䷙䷩䷸䷹䷵䷌䷯䷐䷍䷔䷱䷐䷿䷼䷟䷻䷍䷳䷧䷢䷃䷮䷴䷹䷥䷚䷯䷮䷊䷌䷯䷬䷍䷝䷑䷜䷙䷝䷽䷉䷧䷊䷇䷐䷚䷵䷱䷋䷖䷼䷞䷂䷡䷌䷟䷐䷢䷉䷴䷐䷱䷕䷱䷬䷚䷥䷭䷘䷿䷼䷑䷅䷳䷩䷸䷹䷙䷵䷑䷮䷙䷵䷴䷐䷷䷌䷸䷜䷍䷄䷭䷐䷿䷐䷯䷮䷙䷔䷴䷹䷔䷒䷱䷋䷭䷌䷸䷮䷢䷕䷸䷂䷍䷕䷟䷋䷃䷹䷴䷐䷵䷼䷱䷆䷕䷣䷱䷋䷃䷒䷟䷼䷣䷌䷴䷉䷳䷚䷱䷻䷙䷘䷯䷅䷃䷣䷱䷮䷳䷥䷟䷹䷿䷻䷭䷹䷍䷰䷱䷬䷿䷰䷱䷇䷙䷩䷸䷹䷵䷌䷮䷮䷢䷰䷃䷻䷵䷨䷞䷺䷗䷙䷴䷹䷵䷼䷱䷜䷍䷝䷭䷮䷔䷰䷴䷵䷱䷚䷱䷬䷚䷔䷟䷂䷙䷝䷽䷉䷧䷦䷯䷋䷃䷵䷟䷋䷽䷄䷴䷻䷍䷻䷭䷅䷟䷰䷑䷹䷔䷵䷯䷋䷿䷂䷱䷅䷷䷔䷟䷐䷷䷌䷸䷘䷃䷔䷸䷘䷆䷰䷭䷹䷍䷝䷴䷥䷔䷥䷑䷧䷷䷣䷭䷮䷊䷌䷺䷬䷔䷹䷑䷜䷍䷝䷭䷮䷔䷰䷴䷵䷢䷆䷿䷢䷭䷰䷸䷺䷷䷥䷇䷐䷚䷵䷱䷋䷖䷼䷞䷂䷡䷌䷟䷐䷢䷉䷴䷐䷱䷕䷱䷬䷚䷥䷭䷘䷿䷼䷑䷅䷳䷩䷸䷹䷙䷵䷑䷮䷙䷵䷴䷐䷷䷌䷸䷜䷍䷑䷱䷮䷿䷓䷯䷬䷢䷰䷴䷵䷨䷕䷱䷐䷧䷌䷸䷮䷢䷕䷸䷂䷍䷋䷸䷬䷍䷂䷭䷮䷒䷰䷸䷺䷷䷥䷇䷐䷚䷵䷱䷋䷖䷼䷞䷂䷡䷌䷟䷐䷢䷉䷴䷐䷱䷕䷱䷬䷚䷥䷭䷘䷿䷼䷑䷅䷳䷩䷸䷹䷙䷵䷑䷮䷙䷵䷴䷐䷷䷌䷸䷜䷍䷑䷱䷮䷿䷓䷯䷬䷢䷰䷴䷵䷨䷕䷱䷐䷧䷌䷸䷮䷢䷕䷸䷂䷍䷳䷧䷢䷃䷮䷴䷐䷵䷼䷱䷆䷕䷣䷱䷋䷃䷒䷟䷼䷣䷌䷴䷹䷑䷻䷑䷮䷿䷵䷱䷂䷙䷐䷱䷮䷊䷌䷱䷬䷿䷼䷱䷢䷍䷩䷯䷬䷢䷰䷸䷐䷿䷶䷟䷥䷍䷰䷑䷅䷟䷰䷸䷺䷷䷥䷇䷐䷚䷵䷱䷋䷖䷼䷞䷂䷡䷌䷟䷐䷢䷉䷴䷐䷱䷕䷱䷬䷚䷥䷭䷘䷿䷼䷑䷅䷳䷩䷸䷹䷙䷵䷑䷮䷙䷵䷴䷐䷷䷌䷸䷜䷍䷺䷧䷢䷗䷼䷷䷼䷎䷙䷽䷩䷗䷌䷺䷅䷔䷳䷧䷢䷃䷮䷴䷹䷥䷚䷟䷉䷃䷔䷟䷂䷡䷔䷃䷺䷲䷔䷆䷲䷎䷔䷞䷺䷏䷔䷃䷺䷲䷔䷆䷲䷧䷔䷞䷺䷲䷔䷃䷺䷭䷔䷆䷩䷏䷔䷞䷧䷑䷆䷺䷢䷃䷮䷳䷧䷧䷉䷳䷧䷏䷉䷳䷧䷳䷇䷳䷧䷧䷥䷳䷺䷚䷖䷳䷧䷏䷊䷆䷵䷃䷞䷳䷧䷧䷉䷳䷺䷗䷙䷳䷺䷗䷊䷴䷘䷃䷊䷱䷁䷕䷣䷱䷋䷃䷒䷟䷼䷣䷌䷴䷹䷨䷕䷱䷐䷧䷰䷛䷐䷳䷲䷟䷻䷙䷵䷸䷉䷁䷌䷱䷋䷭䷌䷯䷅䷖䷵䷱䷩䷭䷰䷸䷺䷷䷥䷇䷐䷚䷵䷱䷋䷖䷼䷞䷂䷡䷌䷑䷹䷚䷒䷴䷐䷷䷕䷴䷉䷳䷚䷱䷻䷙䷘䷯䷅䷃䷣䷱䷮䷳䷥䷟䷹䷿䷻䷭䷹䷍䷰䷱䷬䷿䷰䷱䷇䷙䷩䷸䷹䷵䷌䷱䷐䷳䷼䷯䷉䷔䷩䷸䷂䷍䷕䷟䷋䷃䷹䷴䷉䷳䷔䷑䷘䷽䷌䷯䷬䷿䷚䷑䷋䷽䷌䷸䷮䷢䷼䷱䷬䷿䷻䷴䷉䷃䷹䷴䷹䷔䷒䷱䷋䷭䷵䷴䷐䷵䷼䷱䷆䷕䷣䷱䷋䷃䷒䷞䷂䷡䷌䷽䷺䷟䷥䷴䷩䷏䷉䷞䷇䷊䷻䷷䷺䷏䷰䷽䷺䷗䷼䷞䷩䷭䷹䷞䷓䷲䷌䷸䷬䷔䷹䷑䷜䷙䷝䷽䷉䷧䷦䷯䷋䷃䷵䷟䷋䷽䷄䷴䷻䷍䷻䷭䷅䷟䷰䷑䷹䷔䷵䷯䷋䷿䷂䷱䷅䷷䷔䷟䷐䷷䷌䷸䷘䷃䷔䷸䷘䷆䷰䷭䷹䷍䷝䷴䷵䷳䷥䷟䷐䷙䷕䷸䷐䷱䷓䷷䷇䷍䷓䷯䷬䷔䷰䷑䷅䷷䷔䷴䷧䷔䷆䷿䷢䷭䷌䷸䷮䷢䷼䷱䷬䷿䷻䷴䷥䷃䷮䷴䷧䷔䷆䷿䷩䷆䷰䷸䷺䷷䷥䷇䷐䷚䷵䷱䷋䷖䷼䷞䷂䷡䷌䷑䷹䷔䷵䷯䷋䷿䷂䷴䷐䷷䷌䷸䷜䷡䷙䷷䷺䷎䷉䷛䷬䷔䷚䷸䷼䷲䷥䷽䷩䷟䷌䷯䷅䷖䷵䷱䷂䷍䷂䷸䷬䷍䷂䷴䷹䷥䷚䷯䷮䷊䷌䷯䷅䷖䷵䷱䷂䷙䷵䷛䷋䷆䷦䷯䷋䷃䷵䷟䷋䷽䷄䷴䷻䷍䷘䷯䷅䷃䷣䷱䷮䷎䷰䷭䷹䷍䷝䷴䷹䷚䷥䷭䷮䷙䷘䷷䷼䷟䷒䷽䷺䷁䷨䷴䷹䷥䷙䷴䷮䷔䷒䷱䷋䷭䷌䷭䷐䷨䷌䷭䷂䷍䷝䷭䷮䷔䷰䷴䷵䷔䷆䷿䷢䷭䷝䷯䷅䷖䷹䷷䷇䷙䷝䷽䷉䷧䷦䷯䷋䷃䷵䷟䷋䷽䷄䷴䷻䷍䷘䷯䷅䷃䷣䷱䷮䷎䷰䷭䷹䷍䷝䷴䷹䷚䷥䷭䷮䷙䷘䷷䷼䷟䷒䷽䷺䷁䷨䷴䷹䷥䷙䷴䷮䷔䷒䷱䷋䷭䷌䷭䷐䷨䷌䷭䷂䷍䷝䷭䷮䷔䷰䷴䷵䷔䷆䷿䷢䷭䷝䷯䷅䷖䷹䷷䷂䷙䷝䷽䷉䷧〇
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version_code": 16975875, "version_name": "v1.3.8.3"}
{"version_code": 16975876, "version_name": "v1.3.8.4"}

0 comments on commit 0778d09

Please sign in to comment.