higotv: Fix episodes, again. Added poster to episodes

This commit is contained in:
CakesTwix 2024-03-03 21:01:43 +02:00
parent 62ba65e9c6
commit 41f205f8d3
Signed by: CakesTwix
GPG key ID: 7B11051D5CE19825
3 changed files with 30 additions and 34 deletions

View file

@ -1,5 +1,5 @@
// use an integer for version numbers // use an integer for version numbers
version = 3 version = 4
dependencies{ dependencies{
implementation("com.google.code.gson:gson:2.9.0") implementation("com.google.code.gson:gson:2.9.0")

View file

@ -23,6 +23,7 @@ import com.lagradost.cloudstream3.newHomePageResponse
import com.lagradost.cloudstream3.newMovieLoadResponse import com.lagradost.cloudstream3.newMovieLoadResponse
import com.lagradost.cloudstream3.toRatingInt import com.lagradost.cloudstream3.toRatingInt
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.M3u8Helper
import com.lagradost.models.PlayerJson import com.lagradost.models.PlayerJson
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
@ -134,28 +135,28 @@ class HigoTVProvider : MainAPI() {
// Parse episodes // Parse episodes
val episodes = mutableListOf<Episode>() val episodes = mutableListOf<Episode>()
document.select("div.player") document.select("iframe").forEach {
.select("script").forEach { if(it.attr("src").isNotEmpty()){
if(!it.html().substringAfter("file:").substringBeforeLast("})").contains("folder:")) return@forEach val playerDocument = app.get(it.attr("src")).document
// Log.d("CakesTwix-Debug", playerDocument.select("script[type*=text/javascript]").html().substringAfter("file:'").substringBefore("',"))
val parsedJSON = gson.fromJson<List<PlayerJson>>( val parsedJSON = gson.fromJson<List<PlayerJson>>(
it.html().substringAfter("file:").substringBeforeLast("})"), listPlayer playerDocument.select("script[type*=text/javascript]").html().substringAfter("file:'").substringBefore("',"), listPlayer
) )
if (parsedJSON[0].title.isNullOrEmpty()) return@forEach
parsedJSON[0].folder?.forEach { voices -> parsedJSON[0].folder?.forEach { seasons ->
if (voices != null) { seasons.folder?.forEach {
if (voices.file.isNullOrBlank()) return@forEach
episodes.add( episodes.add(
Episode( Episode(
"${url}, ${voices.title}", "${url}, ${it.title}",
voices.title, it.title,
episode = voices.title!!.replace(" Серія", "").toIntOrNull(), episode = it.title!!.replace("Серія ", "").toIntOrNull(),
posterUrl = it.poster
) )
) )
} }
} }
} }
}
// Log.d("CakesTwix-Debug", playerRawJson) // Log.d("CakesTwix-Debug", playerRawJson)
@ -188,7 +189,7 @@ class HigoTVProvider : MainAPI() {
// It works when I click to view the series // It works when I click to view the series
override suspend fun loadLinks( override suspend fun loadLinks(
data: String, // (Serial) [Voice name, Series name] data: String, // (Serial) [url, episode name]
isCasting: Boolean, isCasting: Boolean,
subtitleCallback: (SubtitleFile) -> Unit, subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
@ -198,29 +199,23 @@ class HigoTVProvider : MainAPI() {
val document = app.get(dataList[0]).document val document = app.get(dataList[0]).document
document.select("div.player") document.select("iframe").forEach {
.select("script").forEach { if(it.attr("src").isNotEmpty()){
if(!it.html().substringAfter("file:").substringBeforeLast("})").contains("folder:")) return@forEach val playerDocument = app.get(it.attr("src")).document
// Log.d("CakesTwix-Debug", playerDocument.select("script[type*=text/javascript]").html().substringAfter("file:'").substringBefore("',"))
val parsedJSON = gson.fromJson<List<PlayerJson>>( val parsedJSON = gson.fromJson<List<PlayerJson>>(
it.html().substringAfter("file:").substringBeforeLast("})"), listPlayer playerDocument.select("script[type*=text/javascript]").html().substringAfter("file:'").substringBefore("',"), listPlayer
) )
if (parsedJSON[0].title.isNullOrEmpty()) return@forEach
parsedJSON[0].folder?.forEach { voices -> parsedJSON[0].folder?.forEach { seasons ->
if (voices != null) { seasons.folder?.forEach {
if (voices.file.isNullOrBlank() || voices.title != dataList[1]) return@forEach if(it.title != dataList[1]) return@forEach
M3u8Helper.generateM3u8(
callback.invoke( source = parsedJSON[0].title!!,
ExtractorLink( streamUrl = it.file!!,
voices.file, referer = "https://moonanime.art"
name = "${parsedJSON[0].title}", ).forEach(callback)
voices.file, }
"",
0,
isM3u8 = false,
)
)
} }
} }
} }

View file

@ -10,4 +10,5 @@ data class PlayerJson (
val title : String?, val title : String?,
val file : String?, val file : String?,
val folder: List<PlayerJson>?, val folder: List<PlayerJson>?,
val poster: String?
) )