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

86 lines
3.1 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() {
2024-01-14 12:18:06 +00:00
override var mainUrl = "https://hdmovie2.ist"
2023-07-27 16:09:25 +00:00
override var name = "Hdmovie2"
override val mainPage = mainPageOf(
"trending" to "Trending",
"movies" to "Movies",
2024-01-14 12:18:06 +00:00
"genre/tv-series" to "TV Shows",
2023-07-27 16:09:25 +00:00
"genre/netflix" to "Netflix",
2024-01-14 12:18:06 +00:00
"genre/zee5-tv-series" to "Zee5",
2023-07-27 16:09:25 +00:00
)
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 {
2023-12-15 04:32:48 +00:00
val document = app.get(data).document
2023-07-27 16:09:25 +00:00
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?,
)
}