fixed OnetwothreeTv TimefourTv home

This commit is contained in:
hexated 2022-10-04 19:51:29 +07:00
parent 4f4755bf56
commit c1c4dd91de
4 changed files with 37 additions and 32 deletions

View file

@ -1,5 +1,5 @@
// use an integer for version numbers
version = 2
version = 3
cloudstream {

View file

@ -29,9 +29,19 @@ class OnetwothreeTv : MainAPI() {
)
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
val items = mutableListOf<HomePageList>()
val nonPaged =
(request.name == "Top Streams" || request.name == "Latest Streams") && page <= 1
if (nonPaged) {
val res = app.get(request.data).document
val home = res.select("div.col-md-3.col-sm-6").mapNotNull {
it.toSearchResult()
}
items.add(HomePageList(request.name, home, true))
}
val document = if (request.name.contains("USA")) {
app.post(
if (request.name == "United States (USA)") {
val res = app.post(
"$mainUrl/wp-admin/admin-ajax.php", data = mapOf(
"action" to "_123tv_load_more_videos_from_category",
"cat_id" to request.data,
@ -40,20 +50,13 @@ class OnetwothreeTv : MainAPI() {
"X-Requested-With" to "XMLHttpRequest"
)
).document
} else {
app.get(request.data).document
}
val home = document.select("div.col-md-3.col-sm-6").mapNotNull {
val home = res.select("div.col-md-3.col-sm-6").mapNotNull {
it.toSearchResult()
}
return newHomePageResponse(
list = HomePageList(
name = request.name,
list = home,
isHorizontalImages = true
),
hasNext = true
)
items.add(HomePageList(request.name, home, true))
}
return newHomePageResponse(items)
}

View file

@ -1,5 +1,5 @@
// use an integer for version numbers
version = 1
version = 2
cloudstream {

View file

@ -28,26 +28,28 @@ class TimefourTv : MainAPI() {
page: Int,
request: MainPageRequest
): HomePageResponse {
val document = if (request.name == "All Channels") {
if (page == 1) {
val items = mutableListOf<HomePageList>()
val nonPaged = request.name != "All Channels" && page <= 1
if(nonPaged) {
val res = app.get("${request.data}.php").document
val home = res.select("div.tab-content ul li").mapNotNull {
it.toSearchResult()
}
items.add(HomePageList(request.name, home, true))
}
if (request.name == "All Channels") {
val res = if (page == 1) {
app.get("${request.data}.php").document
} else {
app.get("${request.data}${page.minus(1)}.php").document
}
} else {
app.get("${request.data}.php").document
}
val home = document.select("div.tab-content ul li").mapNotNull {
val home = res.select("div.tab-content ul li").mapNotNull {
it.toSearchResult()
}
return newHomePageResponse(
list = HomePageList(
name = request.name,
list = home,
isHorizontalImages = true
),
hasNext = true
)
items.add(HomePageList(request.name, home, true))
}
return newHomePageResponse(items)
}
private fun Element.toSearchResult(): LiveSearchResponse? {