From a89bbb49b8a448386c907fddae47e005d0ecd55a Mon Sep 17 00:00:00 2001 From: sp0nge Date: Fri, 27 Jan 2023 22:53:54 +0100 Subject: [PATCH] added more extractors and fixed movizland --- .../src/main/kotlin/com/movizland/Govad.kt | 53 ++++ .../src/main/kotlin/com/movizland/JWPlayer.kt | 59 ++++ .../com/movizland/MovizlandProvider copy.kt | 277 ++++++++++++++++++ .../src/main/kotlin/com/mycima/myvid.kt | 32 ++ .../kotlin/com/shahid4u/Shahid4uProvider.kt | 2 +- .../src/main/kotlin/com/shahid4u/gostream.kt | 33 +++ .../src/main/kotlin/com/shahid4u/vidhd.kt | 46 +++ 7 files changed, 501 insertions(+), 1 deletion(-) create mode 100644 MovizlandProvider/src/main/kotlin/com/movizland/Govad.kt create mode 100644 MovizlandProvider/src/main/kotlin/com/movizland/JWPlayer.kt create mode 100644 MovizlandProvider/src/main/kotlin/com/movizland/MovizlandProvider copy.kt create mode 100644 MyCimaProvider/src/main/kotlin/com/mycima/myvid.kt create mode 100644 Shahid4uProvider/src/main/kotlin/com/shahid4u/gostream.kt create mode 100644 Shahid4uProvider/src/main/kotlin/com/shahid4u/vidhd.kt diff --git a/MovizlandProvider/src/main/kotlin/com/movizland/Govad.kt b/MovizlandProvider/src/main/kotlin/com/movizland/Govad.kt new file mode 100644 index 0000000..a26a8c5 --- /dev/null +++ b/MovizlandProvider/src/main/kotlin/com/movizland/Govad.kt @@ -0,0 +1,53 @@ +package com.movizland + +import com.fasterxml.jackson.annotation.JsonProperty +import com.lagradost.cloudstream3.app +import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson +import com.lagradost.cloudstream3.utils.ExtractorApi +import com.lagradost.cloudstream3.utils.ExtractorLink +import com.lagradost.cloudstream3.utils.getQualityFromName +import com.lagradost.cloudstream3.utils.Qualities + + +open class Govad : ExtractorApi() { + override val name = "Govad" + override val mainUrl = "https://govad.xyz" + override val requiresReferer = false + + override suspend fun getUrl(url: String, referer: String?): List { + val sources = mutableListOf() + val regcode = """$mainUrl/embed-(\w+)""".toRegex() + val code = regcode.find(url)?.groupValues?.getOrNull(1) + val link = "$mainUrl/$code" + with(app.get(link).document) { + val data = this.select("script").mapNotNull { script -> + if (script.data().contains("sources: [")) { + script.data().substringAfter("sources: [") + .substringBefore("],").replace("file", "\"file\"").replace("label", "\"label\"").replace("type", "\"type\"") + } else { + null + } + } + + tryParseJson>("$data")?.map { + sources.add( + ExtractorLink( + name, + name, + it.file, + referer = url, + quality = getQualityFromName(it.label) ?: Qualities.Unknown.value, + isM3u8 = if(it.file.endsWith(".m3u8")) true else false + ) + ) + } + } + return sources + } + + private data class ResponseSource( + @JsonProperty("file") val file: String, + @JsonProperty("type") val type: String?, + @JsonProperty("label") val label: String? + ) +} diff --git a/MovizlandProvider/src/main/kotlin/com/movizland/JWPlayer.kt b/MovizlandProvider/src/main/kotlin/com/movizland/JWPlayer.kt new file mode 100644 index 0000000..935501f --- /dev/null +++ b/MovizlandProvider/src/main/kotlin/com/movizland/JWPlayer.kt @@ -0,0 +1,59 @@ +package com.movizland + +import com.fasterxml.jackson.annotation.JsonProperty +import com.lagradost.cloudstream3.app +import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson +import com.lagradost.cloudstream3.utils.ExtractorApi +import com.lagradost.cloudstream3.utils.ExtractorLink +import com.lagradost.cloudstream3.utils.getQualityFromName +import com.lagradost.cloudstream3.utils.Qualities + +open class JWPlayer : ExtractorApi() { + override val name = "JWPlayer" + override val mainUrl = "https://www.jwplayer.com" + override val requiresReferer = false + + override suspend fun getUrl(url: String, referer: String?): List? { + val sources = mutableListOf() + with(app.get(url).document) { + val data = this.select("script").mapNotNull { script -> + if (script.data().contains("sources: [")) { + script.data().substringAfter("sources: [") + .substringBefore("],").replace("file", "\"file\"").replace("label", "\"label\"") + } else { + null + } + } + + tryParseJson>("$data")?.map { + sources.add( + ExtractorLink( + name, + name, + it.file, + referer = url, + quality = getQualityFromName(it.label) ?: Qualities.Unknown.value, + isM3u8 = if(it.file.endsWith(".m3u8")) true else false + ) + ) + } + } + return sources + } + + private data class ResponseSource( + @JsonProperty("file") val file: String, + @JsonProperty("type") val type: String?, + @JsonProperty("label") val label: String? + ) + +} + +class Vadbam : JWPlayer() { + override val name = "Vadbam" + override val mainUrl = "https://vadbam.com/" +} +class Vidshar : JWPlayer() { + override val name = "Vidshar" + override val mainUrl = "https://vidshar.org/" +} diff --git a/MovizlandProvider/src/main/kotlin/com/movizland/MovizlandProvider copy.kt b/MovizlandProvider/src/main/kotlin/com/movizland/MovizlandProvider copy.kt new file mode 100644 index 0000000..7479905 --- /dev/null +++ b/MovizlandProvider/src/main/kotlin/com/movizland/MovizlandProvider copy.kt @@ -0,0 +1,277 @@ +package com.movizland + + +import com.lagradost.cloudstream3.* +import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer +import com.lagradost.cloudstream3.utils.ExtractorLink +import com.lagradost.cloudstream3.utils.Qualities +import com.lagradost.cloudstream3.utils.loadExtractor +import org.jsoup.nodes.Element + +class Movizland : MainAPI() { + override var lang = "ar" + override var mainUrl = "https://movizland.online" + override var name = "Movizland" + override val usesWebView = false + override val hasMainPage = true + override val supportedTypes = setOf(TvType.TvSeries, TvType.Movie, TvType.AsianDrama, TvType.Anime) + + private fun String.getIntFromText(): Int? { + return Regex("""\d+""").find(this)?.groupValues?.firstOrNull()?.toIntOrNull() + } + + private fun String.getFullSize(): String? { + return this.replace("""-\d+x\d+""".toRegex(),"") + } + + private fun String.cleanTitle(): String { + val prefix = setOf("مشاهدة فيلم","مشاهدة وتحميل فيلم","تحميل","فيلم","انمي","إنمي","مسلسل","برنامج") + val suffix = setOf("مدبلج للعربية","اون لاين","مترجم") + this.let{ clean -> + var aa = clean + prefix.forEach{ pre -> + aa = if (aa.contains(pre)) aa.replace(pre,"") else aa } + var bb = aa + suffix.mapNotNull{ suf -> + bb = if (bb.contains(suf)) bb.replace(suf,"") else bb } + return bb + } + } + + private fun Element.toSearchResponse(): SearchResponse? { + val url = select(".BlockItem") + val title = url.select(".BlockTitle").text() + val img = url.select("img:last-of-type") + val posterUrl = img?.attr("src")?.ifEmpty { img?.attr("data-src") } + val year = url.select(".InfoEndBlock li").last()?.text()?.getIntFromText() + var quality = url.select(".RestInformation li").last()?.text()?.replace(" |-|1080p|720p".toRegex(), "")?.replace("BluRay","BLURAY") + val tvtype = if(title.contains("فيلم")) TvType.Movie else TvType.TvSeries + return MovieSearchResponse( + title.cleanTitle(), + url.select("a").attr("href"), + this@Movizland.name, + tvtype, + posterUrl, + year, + null, + quality = getQualityFromString(quality), + ) + } + override val mainPage = mainPageOf( + "$mainUrl/page/" to "أضيف حديثا", + "$mainUrl/category/movies/page/" to "أفلام", + "$mainUrl/series/page/" to "مسلسلات" + ) + + override suspend fun getMainPage(page: Int, request : MainPageRequest): HomePageResponse { + val doc = app.get(request.data + page).document + val list = doc.select(".BlockItem").mapNotNull { element -> + element.toSearchResponse() + } + return newHomePageResponse(request.name, list) + } + + override suspend fun search(query: String): List { + val q = query.replace(" ".toRegex(), "%20") + val result = arrayListOf() + + val rlist = setOf( + "$mainUrl/?s=$q", + ) + rlist.forEach{ docs -> + val d = app.get(docs).document + d.select(".BlockItem").mapNotNull { + it.toSearchResponse()?.let { + it1 -> result.add(it1) + } + } + } + return result + } + +private val seasonPatterns = arrayOf( + Pair("الموسم العاشر|الموسم 10", 10), + Pair("الموسم الحادي عشر|الموسم 11", 11), + Pair("الموسم الثاني عشر|الموسم 12", 12), + Pair("الموسم الثالث عشر|الموسم 13", 13), + Pair("الموسم الرابع عشر|الموسم 14", 14), + Pair("الموسم الخامس عشر|الموسم 15", 15), + Pair("الموسم السادس عشر|الموسم 16", 16), + Pair("الموسم السابع عشر|الموسم 17", 17), + Pair("الموسم الثامن عشر|الموسم 18", 18), + Pair("الموسم التاسع عشر|الموسم 19", 19), + Pair("الموسم العشرون|الموسم 20", 20), + Pair("الموسم الاول|الموسم 1", 1), + Pair("الموسم الثاني|الموسم 2", 2), + Pair("الموسم الثالث|الموسم 3", 3), + Pair("الموسم الرابع|الموسم 4", 4), + Pair("الموسم الخامس|الموسم 5", 5), + Pair("الموسم السادس|الموسم 6", 6), + Pair("الموسم السابع|الموسم 7", 7), + Pair("الموسم الثامن|الموسم 8", 8), + Pair("الموسم التاسع|الموسم 9", 9), +) + +private fun getSeasonFromString(sName: String): Int { + return seasonPatterns.firstOrNull{(pattern, seasonNum) -> sName.contains(pattern.toRegex()) }?.second ?: 1 +} + + override suspend fun load(url: String): LoadResponse { + var doc = app.get(url).document + val sdetails = doc.select(".SingleDetails") + var posterUrl = sdetails.select("img")?.attr("data-src")?.getFullSize() + val year = sdetails.select("li:has(.fa-clock) a").text()?.getIntFromText() + var title = doc.select("h2.postTitle").text() + val isMovie = title.contains("عرض|فيلم".toRegex()) + val synopsis = doc.select("section.story").text() + val trailer = doc.select("div.InnerTrailer iframe").attr("data-src") + var tags = sdetails.select("li:has(.fa-film) a").map{ it.text() } + val recommendations = doc.select(".BlocksUI#LoadFilter .BlockItem").mapNotNull { element -> + element.toSearchResponse() + } + + + return if (isMovie) { + newMovieLoadResponse( + title.cleanTitle().replace("$year",""), + url, + TvType.Movie, + url + ) { + this.posterUrl = posterUrl + this.year = year + this.tags = tags + this.plot = synopsis + this.recommendations = recommendations + addTrailer(trailer) + } + } else { + val episodes = ArrayList() + val episodesItem = doc.select(".EpisodesList").isNotEmpty() + val fBlock = doc.select(".BlockItem")?.first() + val img = fBlock?.select("img:last-of-type") + + if(episodesItem){ + title = doc.select(".SeriesSingle .ButtonsFilter.WidthAuto span").text() + doc.select(".EpisodesList .EpisodeItem").map{ element -> + if(!element.text().contains("Full")){ + episodes.add( + Episode( + element.select("a").attr("href"), + null, + null, + element.select("em").text().getIntFromText(), + null, + null, + ) + ) + } + } + newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodes) { + this.posterUrl = posterUrl + this.year = year + this.tags = tags + this.plot = synopsis + this.recommendations = recommendations + addTrailer(trailer) + } + }else{ + posterUrl = img?.attr("src")?.ifEmpty { img?.attr("data-src") } + tags = fBlock?.select(".RestInformation span")!!.mapNotNull { t -> + t.text() + } + title = doc.select(".PageTitle .H1Title").text().cleanTitle() + if(doc.select(".BlockItem a").attr("href").contains("/series/")){//seasons + doc.select(".BlockItem").map { seas -> + seas.select("a").attr("href") }.apmap{ pageIt -> + val Sedoc = app.get(pageIt).document + val pagEl = Sedoc.select(".pagination > div > ul > li").isNotEmpty() + if(pagEl) { + Sedoc.select(".pagination > div > ul > li:nth-child(n):not(:last-child) a").apmap { + val epidoc = app.get(it.attr("href")).document + epidoc.select(".BlockItem").map{ element -> + episodes.add( + Episode( + element.select("a").attr("href"), + element.select(".BlockTitle").text(), + getSeasonFromString(element.select(".BlockTitle").text()), + element.select(".EPSNumber").text().getIntFromText(), + element.select("img:last-of-type").attr("src")?.ifEmpty { img?.attr("data-src") }, + null, + ) + ) + } + } + }else{ + Sedoc.select(".BlockItem").map{ el -> + episodes.add( + Episode( + el.select("a").attr("href"), + el.select(".BlockTitle").text(), + getSeasonFromString(el.select(".BlockTitle").text()), + el.select(".EPSNumber").text().getIntFromText(), + el.select("img:last-of-type").attr("src")?.ifEmpty { img?.attr("data-src") }, + null, + ) + ) + } + } + } + + } else {//episodes + val pagEl = doc.select(".pagination > div > ul > li.active > a").isNotEmpty() + val pagSt = if(pagEl) true else false + if(pagSt){ + doc.select(".pagination > div > ul > li:nth-child(n):not(:last-child) a").map{ eppages -> + eppages.attr("href") }.apmap{ + val epidoc = app.get(it).document + epidoc.select(".BlockItem").map{ element -> + episodes.add( + Episode( + element.select("a").attr("href"), + element.select(".BlockTitle").text(), + getSeasonFromString(element.select(".BlockTitle").text()), + element.select(".EPSNumber").text().getIntFromText(), + element.select("img:last-of-type").attr("src")?.ifEmpty { img?.attr("data-src") }, + null, + ) + ) + } + } + }else{ + doc.select(".BlockItem").map{ el -> + episodes.add( + Episode( + el.select("a").attr("href"), + el.select(".BlockTitle").text(), + getSeasonFromString(el.select(".BlockTitle").text()), + el.select(".EPSNumber").text().getIntFromText(), + el.select("img:last-of-type").attr("src")?.ifEmpty { img?.attr("data-src") }, + null, + ) + ) + } + } + } + + newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodes) { + this.posterUrl = posterUrl?.getFullSize() + this.tags = tags + } + } + } + } +override suspend fun loadLinks( + data: String, + isCasting: Boolean, + subtitleCallback: (SubtitleFile) -> Unit, + callback: (ExtractorLink) -> Unit + ): Boolean { + val doc = app.get(data).document + doc.select("code[id*='Embed'] iframe,.DownloadsList a").apmap { + var sourceUrl = it.attr("data-srcout").ifEmpty { it.attr("href") } + loadExtractor(sourceUrl, data, subtitleCallback, callback) + } + return true + } +} diff --git a/MyCimaProvider/src/main/kotlin/com/mycima/myvid.kt b/MyCimaProvider/src/main/kotlin/com/mycima/myvid.kt new file mode 100644 index 0000000..62d62be --- /dev/null +++ b/MyCimaProvider/src/main/kotlin/com/mycima/myvid.kt @@ -0,0 +1,32 @@ +package com.mycima + +import com.lagradost.cloudstream3.utils.ExtractorApi +import com.lagradost.cloudstream3.utils.ExtractorLink +import com.lagradost.cloudstream3.utils.Qualities +import com.lagradost.cloudstream3.app + +open class MyVid : ExtractorApi() { + override val name = "MyVid" + override val mainUrl = "https://myviid.com" + override val requiresReferer = false + + override suspend fun getUrl(url: String, referer: String?): List { + val sources = mutableListOf() + val text = app.get(url).document.select("body > script:nth-child(2)").html() ?: "" + val a = text.substringAfter("||||").substringBefore("'.split").split("|") + val link = "${a[7]}://${a[24]}.${a[6]}.${a[5]}/${a[83]}/v.${a[82]}" + if (link.isNotBlank()) { + sources.add( + ExtractorLink( + name = name, + source = name, + url = link, + isM3u8 = false, + quality = "${a[80]}".replace("p","").toInt() ?: Qualities.Unknown.value, + referer = "$mainUrl/" + ) + ) + } + return sources + } +} diff --git a/Shahid4uProvider/src/main/kotlin/com/shahid4u/Shahid4uProvider.kt b/Shahid4uProvider/src/main/kotlin/com/shahid4u/Shahid4uProvider.kt index 155bb7f..9e5272a 100644 --- a/Shahid4uProvider/src/main/kotlin/com/shahid4u/Shahid4uProvider.kt +++ b/Shahid4uProvider/src/main/kotlin/com/shahid4u/Shahid4uProvider.kt @@ -8,7 +8,7 @@ import org.jsoup.nodes.Element class Shahid4u : MainAPI() { override var lang = "ar" - override var mainUrl = "https://shahed4u.vip" + override var mainUrl = "https://shaheed4u.me/" override var name = "Shahid4u" override val usesWebView = false override val hasMainPage = true diff --git a/Shahid4uProvider/src/main/kotlin/com/shahid4u/gostream.kt b/Shahid4uProvider/src/main/kotlin/com/shahid4u/gostream.kt new file mode 100644 index 0000000..bb3c121 --- /dev/null +++ b/Shahid4uProvider/src/main/kotlin/com/shahid4u/gostream.kt @@ -0,0 +1,33 @@ +package com.shahid4u + +import com.lagradost.cloudstream3.utils.ExtractorApi +import com.lagradost.cloudstream3.utils.ExtractorLink +import com.lagradost.cloudstream3.utils.Qualities +import com.lagradost.cloudstream3.app + +open class GoStream : ExtractorApi() { + override val name = "GoStream" + override val mainUrl = "https://gostream.pro" + override val requiresReferer = false + + override suspend fun getUrl(url: String, referer: String?): List { + val sources = mutableListOf() + val text = app.get(url).document.select("#player_code > script:nth-child(4)").html() ?: "" + val a = text.split("|") + val b = a[0].substring(a[0].lastIndexOf("http")) + val link = "$b://${a[5]}.${a[4]}-${a[3]}.${a[2]}:${a[11]}/d/${a[10]}/${a[9]}.${a[8]}" + if (link.isNotBlank()) { + sources.add( + ExtractorLink( + name = name, + source = name, + url = link, + isM3u8 = false, + quality = Qualities.Unknown.value, + referer = "$mainUrl/" + ) + ) + } + return sources + } +} diff --git a/Shahid4uProvider/src/main/kotlin/com/shahid4u/vidhd.kt b/Shahid4uProvider/src/main/kotlin/com/shahid4u/vidhd.kt new file mode 100644 index 0000000..74787fb --- /dev/null +++ b/Shahid4uProvider/src/main/kotlin/com/shahid4u/vidhd.kt @@ -0,0 +1,46 @@ +package com.shahid4u + +import com.lagradost.cloudstream3.utils.ExtractorApi +import com.lagradost.cloudstream3.utils.ExtractorLink +import com.lagradost.cloudstream3.utils.Qualities +import com.lagradost.cloudstream3.app + +open class VidHD : ExtractorApi() { + override val name = "VidHD" + override val mainUrl = "https://vidhd.fun" + override val requiresReferer = false + + private fun String.getIntFromText(): Int? { + return Regex("""\d+""").find(this)?.groupValues?.firstOrNull()?.toIntOrNull() + } + + override suspend fun getUrl(url: String, referer: String?): List { + val sources = mutableListOf() + app.get(url).document.select("body > script:nth-child(2)").html().substringAfter("||||").let{ c-> + val a = c.split("|") + val b = c.substringAfter("|image|").split("|") + val f = c.substringAfter("|label|").substringBefore("|file|") + val e = "${a[6]}://${a[21]}.e-${a[20]}-${a[19]}.${a[18]}/${b[1]}/v.$f" + val d = e.replace(b[1],b[3]) + val links: MutableMap = mutableMapOf( + e to b[0].getIntFromText(), + d to b[2].getIntFromText(), + ) + links.forEach { (watchlink, quality) -> + if(watchlink.isNotBlank()){ + sources.add( + ExtractorLink( + name = name, + source = name, + url = watchlink, + isM3u8 = false, + quality = quality ?: Qualities.Unknown.value, + referer = "$mainUrl/" + ) + ) + } + } + } + return sources + } + }