cloudstream-extensions-hexated/Movierulzhd/src/main/kotlin/com/hexated/Hdmovie2.kt

89 lines
3.3 KiB
Kotlin
Raw Normal View History

2023-07-27 16:09:25 +00:00
package com.hexated
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.SubtitleFile
import com.lagradost.cloudstream3.apmap
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.mainPageOf
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.loadExtractor
import org.jsoup.Jsoup
class Hdmovie2 : Movierulzhd() {
override var mainUrl = "https://hdmovie2.boo"
2023-07-27 16:09:25 +00:00
override var name = "Hdmovie2"
override val mainPage = mainPageOf(
"trending" to "Trending",
"movies" to "Movies",
"genre/tv-series" to "TV-Series",
"genre/netflix" to "Netflix",
"genre/zee5-tv-series" to "Zee5 TV Series",
)
override suspend fun loadLinks(
data: String,
isCasting: Boolean,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
): Boolean {
if (data.startsWith("{")) {
val loadData = tryParseJson<LinkData>(data)
2023-10-21 12:08:46 +00:00
val source = app.post(
url = "$directUrl/wp-admin/admin-ajax.php", data = mapOf(
"action" to "doo_player_ajax", "post" to "${loadData?.post}", "nume" to "${loadData?.nume}", "type" to "${loadData?.type}"
), referer = data, headers = mapOf("Accept" to "*/*", "X-Requested-With" to "XMLHttpRequest"
)).parsed<ResponseHash>().embed_url.getIframe()
2023-07-27 16:09:25 +00:00
if (!source.contains("youtube")) loadExtractor(
source,
"$directUrl/",
subtitleCallback,
callback
)
} else {
var document = app.get(data).document
if (document.select("title").text() == "Just a moment...") {
document = app.get(data, interceptor = interceptor).document
}
val id = document.select("meta#dooplay-ajax-counter").attr("data-postid")
val type = if (data.contains("/movies/")) "movie" else "tv"
document.select("ul#playeroptionsul > li").map {
it.attr("data-nume")
}.apmap { nume ->
2023-10-20 21:40:44 +00:00
val source = app.post(
url = "$directUrl/wp-admin/admin-ajax.php", data = mapOf(
"action" to "doo_player_ajax", "post" to id, "nume" to nume, "type" to type
), referer = data, headers = mapOf("Accept" to "*/*", "X-Requested-With" to "XMLHttpRequest")
2023-07-27 16:09:25 +00:00
).parsed<ResponseHash>().embed_url.getIframe()
when {
!source.contains("youtube") -> loadExtractor(
source,
"$directUrl/",
subtitleCallback,
callback
)
else -> return@apmap
}
}
}
return true
}
private fun String.getIframe(): String {
return Jsoup.parse(this).select("iframe").attr("src")
}
data class LinkData(
val type: String? = null,
val post: String? = null,
val nume: String? = null,
)
data class ResponseHash(
@JsonProperty("embed_url") val embed_url: String,
@JsonProperty("type") val type: String?,
)
}