Skip to content

Commit

Permalink
Update HentaiLAProvider.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
imper1aldev committed Oct 4, 2023
1 parent c9bab3f commit 7299676
Showing 1 changed file with 73 additions and 12 deletions.
85 changes: 73 additions & 12 deletions HentaiLAProvider/src/main/kotlin/com/lagradost/HentaiLAProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand Down Expand Up @@ -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<String>()
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")
Expand All @@ -83,6 +94,8 @@ class HentaiLAProvider : MainAPI() {
addEpisodes(DubStatus.Subbed, episodes)
showStatus = ShowStatus.Completed
plot = description
tags = genres
year = year
}
}

Expand All @@ -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>()
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<Source> = arrayListOf(),
)

data class Source(
val src: String? = null,
val type: String? = null,
val label: String? = null,
)
}

0 comments on commit 7299676

Please sign in to comment.