idlix: last fix

This commit is contained in:
hexated 2023-09-13 22:16:03 +07:00
parent fb882b609b
commit 4077d1275d
2 changed files with 42 additions and 113 deletions

View file

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

View file

@ -4,13 +4,9 @@ import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.LoadResponse.Companion.addActors import com.lagradost.cloudstream3.LoadResponse.Companion.addActors
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
import com.lagradost.cloudstream3.mvvm.safeApiCall import com.lagradost.cloudstream3.extractors.helper.AesHelper
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.tryParseJson
import okhttp3.Interceptor
import okhttp3.Response
import org.jsoup.Jsoup
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import java.net.URI import java.net.URI
@ -22,7 +18,6 @@ class IdlixProvider : MainAPI() {
override var lang = "id" override var lang = "id"
override val hasDownloadSupport = true override val hasDownloadSupport = true
private val cloudflareKiller by lazy { CloudflareKiller() } private val cloudflareKiller by lazy { CloudflareKiller() }
private val interceptor by lazy { CloudflareInterceptor(cloudflareKiller) }
override val supportedTypes = setOf( override val supportedTypes = setOf(
TvType.Movie, TvType.Movie,
TvType.TvSeries, TvType.TvSeries,
@ -30,17 +25,15 @@ class IdlixProvider : MainAPI() {
TvType.AsianDrama TvType.AsianDrama
) )
private val key = "\\x5a\\x6d\\x5a\\x6c\\x4e\\x7a\\x55\\x79\\x4d\\x54\\x56\\x6a\\x5a\\x47\\x52\\x69\\x5a\\x44\\x55\\x30\\x5a\\x6d\\x59\\x35\\x4f\\x57\\x45\\x33\\x4d\\x44\\x4a\\x69\\x4e\\x32\\x4a\\x6c\\x4f\\x54\\x42\\x6c\\x4e\\x7a\\x49\\x3d"
override val mainPage = mainPageOf( override val mainPage = mainPageOf(
"$mainUrl/" to "Featured", "$mainUrl/" to "Featured",
"$mainUrl/trending/page/?get=movies" to "Trending Movies", "$mainUrl/trending/page/?get=movies" to "Trending Movies",
"$mainUrl/trending/page/?get=tv" to "Trending TV Series", "$mainUrl/trending/page/?get=tv" to "Trending TV Series",
"$mainUrl/movie/page/" to "Movie Terbaru", "$mainUrl/movie/page/" to "Movie Terbaru",
"$mainUrl/tvseries/page/" to "TV Series Terbaru", "$mainUrl/tvseries/page/" to "TV Series Terbaru",
"$mainUrl/network/netflix/page/" to "Netflix", // "$mainUrl/network/netflix/page/" to "Netflix",
"$mainUrl/genre/anime/page/" to "Anime", // "$mainUrl/genre/anime/page/" to "Anime",
"$mainUrl/genre/drama-korea/page/" to "Drama Korea", // "$mainUrl/genre/drama-korea/page/" to "Drama Korea",
) )
private fun getBaseUrl(url: String): String { private fun getBaseUrl(url: String): String {
@ -56,9 +49,9 @@ class IdlixProvider : MainAPI() {
val url = request.data.split("?") val url = request.data.split("?")
val nonPaged = request.name == "Featured" && page <= 1 val nonPaged = request.name == "Featured" && page <= 1
val req = if (nonPaged) { val req = if (nonPaged) {
app.get(request.data, interceptor = interceptor) app.get(request.data)
} else { } else {
app.get("${url.first()}$page/?${url.lastOrNull()}", interceptor = interceptor) app.get("${url.first()}$page/?${url.lastOrNull()}")
} }
mainUrl = getBaseUrl(req.url) mainUrl = getBaseUrl(req.url)
val document = req.document val document = req.document
@ -79,11 +72,13 @@ class IdlixProvider : MainAPI() {
title = Regex("(.+?)-season").find(title)?.groupValues?.get(1).toString() title = Regex("(.+?)-season").find(title)?.groupValues?.get(1).toString()
"$mainUrl/tvseries/$title" "$mainUrl/tvseries/$title"
} }
uri.contains("/season/") -> { uri.contains("/season/") -> {
var title = uri.substringAfter("$mainUrl/season/") var title = uri.substringAfter("$mainUrl/season/")
title = Regex("(.+?)-season").find(title)?.groupValues?.get(1).toString() title = Regex("(.+?)-season").find(title)?.groupValues?.get(1).toString()
"$mainUrl/tvseries/$title" "$mainUrl/tvseries/$title"
} }
else -> { else -> {
uri uri
} }
@ -98,13 +93,12 @@ class IdlixProvider : MainAPI() {
return newMovieSearchResponse(title, href, TvType.Movie) { return newMovieSearchResponse(title, href, TvType.Movie) {
this.posterUrl = posterUrl this.posterUrl = posterUrl
this.quality = quality this.quality = quality
posterHeaders = cloudflareKiller.getCookieHeaders(mainUrl).toMap()
} }
} }
override suspend fun search(query: String): List<SearchResponse> { override suspend fun search(query: String): List<SearchResponse> {
val req = app.get("$mainUrl/search/$query", interceptor = interceptor) val req = app.get("$mainUrl/search/$query")
mainUrl = getBaseUrl(req.url) mainUrl = getBaseUrl(req.url)
val document = req.document val document = req.document
return document.select("div.result-item").map { return document.select("div.result-item").map {
@ -114,13 +108,12 @@ class IdlixProvider : MainAPI() {
val posterUrl = it.selectFirst("img")!!.attr("src").toString() val posterUrl = it.selectFirst("img")!!.attr("src").toString()
newMovieSearchResponse(title, href, TvType.TvSeries) { newMovieSearchResponse(title, href, TvType.TvSeries) {
this.posterUrl = posterUrl this.posterUrl = posterUrl
posterHeaders = cloudflareKiller.getCookieHeaders(mainUrl).toMap()
} }
} }
} }
override suspend fun load(url: String): LoadResponse { override suspend fun load(url: String): LoadResponse {
val request = app.get(url, interceptor = interceptor, referer = "$directUrl/") val request = app.get(url)
directUrl = getBaseUrl(request.url) directUrl = getBaseUrl(request.url)
val document = request.document val document = request.document
val title = val title =
@ -149,7 +142,6 @@ class IdlixProvider : MainAPI() {
val recPosterUrl = it.selectFirst("img")?.attr("src").toString() val recPosterUrl = it.selectFirst("img")?.attr("src").toString()
newTvSeriesSearchResponse(recName, recHref, TvType.TvSeries) { newTvSeriesSearchResponse(recName, recHref, TvType.TvSeries) {
this.posterUrl = recPosterUrl this.posterUrl = recPosterUrl
posterHeaders = cloudflareKiller.getCookieHeaders(mainUrl).toMap()
} }
} }
@ -179,7 +171,6 @@ class IdlixProvider : MainAPI() {
addActors(actors) addActors(actors)
this.recommendations = recommendations this.recommendations = recommendations
addTrailer(trailer) addTrailer(trailer)
posterHeaders = cloudflareKiller.getCookieHeaders(mainUrl).toMap()
} }
} else { } else {
newMovieLoadResponse(title, url, TvType.Movie, url) { newMovieLoadResponse(title, url, TvType.Movie, url) {
@ -191,7 +182,6 @@ class IdlixProvider : MainAPI() {
addActors(actors) addActors(actors)
this.recommendations = recommendations this.recommendations = recommendations
addTrailer(trailer) addTrailer(trailer)
posterHeaders = cloudflareKiller.getCookieHeaders(mainUrl).toMap()
} }
} }
} }
@ -203,114 +193,53 @@ class IdlixProvider : MainAPI() {
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
): Boolean { ): Boolean {
val document = app.get(data, interceptor = interceptor, referer = "$directUrl/").document val document = app.get(data).document
val id = document.select("meta#dooplay-ajax-counter").attr("data-postid")
val type = if (data.contains("/movie/")) "movie" else "tv"
document.select("ul#playeroptionsul > li").map { document.select("ul#playeroptionsul > li").map {
it.attr("data-nume") Triple(
}.apmap { nume -> it.attr("data-post"),
safeApiCall { it.attr("data-nume"),
val source = app.post( it.attr("data-type")
)
}.apmap { (id, nume, type) ->
val json = app.post(
url = "$directUrl/wp-admin/admin-ajax.php", data = mapOf( url = "$directUrl/wp-admin/admin-ajax.php", data = mapOf(
"action" to "doo_player_ajax", "post" to id, "nume" to nume, "type" to type "action" to "doo_player_ajax", "post" to id, "nume" to nume, "type" to type
), headers = mapOf("X-Requested-With" to "XMLHttpRequest"), referer = data, interceptor = interceptor ), referer = data, headers = mapOf("Accept" to "*/*", "X-Requested-With" to "XMLHttpRequest")
).let { tryParseJson<ResponseHash>(it.text) } ?: return@safeApiCall ).parsedSafe<ResponseHash>() ?: return@apmap
val metrix = AppUtils.parseJson<AesData>(json.embed_url).m
val password = if(source.key?.startsWith("\\x") == true) source.key else key val password = createKey(json.key, metrix)
var decrypted = AesHelper.cryptoAESHandler(source.embed_url, password.toByteArray(), false)?.fixBloat() ?: return@safeApiCall val decrypted = AesHelper.cryptoAESHandler(json.embed_url, password.toByteArray(), false)?.fixBloat() ?: return@apmap
if (decrypted.startsWith("https://uservideo.xyz")) {
decrypted = app.get(decrypted).document.select("iframe").attr("src")
}
getUrl(decrypted, "$directUrl/", subtitleCallback, callback)
when {
!decrypted.contains("youtube") -> loadExtractor(decrypted, "$directUrl/", subtitleCallback, callback)
else -> return@apmap
} }
} }
return true return true
} }
class CloudflareInterceptor(private val cloudflareKiller: CloudflareKiller): Interceptor { private fun createKey(r: String, m: String): String {
override fun intercept(chain: Interceptor.Chain): Response { val rList = r.split("\\x").toTypedArray()
val request = chain.request() var n = ""
val response = chain.proceed(request) val decodedM = String(base64Decode(m.split("").reversed().joinToString("")).toCharArray())
val doc = Jsoup.parse(response.peekBody(1024 * 1024).string()) for (s in decodedM.split("|")) {
if (doc.select("title").text() == "Just a moment...") { n += "\\x" + rList[Integer.parseInt(s) + 1]
return cloudflareKiller.intercept(chain)
}
return response
} }
return n
} }
private fun String.fixBloat(): String { private fun String.fixBloat(): String {
return this.replace("\"", "").replace("\\", "") return this.replace("\"", "").replace("\\", "")
} }
private suspend fun getUrl(
url: String,
referer: String?,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
) {
val document = app.get(url, referer = referer).document
val hash = url.split("/").last().substringAfter("data=")
val m3uLink = app.post(
url = "$mainUrl/player/index.php?data=$hash&do=getVideo",
data = mapOf("hash" to hash, "r" to "$referer"),
referer = referer,
headers = mapOf("X-Requested-With" to "XMLHttpRequest")
).parsed<ResponseSource>().videoSource
M3u8Helper.generateM3u8(
this.name,
m3uLink,
"$referer",
).forEach(callback)
document.select("script").map { script ->
if (script.data().contains("eval(function(p,a,c,k,e,d)")) {
val subData =
getAndUnpack(script.data()).substringAfter("\"tracks\":[").substringBefore("],")
tryParseJson<List<Tracks>>("[$subData]")?.map { subtitle ->
subtitleCallback.invoke(
SubtitleFile(
getLanguage(subtitle.label ?: ""),
subtitle.file
)
)
}
}
}
}
private fun getLanguage(str: String): String {
return when {
str.contains("indonesia", true) || str
.contains("bahasa", true) -> "Indonesian"
else -> str
}
}
data class ResponseSource(
@JsonProperty("hls") val hls: Boolean,
@JsonProperty("videoSource") val videoSource: String,
@JsonProperty("securedLink") val securedLink: String?,
)
data class Tracks(
@JsonProperty("kind") val kind: String?,
@JsonProperty("file") val file: String,
@JsonProperty("label") val label: String?,
)
data class ResponseHash( data class ResponseHash(
@JsonProperty("embed_url") val embed_url: String, @JsonProperty("embed_url") val embed_url: String,
@JsonProperty("key") val key: String?, @JsonProperty("key") val key: String,
@JsonProperty("type") val type: String?, )
data class AesData(
@JsonProperty("m") val m: String,
) )