higotv: Add movies and reformat code

This commit is contained in:
CakesTwix 2024-01-18 16:04:36 +02:00
parent cb40ace826
commit 1d63e72987
Signed by: CakesTwix
GPG key ID: 7B11051D5CE19825

View file

@ -1,6 +1,5 @@
package com.lagradost
import android.util.Log
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.lagradost.cloudstream3.AnimeSearchResponse
@ -24,7 +23,6 @@ import com.lagradost.cloudstream3.newHomePageResponse
import com.lagradost.cloudstream3.newMovieLoadResponse
import com.lagradost.cloudstream3.toRatingInt
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.M3u8Helper
import com.lagradost.models.PlayerJson
import org.jsoup.nodes.Element
@ -36,14 +34,13 @@ class HigoTVProvider : MainAPI() {
override val hasMainPage = true
override var lang = "uk"
override val hasDownloadSupport = true
override val supportedTypes = setOf(
TvType.Anime
)
override val supportedTypes = setOf(TvType.Anime)
private val searchUrl = "https://higotv.fun/search/doSearch"
// Sections
override val mainPage = mainPageOf(
override val mainPage =
mainPageOf(
"vsevishlo" to "Виходить, Вийшло",
)
@ -66,15 +63,10 @@ class HigoTVProvider : MainAPI() {
private val TAG = "$name-Debug"
override suspend fun getMainPage(
page: Int,
request: MainPageRequest
): HomePageResponse {
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
val document = app.get("$mainUrl/${request.data}").document
val home = document.select(animeSelector).map {
it.toSearchResponse()
}
val home = document.select(animeSelector).map { it.toSearchResponse() }
return newHomePageResponse(request.name, home)
}
@ -89,31 +81,25 @@ class HigoTVProvider : MainAPI() {
this.posterUrl = posterUrl
addDubStatus(isDub = true)
}
}
override suspend fun search(query: String): List<SearchResponse> {
val document = app.post(
url = searchUrl,
data = mapOf("keyword" to query)
).document
val document = app.post(url = searchUrl, data = mapOf("keyword" to query)).document
return document.select(animeSelector).map {
it.toSearchResponse()
}
return document.select(animeSelector).map { it.toSearchResponse() }
}
// Detailed information
override suspend fun load(url: String): LoadResponse {
val document = app.get(url).document
// Parse info
val title = document.select(".anime-op__txt").text()
val engTitle = document.select(".anime-eng__txt").text()
val poster = fixUrl(document.select(".anime-op__img > img").attr("src"))
val tags = document.select(".span-menu-ogg a").map { it.text() }
val tvType = with(document.select(".tup-anim").text()){
val tvType =
with(document.select(".tup-anim").text()) {
when {
contains("TV SHORT") -> TvType.OVA
contains("OVA") -> TvType.OVA
@ -122,10 +108,11 @@ class HigoTVProvider : MainAPI() {
}
}
val description = document.selectFirst(descriptionSelector)?.text()?.trim()
val rating = extractIntFromString(document.select(ratingSelector).text()).toString().toRatingInt()
val rating =
extractIntFromString(document.select(ratingSelector).text()).toString().toRatingInt()
// TODO: Fix
val recommendations = document.select("div.owl-item").map {
val recommendations =
document.select("div.owl-item").map {
val title = it.select(".popular-item-title").text().trim()
// val engTitle = this.selectFirst(engTitleSelector)?.text()?.trim().toString()
val href = it.select("a.popular-item-img").attr("href").toString()
@ -141,7 +128,11 @@ class HigoTVProvider : MainAPI() {
// Parse episodes
val episodes = mutableListOf<Episode>()
val playerRawJson = document.select("div.player").select("script").html()
val playerRawJson =
document
.select("div.player")
.select("script")
.html()
.substringAfterLast("file:")
.substringBeforeLast("},")
@ -181,7 +172,7 @@ class HigoTVProvider : MainAPI() {
}
} else { // Parse as Movie.
newMovieLoadResponse(title, url, tvType, "$title, ") {
newMovieLoadResponse(title, url, tvType, "${url}, 1 Серія") {
this.posterUrl = poster
this.name = engTitle
this.year = year
@ -200,12 +191,16 @@ class HigoTVProvider : MainAPI() {
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
): Boolean {
Log.d(TAG, "loadLinks: $data")
// Log.d(TAG, "loadLinks: $data")
val dataList = data.split(", ")
val document = app.get(dataList[0]).document
val playerRawJson = document.select("div.player").select("script").html()
val playerRawJson =
document
.select("div.player")
.select("script")
.html()
.substringAfterLast("file:")
.substringBeforeLast("},")
@ -249,6 +244,5 @@ class HigoTVProvider : MainAPI() {
}
return value.value.toIntOrNull()
}
}