try to speed up the getMainPage

This commit is contained in:
Eddy 2022-10-23 20:40:22 +02:00
parent 9fef2e58f4
commit 2447cee079
1 changed files with 21 additions and 9 deletions

View File

@ -595,8 +595,8 @@ class MacIPTVProvider(override var lang: String) : MainAPI() {
val rgxcodeCountry = findKeyWord(codeCountry)
val arrayHomepage = arrayListOf<HomePageList>()
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
val arrayHomepage = arrayListOf<HomePageList>()
if (!firstInitDone) {
val headerIPTV = getAuthHeader()
val url_info =
@ -642,24 +642,26 @@ class MacIPTVProvider(override var lang: String) : MainAPI() {
responseGetGenretoJSON.js.forEach { js ->
val idGenre = js.id
val categoryTitle = js.title.toString()
val arraymedia = ArrayList<Channel>()
if (idGenre!!.contains("""\d""".toRegex()) && (categoryTitle.uppercase()
.contains(rgxcodeCountry) ||
categoryTitle.isContainsTargetCountry()
)
) {
AllchannelstoJSON.forEach { data ->
val itr = AllchannelstoJSON.iterator()
while (itr.hasNext()) {
val data = itr.next()
val genre = data.tvGenreId
if (genre != null) {
if (genre == idGenre) {
itr.remove()
val name = data.name.toString()
val tv_genre_id = data.tvGenreId
val idCH = data.id
val link = "http://localhost/ch/$idCH" + "_"
val logo = data.logo?.replace("""\""", "")
val ch_id = data.cmds[0].chId
arraymediaPlaylist.add(
arraymedia.add(
Channel(
name,
link,
@ -670,7 +672,18 @@ class MacIPTVProvider(override var lang: String) : MainAPI() {
ch_id
)
)
arraymediaPlaylist.add(
Channel(
name,
link,
logo,
"",
idCH,
tv_genre_id,
ch_id
)
)
}
}
}
@ -680,8 +693,8 @@ class MacIPTVProvider(override var lang: String) : MainAPI() {
val groupMedia = ArrayList<String>()
var b_new: String
var newgroupMedia: Boolean
val home = arraymediaPlaylist.mapNotNull { media ->
val b = cleanTitle(media.title)//
val home = arraymedia.mapNotNull { media ->
val b = cleanTitle(media.title)
b_new = b.take(6)
newgroupMedia = true
for (nameMedia in groupMedia) {
@ -747,5 +760,4 @@ class MacIPTVProvider(override var lang: String) : MainAPI() {
regxNbr.find(str)?.groupValues?.get(0)?.trim()?.toInt() ?: 1000
})
}
}
}