From aa6ed888c03b9a49e5949c7db6d4fb4ed1373482 Mon Sep 17 00:00:00 2001 From: hexated Date: Fri, 28 Oct 2022 10:57:14 +0700 Subject: [PATCH] added new sources into SoraExtractor --- SoraStream/build.gradle.kts | 2 +- .../src/main/kotlin/com/hexated/Jeniusplay.kt | 72 +++++++++++++++++++ .../main/kotlin/com/hexated/SoraExtractor.kt | 67 +++++++++++++++-- .../src/main/kotlin/com/hexated/SoraStream.kt | 7 +- .../kotlin/com/hexated/SoraStreamPlugin.kt | 1 + 5 files changed, 140 insertions(+), 9 deletions(-) create mode 100644 SoraStream/src/main/kotlin/com/hexated/Jeniusplay.kt diff --git a/SoraStream/build.gradle.kts b/SoraStream/build.gradle.kts index 5acb1295..87452bb0 100644 --- a/SoraStream/build.gradle.kts +++ b/SoraStream/build.gradle.kts @@ -1,5 +1,5 @@ // use an integer for version numbers -version = 12 +version = 13 cloudstream { diff --git a/SoraStream/src/main/kotlin/com/hexated/Jeniusplay.kt b/SoraStream/src/main/kotlin/com/hexated/Jeniusplay.kt new file mode 100644 index 00000000..7df5369c --- /dev/null +++ b/SoraStream/src/main/kotlin/com/hexated/Jeniusplay.kt @@ -0,0 +1,72 @@ +package com.hexated + +import com.fasterxml.jackson.annotation.JsonProperty +import com.lagradost.cloudstream3.SubtitleFile +import com.lagradost.cloudstream3.app +import com.lagradost.cloudstream3.utils.* +import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson + +class Jeniusplay : ExtractorApi() { + override val name = "Jeniusplay" + override val mainUrl = "https://jeniusplay.com" + override val requiresReferer = true + + override suspend fun getUrl( + url: String, + referer: String?, + subtitleCallback: (SubtitleFile) -> Unit, + callback: (ExtractorLink) -> Unit + ) { + val document = app.get(url, referer = "$mainUrl/").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 = url, + headers = mapOf("X-Requested-With" to "XMLHttpRequest") + ).parsed().videoSource + + M3u8Helper.generateM3u8( + this.name, + m3uLink, + url, + ).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>("[$subData]")?.map { subtitle -> + subtitleCallback.invoke( + SubtitleFile( + getLanguage(subtitle.label.toString()), + subtitle.file + ) + ) + } + } + } + } + + private fun getLanguage(str: String): String { + return when { + str.lowercase().contains("indonesia") || str.lowercase() + .contains("bahasa") -> "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?, + ) +} \ No newline at end of file diff --git a/SoraStream/src/main/kotlin/com/hexated/SoraExtractor.kt b/SoraStream/src/main/kotlin/com/hexated/SoraExtractor.kt index 44532a4d..7e4c25ca 100644 --- a/SoraStream/src/main/kotlin/com/hexated/SoraExtractor.kt +++ b/SoraStream/src/main/kotlin/com/hexated/SoraExtractor.kt @@ -230,16 +230,16 @@ object SoraExtractor : SoraStream() { } suspend fun invokeMovieHab( - id: Int? = null, + imdbId: String? = null, season: Int? = null, episode: Int? = null, subtitleCallback: (SubtitleFile) -> Unit, callback: (ExtractorLink) -> Unit ) { val url = if (season == null) { - "$movieHabAPI/embed/movie?tmdb=$id" + "$movieHabAPI/embed/movie?imdb=$imdbId" } else { - "$movieHabAPI/embed/series?tmdb=$id&sea=$season&epi=$episode" + "$movieHabAPI/embed/series?imdb=$imdbId&sea=$season&epi=$episode" } val doc = app.get(url, referer = "$movieHabAPI/").document @@ -334,7 +334,7 @@ object SoraExtractor : SoraStream() { json?.subtitles?.map { sub -> subtitleCallback.invoke( SubtitleFile( - sub.lang.toString(), + getLanguage(sub.lang.toString()), sub.url ?: return@map null ) ) @@ -372,7 +372,7 @@ object SoraExtractor : SoraStream() { episode: Int? = null, callback: (ExtractorLink) -> Unit ) { - val fixTitle = title?.replace(":", "")?.replace(" ", "-")?.lowercase() + val fixTitle = title.fixTitle() val url = "$hdMovieBoxAPI/watch/$fixTitle" val ref = if (season == null) { "$hdMovieBoxAPI/watch/$fixTitle" @@ -436,7 +436,7 @@ object SoraExtractor : SoraStream() { subtitleCallback: (SubtitleFile) -> Unit, callback: (ExtractorLink) -> Unit ) { - val fixTitle = title?.replace(":", "")?.replace(" ", "-")?.lowercase() + val fixTitle = title.fixTitle() val url = if (season == null) { "$series9API/film/$fixTitle/watching.html" } else { @@ -465,9 +465,57 @@ object SoraExtractor : SoraStream() { sources.apmap { link -> loadExtractor(link ?: return@apmap null, url, subtitleCallback, callback) } - } + suspend fun invokeIdlix( + title: String? = null, + season: Int? = null, + episode: Int? = null, + subtitleCallback: (SubtitleFile) -> Unit, + callback: (ExtractorLink) -> Unit + ) { + val fixTitle = title.fixTitle() + val url = if(season == null) { + "$idlixAPI/movie/$fixTitle" + } else { + "$idlixAPI/episode/$fixTitle-season-$season-episode-$episode" + } + + val document = app.get(url).document + val id = document.select("meta#dooplay-ajax-counter").attr("data-postid") + val type = if (url.contains("/movie/")) "movie" else "tv" + + document.select("ul#playeroptionsul > li").map { + it.attr("data-nume") + }.apmap { nume -> + val source = app.post( + url = "$idlixAPI/wp-admin/admin-ajax.php", + data = mapOf( + "action" to "doo_player_ajax", + "post" to id, + "nume" to nume, + "type" to type + ), + headers = mapOf("X-Requested-With" to "XMLHttpRequest"), + referer = url + ).parsed().embed_url + + loadExtractor(source, "$idlixAPI/", subtitleCallback, callback) + } + } + +} + +//private fun fixTitle(title: String? = null) : String? { +// return title?.replace(":", "")?.replace(" ", "-")?.lowercase()?.replace("-–-", "-") +//} + +private fun String?.fixTitle() : String? { + return this?.replace(":", "")?.replace(" ", "-")?.lowercase()?.replace("-–-", "-") +} + +fun getLanguage(str: String): String { + return if(str.contains("(in_ID)")) "Indonesian" else str } private fun getQuality(str: String): Int { @@ -552,3 +600,8 @@ data class HdMovieBoxIframe( @JsonProperty("api_iframe") val apiIframe: String? = null, ) +data class ResponseHash( + @JsonProperty("embed_url") val embed_url: String, + @JsonProperty("type") val type: String?, +) + diff --git a/SoraStream/src/main/kotlin/com/hexated/SoraStream.kt b/SoraStream/src/main/kotlin/com/hexated/SoraStream.kt index 8c8eb559..fef290e4 100644 --- a/SoraStream/src/main/kotlin/com/hexated/SoraStream.kt +++ b/SoraStream/src/main/kotlin/com/hexated/SoraStream.kt @@ -7,6 +7,7 @@ import com.hexated.SoraExtractor.invokeDatabaseGdrive import com.hexated.SoraExtractor.invokeDbgo import com.hexated.SoraExtractor.invokeGogo import com.hexated.SoraExtractor.invokeHDMovieBox +import com.hexated.SoraExtractor.invokeIdlix import com.hexated.SoraExtractor.invokeLocalSources import com.hexated.SoraExtractor.invokeMovieHab import com.hexated.SoraExtractor.invokeOlgply @@ -52,6 +53,7 @@ open class SoraStream : TmdbProvider() { const val databaseGdriveAPI = "https://databasegdriveplayer.co" const val hdMovieBoxAPI = "https://hdmoviebox.net" const val series9API = "https://series9.la" + const val idlixAPI = "https://109.234.36.69" fun getType(t: String?): TvType { return when (t) { @@ -352,7 +354,7 @@ open class SoraStream : TmdbProvider() { ) }, { - invokeMovieHab(res.id, res.season, res.episode, subtitleCallback, callback) + invokeMovieHab(res.imdbId, res.season, res.episode, subtitleCallback, callback) }, // { // invokeDatabaseGdrive( @@ -371,6 +373,9 @@ open class SoraStream : TmdbProvider() { }, { invokeSeries9(res.title, res.season, res.episode, subtitleCallback, callback) + }, + { + invokeIdlix(res.title, res.season, res.episode, subtitleCallback, callback) } ) diff --git a/SoraStream/src/main/kotlin/com/hexated/SoraStreamPlugin.kt b/SoraStream/src/main/kotlin/com/hexated/SoraStreamPlugin.kt index bdf4216e..805b7945 100644 --- a/SoraStream/src/main/kotlin/com/hexated/SoraStreamPlugin.kt +++ b/SoraStream/src/main/kotlin/com/hexated/SoraStreamPlugin.kt @@ -10,5 +10,6 @@ class SoraStreamPlugin: Plugin() { override fun load(context: Context) { // All providers should be added in this manner. Please don't edit the providers list directly. registerMainAPI(SoraStream()) + registerExtractorAPI(Jeniusplay()) } } \ No newline at end of file