fixed Movierulzhd

This commit is contained in:
hexated 2022-11-29 20:08:14 +07:00
parent 4272df4072
commit 0b75e28068
4 changed files with 175 additions and 124 deletions

View File

@ -1,5 +1,5 @@
// use an integer for version numbers // use an integer for version numbers
version = 22 version = 23
cloudstream { cloudstream {

View File

@ -7,11 +7,13 @@ import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
import com.lagradost.cloudstream3.mvvm.safeApiCall import com.lagradost.cloudstream3.mvvm.safeApiCall
import com.lagradost.cloudstream3.network.CloudflareKiller import com.lagradost.cloudstream3.network.CloudflareKiller
import com.lagradost.cloudstream3.utils.* import com.lagradost.cloudstream3.utils.*
import com.lagradost.cloudstream3.utils.AppUtils.toJson
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import java.net.URI import java.net.URI
class Movierulzhd : MainAPI() { class Movierulzhd : MainAPI() {
override var mainUrl = "https://movierulzhd.life" override var mainUrl = "https://movierulzhd.life"
private var directUrl = mainUrl
override var name = "Movierulzhd" override var name = "Movierulzhd"
override val hasMainPage = true override val hasMainPage = true
override var lang = "hi" override var lang = "hi"
@ -38,7 +40,7 @@ class Movierulzhd : MainAPI() {
page: Int, page: Int,
request: MainPageRequest request: MainPageRequest
): HomePageResponse { ): HomePageResponse {
var document = app.get(request.data + page,).document var document = app.get(request.data + page).document
if(document.select("title").text() == "Just a moment...") { if(document.select("title").text() == "Just a moment...") {
document = app.get(request.data + page, interceptor = interceptor).document document = app.get(request.data + page, interceptor = interceptor).document
} }
@ -82,7 +84,7 @@ class Movierulzhd : MainAPI() {
override suspend fun search(query: String): List<SearchResponse> { override suspend fun search(query: String): List<SearchResponse> {
val link = "$mainUrl/search/$query" val link = "$mainUrl/search/$query"
var document = app.get(link,).document var document = app.get(link).document
if(document.select("title").text() == "Just a moment...") { if(document.select("title").text() == "Just a moment...") {
document = app.get(link, interceptor = interceptor).document document = app.get(link, interceptor = interceptor).document
} }
@ -100,10 +102,12 @@ class Movierulzhd : MainAPI() {
} }
override suspend fun load(url: String): LoadResponse { override suspend fun load(url: String): LoadResponse {
var document = app.get(url,).document val request = app.get(url)
var document = request.document
if(document.select("title").text() == "Just a moment...") { if(document.select("title").text() == "Just a moment...") {
document = app.get(url, interceptor = interceptor).document document = app.get(url, interceptor = interceptor).document
} }
directUrl = getBaseUrl(request.url)
val title = val title =
document.selectFirst("div.data > h1")?.text()?.trim().toString() document.selectFirst("div.data > h1")?.text()?.trim().toString()
val poster = document.select("div.poster > img").attr("src").toString() val poster = document.select("div.poster > img").attr("src").toString()
@ -112,7 +116,11 @@ class Movierulzhd : MainAPI() {
val year = Regex(",\\s?(\\d+)").find( val year = Regex(",\\s?(\\d+)").find(
document.select("span.date").text().trim() document.select("span.date").text().trim()
)?.groupValues?.get(1).toString().toIntOrNull() )?.groupValues?.get(1).toString().toIntOrNull()
val tvType = if (document.select("ul#section > li:nth-child(1)").text().contains("Episodes") val tvType = if (document.select("ul#section > li:nth-child(1)").text()
.contains("Episodes") || document.selectFirst("ul#playeroptionsul li span.title")
?.text()?.contains(
Regex("Episode\\s\\d+")
) == true
) TvType.TvSeries else TvType.Movie ) TvType.TvSeries else TvType.Movie
val description = document.select("div.wp-content > p").text().trim() val description = document.select("div.wp-content > p").text().trim()
val trailer = document.selectFirst("div.embed iframe")?.attr("src") val trailer = document.selectFirst("div.embed iframe")?.attr("src")
@ -134,21 +142,34 @@ class Movierulzhd : MainAPI() {
} }
return if (tvType == TvType.TvSeries) { return if (tvType == TvType.TvSeries) {
val episodes = document.select("ul.episodios > li").map { val episodes = if(document.select("ul.episodios > li").isNotEmpty()) {
val href = it.select("a").attr("href") document.select("ul.episodios > li").map {
val name = fixTitle(it.select("div.episodiotitle > a").text().trim()) val href = it.select("a").attr("href")
val image = it.select("div.imagen > img").attr("src") val name = fixTitle(it.select("div.episodiotitle > a").text().trim())
val episode = it.select("div.numerando").text().replace(" ", "").split("-").last() val image = it.select("div.imagen > img").attr("src")
.toIntOrNull() val episode = it.select("div.numerando").text().replace(" ", "").split("-").last()
val season = it.select("div.numerando").text().replace(" ", "").split("-").first() .toIntOrNull()
.toIntOrNull() val season = it.select("div.numerando").text().replace(" ", "").split("-").first()
Episode( .toIntOrNull()
href, Episode(
name, href,
season, name,
episode, season,
image episode,
) image
)
}
} else {
document.select("ul#playeroptionsul > li").map {
val name = it.selectFirst("span.title")?.text()
val type = it.attr("data-type")
val post = it.attr("data-post")
val nume = it.attr("data-nume")
Episode(
LinkData(type, post, nume).toJson(),
name,
)
}
} }
newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodes) { newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodes) {
this.posterUrl = poster this.posterUrl = poster
@ -176,43 +197,6 @@ class Movierulzhd : MainAPI() {
} }
} }
private suspend fun invokeSbflix(
url: String,
callback: (ExtractorLink) -> Unit,
) {
val mainUrl = "https://sbflix.xyz"
val name = "Sbflix"
val regexID =
Regex("(embed-[a-zA-Z0-9]{0,8}[a-zA-Z0-9_-]+|/e/[a-zA-Z0-9]{0,8}[a-zA-Z0-9_-]+)")
val id = regexID.findAll(url).map {
it.value.replace(Regex("(embed-|/e/)"), "")
}.first()
val master = "$mainUrl/sources48/" + bytesToHex("||$id||||streamsb".toByteArray()) + "/"
val headers = mapOf(
"watchsb" to "sbstream",
)
val urltext = app.get(
master.lowercase(),
headers = headers,
referer = url,
).text
val mapped = urltext.let { AppUtils.parseJson<Main>(it) }
val testurl = app.get(mapped.streamData.file, headers = headers).text
if (urltext.contains("m3u8") && testurl.contains("EXTM3U"))
callback.invoke(
ExtractorLink(
name,
name,
mapped.streamData.file,
url,
Qualities.Unknown.value,
isM3u8 = true,
headers = headers
)
)
}
private fun getBaseUrl(url: String): String { private fun getBaseUrl(url: String): String {
return URI(url).let { return URI(url).let {
"${it.scheme}://${it.host}" "${it.scheme}://${it.host}"
@ -226,84 +210,60 @@ class Movierulzhd : MainAPI() {
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
): Boolean { ): Boolean {
val req = app.get(data) if(data.startsWith("{")) {
val directUrl = getBaseUrl(req.url) val loadData = AppUtils.tryParseJson<LinkData>(data)
var document = req.document val source = app.post(
if(document.select("title").text() == "Just a moment...") { url = "$directUrl/wp-admin/admin-ajax.php",
document = app.get(data, interceptor = interceptor).document data = mapOf(
} "action" to "doo_player_ajax",
val id = document.select("meta#dooplay-ajax-counter").attr("data-postid") "post" to "${loadData?.post}",
val type = if (data.contains("/movies/")) "movie" else "tv" "nume" to "${loadData?.nume}",
"type" to "${loadData?.type}"
),
referer = data,
headers = mapOf("X-Requested-With" to "XMLHttpRequest")
).parsed<ResponseHash>().embed_url
if(!source.contains("youtube")) loadExtractor(source, data, 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 { document.select("ul#playeroptionsul > li").map {
it.attr("data-nume") it.attr("data-nume")
}.apmap { nume -> }.apmap { nume ->
safeApiCall { safeApiCall {
val source = app.post( val source = app.post(
url = "$directUrl/wp-admin/admin-ajax.php", url = "$directUrl/wp-admin/admin-ajax.php",
data = mapOf( data = mapOf(
"action" to "doo_player_ajax", "action" to "doo_player_ajax",
"post" to id, "post" to id,
"nume" to nume, "nume" to nume,
"type" to type "type" to type
), ),
referer = data, referer = data,
headers = mapOf("X-Requested-With" to "XMLHttpRequest") headers = mapOf("X-Requested-With" to "XMLHttpRequest")
).parsed<ResponseHash>().embed_url ).parsed<ResponseHash>().embed_url
when { if(!source.contains("youtube")) loadExtractor(source, data, subtitleCallback, callback)
source.startsWith("https://sbflix.xyz") -> {
invokeSbflix(source, callback)
}
// source.startsWith("https://series.databasegdriveplayer.co") -> {
// invokeDatabase(source, callback, subtitleCallback)
// }
!source.contains("youtube") -> loadExtractor(source, data, subtitleCallback, callback)
else -> {}
} }
} }
} }
return true return true
} }
data class LinkData(
val type: String? = null,
val post: String? = null,
val nume: String? = null,
)
data class ResponseHash( data class ResponseHash(
@JsonProperty("embed_url") val embed_url: String, @JsonProperty("embed_url") val embed_url: String,
@JsonProperty("type") val type: String?, @JsonProperty("type") val type: String?,
) )
private val hexArray = "0123456789ABCDEF".toCharArray()
private fun bytesToHex(bytes: ByteArray): String {
val hexChars = CharArray(bytes.size * 2)
for (j in bytes.indices) {
val v = bytes[j].toInt() and 0xFF
hexChars[j * 2] = hexArray[v ushr 4]
hexChars[j * 2 + 1] = hexArray[v and 0x0F]
}
return String(hexChars)
}
data class Subs(
@JsonProperty("file") val file: String,
@JsonProperty("label") val label: String,
)
data class StreamData(
@JsonProperty("file") val file: String,
@JsonProperty("cdn_img") val cdnImg: String,
@JsonProperty("hash") val hash: String,
@JsonProperty("subs") val subs: List<Subs>?,
@JsonProperty("length") val length: String,
@JsonProperty("id") val id: String,
@JsonProperty("title") val title: String,
@JsonProperty("backup") val backup: String,
)
data class Main(
@JsonProperty("stream_data") val streamData: StreamData,
@JsonProperty("status_code") val statusCode: Int,
)
} }

View File

@ -10,5 +10,7 @@ class MovierulzhdPlugin: Plugin() {
override fun load(context: Context) { override fun load(context: Context) {
// All providers should be added in this manner. Please don't edit the providers list directly. // All providers should be added in this manner. Please don't edit the providers list directly.
registerMainAPI(Movierulzhd()) registerMainAPI(Movierulzhd())
registerExtractorAPI(Sbflix())
registerExtractorAPI(Sbrulz())
} }
} }

View File

@ -0,0 +1,89 @@
package com.hexated
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.SubtitleFile
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.utils.AppUtils
import com.lagradost.cloudstream3.utils.ExtractorApi
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.Qualities
class Sbrulz : Sbflix() {
override val name = "Sbrulz"
override var mainUrl = "https://sbrulz.xyz"
}
open class Sbflix : ExtractorApi() {
override val mainUrl = "https://sbflix.xyz"
override val name = "Sbflix"
override val requiresReferer = false
override suspend fun getUrl(
url: String,
referer: String?,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
) {
val regexID =
Regex("(embed-[a-zA-Z0-9]{0,8}[a-zA-Z0-9_-]+|/e/[a-zA-Z0-9]{0,8}[a-zA-Z0-9_-]+)")
val id = regexID.findAll(url).map {
it.value.replace(Regex("(embed-|/e/)"), "")
}.first()
val master = "$mainUrl/sources48/" + bytesToHex("||$id||||streamsb".toByteArray()) + "/"
val headers = mapOf(
"watchsb" to "sbstream",
)
val urltext = app.get(
master.lowercase(),
headers = headers,
referer = url,
).text
val mapped = urltext.let { AppUtils.parseJson<Main>(it) }
callback.invoke(
ExtractorLink(
name,
name,
mapped.streamData.file,
url,
Qualities.Unknown.value,
isM3u8 = true,
headers = headers
)
)
}
private val hexArray = "0123456789ABCDEF".toCharArray()
private fun bytesToHex(bytes: ByteArray): String {
val hexChars = CharArray(bytes.size * 2)
for (j in bytes.indices) {
val v = bytes[j].toInt() and 0xFF
hexChars[j * 2] = hexArray[v ushr 4]
hexChars[j * 2 + 1] = hexArray[v and 0x0F]
}
return String(hexChars)
}
data class Subs(
@JsonProperty("file") val file: String,
@JsonProperty("label") val label: String,
)
data class StreamData(
@JsonProperty("file") val file: String,
@JsonProperty("cdn_img") val cdnImg: String,
@JsonProperty("hash") val hash: String,
@JsonProperty("subs") val subs: List<Subs>?,
@JsonProperty("length") val length: String,
@JsonProperty("id") val id: String,
@JsonProperty("title") val title: String,
@JsonProperty("backup") val backup: String,
)
data class Main(
@JsonProperty("stream_data") val streamData: StreamData,
@JsonProperty("status_code") val statusCode: Int,
)
}