From 72996766b95b337bf19477018320274a290f67ec Mon Sep 17 00:00:00 2001 From: imper1aldev Date: Wed, 4 Oct 2023 15:14:37 -0600 Subject: [PATCH] Update HentaiLAProvider.kt --- .../kotlin/com/lagradost/HentaiLAProvider.kt | 85 ++++++++++++++++--- 1 file changed, 73 insertions(+), 12 deletions(-) diff --git a/HentaiLAProvider/src/main/kotlin/com/lagradost/HentaiLAProvider.kt b/HentaiLAProvider/src/main/kotlin/com/lagradost/HentaiLAProvider.kt index 1605d2f..78e6c1a 100644 --- a/HentaiLAProvider/src/main/kotlin/com/lagradost/HentaiLAProvider.kt +++ b/HentaiLAProvider/src/main/kotlin/com/lagradost/HentaiLAProvider.kt @@ -4,6 +4,7 @@ import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.Qualities import java.util.* +import com.lagradost.cloudstream3.utils.M3u8Helper.Companion.generateM3u8 class HentaiLAProvider : MainAPI() { @@ -69,6 +70,16 @@ class HentaiLAProvider : MainAPI() { val soup = app.get(url).document val title = soup.selectFirst(".hentai_cover img")!!.attr("alt").substringBefore("cover").trim() val description = soup.selectFirst("div.vraven_expand > div.vraven_text.single > p")!!.text() + var genres = listOf() + var year = 0 + soup.select(".single_data").forEach { + if (it.select("h5").text().contains("Genre", true)) { + genres = it.select(".list a").map { it.text() } + } + if (it.select("h5").text().contains("Release", true)) { + year = it.selectFirst("div a")?.text()?.toInt() ?: 0 + } + } val episodes = soup.select(".hentai__episodes .hentai__chapter").map { val href = it.select("a").attr("abs:href") @@ -83,6 +94,8 @@ class HentaiLAProvider : MainAPI() { addEpisodes(DubStatus.Subbed, episodes) showStatus = ShowStatus.Completed plot = description + tags = genres + year = year } } @@ -92,21 +105,69 @@ class HentaiLAProvider : MainAPI() { subtitleCallback: (SubtitleFile) -> Unit, callback: (ExtractorLink) -> Unit ): Boolean { - app.get(data).document.select("script").apmap { script -> - if (script.data().contains("window.hola_player({")) { - script.data().substringAfter("sources: [{src: \"").substringBefore("\",").let { url -> - callback.invoke( - ExtractorLink( - this.name, - this.name, - url, - referer = "", - quality = Qualities.P720.value + val document = app.get(data).document + val iframe = document.select("iframe").attr("abs:src") + val videoDocument = app.get(iframe).document + + videoDocument.select("script:containsData(const loaded = async ())").map { script -> + val action = script.data().substringAfter("'action', '").substringBefore("'") + val a = script.data().substringAfter("'a', '").substringBefore("'") + val b = script.data().substringAfter("'b', '").substringBefore("'") + + val playerHeaders = mapOf( + "authority" to "hentaila.tv", + "accept" to "*/*", + "accept-language" to "en-US,en;q=0.9", + "content-type" to "multipart/form-data; boundary=----WebKitFormBoundarybab9W9OlAvbOUs9J", + "origin" to "https://hentaila.tv", + "user-agent" to USER_AGENT, + "sec-ch-ua" to "\"Chromium\";v=\"116\", \"Not)A;Brand\";v=\"24\", \"Opera\";v=\"102\"", + "sec-ch-ua-mobile" to "?0", + "sec-fetch-dest" to "empty", + "sec-fetch-mode" to "cors", + "sec-fetch-site" to "same-origin", + ) + val urlRequest = "https://hentaila.tv/wp-content/plugins/player-logic/api.php" + val hlsJson = app.post(urlRequest, headers = playerHeaders, data = mapOf("action" to action, "a" to a, "b" to b)).parsed() + hlsJson.data.sources.filter { it.src!!.isEmpty() }.apmap { hls -> + generateM3u8( + this.name, + hls.src ?: "", + "", + headers = mapOf( + "Accept" to "*/*", + "Accept-Encoding" to "gzip, deflate, br", + "Accept-Language" to "en-US,en;q=0.9", + "Connection" to "keep-alive", + "Host" to "master-es.cyou", + "Origin" to "https://hentaila.tv", + "Sec-Fetch-Dest" to "empty", + "Sec-Fetch-Mode" to "cors", + "Sec-Fetch-Site" to "cross-site", + "User-Agent" to USER_AGENT, + "sec-ch-ua" to "\"Chromium\";v=\"116\", \"Not)A;Brand\";v=\"24\", \"Opera\";v=\"102\"", + "sec-ch-ua-mobile" to "?0" ) - ) - } + ).forEach(callback) } } return true } + + data class HlsJson( + val status: Boolean, + val data: Data = Data(), + ) + + data class Data( + val image: String? = null, + val mosaic: String? = null, + val sources: List = arrayListOf(), + ) + + data class Source( + val src: String? = null, + val type: String? = null, + val label: String? = null, + ) } \ No newline at end of file